update javadoc for JDK MethodHandles bug tests, stop stacktrace in DistributionTests
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
5d1d7c9c26
commit
14e6bd196e
|
@ -93,8 +93,13 @@ public class DeploymentTest
|
|||
assertThat(error.getMessage(), Matchers.containsString("503 Service Unavailable"));
|
||||
}
|
||||
|
||||
/**
|
||||
* This reproduces some classloading issue with MethodHandles in JDK14-15, this has been fixed in JDK16.
|
||||
* @see <a href="https://bugs.openjdk.java.net/browse/JDK-8244090">JDK-8244090</a>
|
||||
* @throws Exception if there is an error during the test.
|
||||
*/
|
||||
@Test
|
||||
@DisabledOnJre({JRE.JAVA_14, JRE.JAVA_15}) // TODO: Waiting for bug https://bugs.openjdk.java.net/browse/JDK-8244090.
|
||||
@DisabledOnJre({JRE.JAVA_14, JRE.JAVA_15})
|
||||
public void testDifferentWebAppsWithSameClassInSignature() throws Exception
|
||||
{
|
||||
WSServer.WebApp app1 = server.createWebApp("test1");
|
||||
|
|
|
@ -18,17 +18,23 @@
|
|||
|
||||
package org.eclipse.jetty.tests.distribution;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.eclipse.jetty.client.api.ContentResponse;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.websocket.client.WebSocketClient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
|
@ -153,4 +159,50 @@ public class BadAppTests extends AbstractDistributionTest
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"",
|
||||
"--jpms",
|
||||
})
|
||||
public void testBadWebSocketWebapp(String arg) throws Exception
|
||||
{
|
||||
String jettyVersion = System.getProperty("jettyVersion");
|
||||
DistributionTester distribution = DistributionTester.Builder.newInstance()
|
||||
.jettyVersion(jettyVersion)
|
||||
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
|
||||
.build();
|
||||
String[] args1 = {
|
||||
"--create-startd",
|
||||
"--approve-all-licenses",
|
||||
"--add-to-start=resources,server,http,webapp,deploy,jsp,jmx,servlet,servlets,websocket"
|
||||
};
|
||||
|
||||
try (DistributionTester.Run run1 = distribution.start(args1))
|
||||
{
|
||||
assertTrue(run1.awaitFor(5, TimeUnit.SECONDS));
|
||||
assertEquals(0, run1.getExitValue());
|
||||
|
||||
File badWebApp = distribution.resolveArtifact("org.eclipse.jetty.tests:test-bad-websocket-webapp:war:" + jettyVersion);
|
||||
distribution.installWarFile(badWebApp, "test");
|
||||
|
||||
int port = distribution.freePort();
|
||||
String[] args2 = {arg, "jetty.http.port=" + port};
|
||||
|
||||
try (DistributionTester.Run run2 = distribution.start(args2))
|
||||
{
|
||||
assertTrue(run2.awaitConsoleLogsFor("Started Server@", 10, TimeUnit.SECONDS));
|
||||
assertFalse(run2.getLogs().stream().anyMatch(s -> s.contains("LinkageError")));
|
||||
|
||||
startHttpClient();
|
||||
WebSocketClient wsClient = new WebSocketClient(client);
|
||||
wsClient.start();
|
||||
URI serverUri = URI.create("ws://localhost:" + port);
|
||||
|
||||
// Verify /test is not able to establish a WebSocket connection.
|
||||
ContentResponse response = client.GET(serverUri.resolve("/test/badonopen/a"));
|
||||
assertEquals(HttpStatus.SERVICE_UNAVAILABLE_503, response.getStatus());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -412,12 +412,14 @@ public class DistributionTests extends AbstractDistributionTest
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This reproduces some classloading issue with MethodHandles in JDK14-15, this has been fixed in JDK16.
|
||||
* @see <a href="https://bugs.openjdk.java.net/browse/JDK-8244090">JDK-8244090</a>
|
||||
* @throws Exception if there is an error during the test.
|
||||
*/
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"",
|
||||
"--jpms",
|
||||
})
|
||||
@DisabledOnJre({JRE.JAVA_14, JRE.JAVA_15}) // TODO: Waiting for bug https://bugs.openjdk.java.net/browse/JDK-8244090.
|
||||
@ValueSource(strings = {"", "--jpms"})
|
||||
@DisabledOnJre({JRE.JAVA_14, JRE.JAVA_15})
|
||||
public void testSimpleWebAppWithWebsocket(String arg) throws Exception
|
||||
{
|
||||
String jettyVersion = System.getProperty("jettyVersion");
|
||||
|
@ -436,12 +438,8 @@ public class DistributionTests extends AbstractDistributionTest
|
|||
assertEquals(0, run1.getExitValue());
|
||||
|
||||
File webApp = distribution.resolveArtifact("org.eclipse.jetty.tests:test-websocket-webapp:war:" + jettyVersion);
|
||||
File badWebApp = distribution.resolveArtifact("org.eclipse.jetty.tests:test-bad-websocket-webapp:war:" + jettyVersion);
|
||||
|
||||
distribution.installWarFile(webApp, "test1");
|
||||
distribution.installWarFile(badWebApp, "test2");
|
||||
distribution.installWarFile(badWebApp, "test3");
|
||||
distribution.installWarFile(webApp, "test4");
|
||||
distribution.installWarFile(webApp, "test2");
|
||||
|
||||
int port = distribution.freePort();
|
||||
String[] args2 = {
|
||||
|
@ -469,15 +467,9 @@ public class DistributionTests extends AbstractDistributionTest
|
|||
assertTrue(webSocketListener.closeLatch.await(5, TimeUnit.SECONDS));
|
||||
assertThat(webSocketListener.closeCode, is(StatusCode.NORMAL));
|
||||
|
||||
// Verify that /test2 and /test3 could not be started.
|
||||
ContentResponse response = client.GET(serverUri.resolve("/test2/badonopen/a"));
|
||||
assertEquals(HttpStatus.SERVICE_UNAVAILABLE_503, response.getStatus());
|
||||
client.GET("http://localhost:" + port + "/test3/badonopen/a");
|
||||
assertEquals(HttpStatus.SERVICE_UNAVAILABLE_503, response.getStatus());
|
||||
|
||||
// Verify /test4 is able to establish a WebSocket connection.
|
||||
// Verify /test2 is able to establish a WebSocket connection.
|
||||
webSocketListener = new WsListener();
|
||||
session = wsClient.connect(webSocketListener, serverUri.resolve("/test4")).get(5, TimeUnit.SECONDS);
|
||||
session = wsClient.connect(webSocketListener, serverUri.resolve("/test2")).get(5, TimeUnit.SECONDS);
|
||||
session.getRemote().sendString("echo message");
|
||||
assertThat(webSocketListener.textMessages.poll(5, TimeUnit.SECONDS), is("echo message"));
|
||||
session.close();
|
||||
|
@ -489,9 +481,9 @@ public class DistributionTests extends AbstractDistributionTest
|
|||
|
||||
public static class WsListener implements WebSocketListener
|
||||
{
|
||||
BlockingArrayQueue<String> textMessages = new BlockingArrayQueue<>();
|
||||
private CountDownLatch closeLatch = new CountDownLatch(1);
|
||||
private int closeCode;
|
||||
public BlockingArrayQueue<String> textMessages = new BlockingArrayQueue<>();
|
||||
public final CountDownLatch closeLatch = new CountDownLatch(1);
|
||||
public int closeCode;
|
||||
|
||||
@Override
|
||||
public void onWebSocketClose(int statusCode, String reason)
|
||||
|
|
Loading…
Reference in New Issue