Skip to content

Commit

Permalink
Expect100Continue test fixed for NettyConnector
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Nesen <[email protected]>
  • Loading branch information
senivam committed Apr 11, 2024
1 parent 9a88261 commit 86ea86c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tests/e2e-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@
<profile>
<id>JettyTestExclude</id>
<activation>
<jdk>[11,)</jdk>
<jdk>[11,17)</jdk>
</activation>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand Down Expand Up @@ -28,11 +28,8 @@
import org.glassfish.jersey.netty.connector.NettyConnectorProvider;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.ws.rs.ProcessingException;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
Expand Down Expand Up @@ -66,9 +63,10 @@ public class Expect100ContinueTest /*extends JerseyTest*/ {

private static Server server;
@BeforeAll
public static void startExpect100ContinueTestServer() {
private static void startExpect100ContinueTestServer() {
server = new Server(portNumber);
server.setHandler(new Expect100ContinueTestHandler());
server.setDefaultHandler(new Expect100ContinueTestHandler());
server.setDynamic(true);
try {
server.start();
} catch (Exception e) {
Expand All @@ -77,31 +75,28 @@ public static void startExpect100ContinueTestServer() {
}

@AfterAll
public static void stopExpect100ContinueTestServer() {
private static void stopExpect100ContinueTestServer() {
try {
server.stop();
} catch (Exception e) {
}
}

private static Client client;
@BeforeEach
public void beforeEach() {
@BeforeAll
private static void initClient() {
final ClientConfig config = new ClientConfig();
this.configureClient(config);
config.connectorProvider(new NettyConnectorProvider());
client = ClientBuilder.newClient(config);
}

private Client client() {
return client;
@AfterAll
private static void stopClient() {
client.close();
}

private static Client client;
public WebTarget target(String path) {
return client().target(String.format("http://localhost:%d", portNumber)).path(path);
}

protected void configureClient(ClientConfig config) {
config.connectorProvider(new NettyConnectorProvider());
return client.target(String.format("http://localhost:%d", portNumber)).path(path);
}

@Test
Expand Down Expand Up @@ -234,6 +229,11 @@ public boolean handle(Request request,
callback.succeeded();
return true;
}
if (!expected && !failed) {
response.reset();
callback.succeeded();
return true;
}
response.write(true, ByteBuffer.wrap("\n\r".getBytes()), callback);

callback.failed(new ProcessingException(""));
Expand Down

0 comments on commit 86ea86c

Please sign in to comment.