Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add module configuration for demo handler #8490

Merged
merged 3 commits into from
Sep 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html

[description]
Demo Handler

[tags]
demo
handler

[depends]
server

[files]
basehome:modules/demo.d/demo-handler.xml|etc/demo-handler.xml
maven://org.eclipse.jetty.demos/jetty-demo-handler/${jetty.version}/jar|lib/jetty-demo-handler.jar
olamy marked this conversation as resolved.
Show resolved Hide resolved

[xml]
etc/demo-handler.xml

[lib]
lib/jetty-demo-handler.jar
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">

<Configure id="helloDemo" class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="handler">
<New class="org.eclipse.jetty.demo.HelloHandler" />
</Set>
</Configure>
<Configure id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection">
<Call name="addHandler">
<Arg>
<New id="helloHandler" class="org.eclipse.jetty.server.handler.ContextHandler">
<Set name="handler">
<New class="org.eclipse.jetty.demo.HelloHandler" />
</Set>
<Set name="contextPath">/demo-handler</Set>
</New>
</Arg>
</Call>
</Configure>
47 changes: 6 additions & 41 deletions jetty-home/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -607,47 +607,12 @@
<optional>true</optional>
</dependency>

<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-hazelcast</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty.gcloud</groupId>-->
<!-- <artifactId>jetty-gcloud-session-manager</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty.memcached</groupId>-->
<!-- <artifactId>jetty-memcached-sessions</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-nosql</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->

<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-hazelcast</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty.gcloud</groupId>-->
<!-- <artifactId>jetty-gcloud-session-manager</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty.memcached</groupId>-->
<!-- <artifactId>jetty-memcached-sessions</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-nosql</artifactId>-->
<!-- <optional>true</optional>-->
<!-- </dependency>-->
<dependency>
<groupId>org.eclipse.jetty.demos</groupId>
<artifactId>jetty-demo-handler</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.util.Fields;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -421,4 +422,45 @@ public void testSessionDump(String env) throws Exception
}
}
}

@Test
public void testDemoHandler() throws Exception
{
Path jettyBase = newTestJettyBaseDirectory();
String jettyVersion = System.getProperty("jettyVersion");
JettyHomeTester distribution = JettyHomeTester.Builder.newInstance()
.jettyVersion(jettyVersion)
.jettyBase(jettyBase)
.mavenLocalRepository(System.getProperty("mavenRepoPath"))
.build();

int httpPort = distribution.freePort();

String[] argsConfig = {
"--add-modules=http,demo-handler"
};

String baseURI = "http://localhost:%d/demo-handler/".formatted(httpPort);

try (JettyHomeTester.Run runConfig = distribution.start(argsConfig))
{
assertTrue(runConfig.awaitFor(START_TIMEOUT, TimeUnit.SECONDS));
assertEquals(0, runConfig.getExitValue());

String[] argsStart = {
"jetty.http.port=" + httpPort
};

try (JettyHomeTester.Run runStart = distribution.start(argsStart))
{
assertTrue(runStart.awaitConsoleLogsFor("Started oejs.Server@", START_TIMEOUT, TimeUnit.SECONDS));

startHttpClient();
ContentResponse response = client.GET(baseURI);

assertEquals(HttpStatus.OK_200, response.getStatus(), new ResponseDetails(response));
assertThat(response.getContentAsString(), containsString("Hello World"));
}
}
}
}