From bb27fa6cc0cc9a875c9db7096eea22138c26560e Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Tue, 17 Sep 2019 11:18:14 +0200 Subject: [PATCH] Issue #3747 - Make Jetty Demo work with JPMS. Added distribution test for running with JPMS. Signed-off-by: Simone Bordet --- .../tests/distribution/DemoBaseTests.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java index 40828383857..a4f06e74c49 100644 --- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java +++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DemoBaseTests.java @@ -24,6 +24,8 @@ import java.util.concurrent.TimeUnit; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.http.HttpStatus; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnJre; +import org.junit.jupiter.api.condition.JRE; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.containsString; @@ -142,4 +144,33 @@ public class DemoBaseTests extends AbstractDistributionTest assertThat(response.getContentAsString(), not(containsString("FAIL"))); } } + + @Test + @DisabledOnJre(JRE.JAVA_8) + public void testJPMS() throws Exception + { + String jettyVersion = System.getProperty("jettyVersion"); + DistributionTester distribution = DistributionTester.Builder.newInstance() + .jettyVersion(jettyVersion) + .jettyBase(Paths.get("demo-base")) + .mavenLocalRepository(System.getProperty("mavenRepoPath")) + .build(); + + int httpPort = distribution.freePort(); + int httpsPort = distribution.freePort(); + String[] args = { + "--jpms", + "jetty.http.port=" + httpPort, + "jetty.httpConfig.port=" + httpsPort, + "jetty.ssl.port=" + httpsPort + }; + try (DistributionTester.Run run = distribution.start(args)) + { + assertTrue(run.awaitConsoleLogsFor("Started @", 10, TimeUnit.SECONDS)); + + startHttpClient(); + ContentResponse response = client.GET("http://localhost:" + httpPort + "/test/hello"); + assertEquals(HttpStatus.OK_200, response.getStatus()); + } + } }