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 <maxim.nesen@oracle.com>
  • Loading branch information
senivam committed Apr 11, 2024
1 parent 9a88261 commit f6fedfd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 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 @@ -27,12 +27,11 @@
import org.glassfish.jersey.netty.connector.NettyClientProperties;
import org.glassfish.jersey.netty.connector.NettyConnectorProvider;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
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 @@ -65,43 +64,40 @@ public class Expect100ContinueTest /*extends JerseyTest*/ {
private static final Integer portNumber = 9997;

private static Server server;
@BeforeAll
public static void startExpect100ContinueTestServer() {
@BeforeEach
private void startExpect100ContinueTestServer() {
server = new Server(portNumber);
server.setHandler(new Expect100ContinueTestHandler());
server.setDefaultHandler(new Expect100ContinueTestHandler());
try {
server.start();
} catch (Exception e) {

}
}

@AfterAll
public static void stopExpect100ContinueTestServer() {
@AfterEach
private 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

0 comments on commit f6fedfd

Please sign in to comment.