Merge remote-tracking branch 'origin/jetty-9.4.x'
This commit is contained in:
commit
6df5377634
|
@ -15,7 +15,7 @@
|
||||||
<name>Jetty :: Simple :: Webapp</name>
|
<name>Jetty :: Simple :: Webapp</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
<jetty.port.file>${project.build.directory}/jetty-run-distro-port.txt</jetty.port.file>
|
||||||
<jetty.jvmArgs>@jetty.jvmArgs@</jetty.jvmArgs>
|
<jetty.jvmArgs>@jetty.jvmArgs@</jetty.jvmArgs>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
<version>2.20</version>
|
<version>2.20</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -87,52 +87,20 @@
|
||||||
<goal>run-distro</goal>
|
<goal>run-distro</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<jettyBase>${basedir}/src/base</jettyBase>
|
||||||
<jettyProperties>
|
<jettyProperties>
|
||||||
<jettyProperty>jetty.server.dumpAfterStart=true</jettyProperty>
|
<jettyProperty>jetty.server.dumpAfterStart=true</jettyProperty>
|
||||||
<jettyProperty>jetty.http.port=@jetty.runPort@</jettyProperty>
|
<jettyProperty>jetty.port.file=${jetty.port.file}</jettyProperty>
|
||||||
|
<jettyProperty>jetty.http.port=0</jettyProperty>
|
||||||
</jettyProperties>
|
</jettyProperties>
|
||||||
<waitForChild>false</waitForChild>
|
<waitForChild>false</waitForChild>
|
||||||
<modules>
|
<modules>
|
||||||
<module>jsp</module>
|
<module>jsp</module>
|
||||||
<module>jstl</module>
|
<module>jstl</module>
|
||||||
|
<module>testmod</module>
|
||||||
</modules>
|
</modules>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<!--
|
|
||||||
<execution>
|
|
||||||
<id>stop-jetty</id>
|
|
||||||
<phase>test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>stop</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
-->
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>copy-resources-jetty</id>
|
|
||||||
<phase>generate-resources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-resources</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${project.build.directory}/config</outputDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>${basedir}/src/config/</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
<includes>
|
|
||||||
<include>**/**</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||||
|
|
||||||
|
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||||
|
<Ref id="httpConnector">
|
||||||
|
<Call name="addLifeCycleListener">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.maven.plugin.ServerConnectorListener">
|
||||||
|
<Set name="fileName"><Property name="jetty.port.file" default="port.txt"/></Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
|
</Ref>
|
||||||
|
</Configure>
|
|
@ -0,0 +1,10 @@
|
||||||
|
[description]
|
||||||
|
Enables test setup
|
||||||
|
|
||||||
|
[depend]
|
||||||
|
http
|
||||||
|
|
||||||
|
|
||||||
|
[xml]
|
||||||
|
etc/test-jetty.xml
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.its.jetty_run_distro_mojo_it;
|
package org.eclipse.jetty.its.jetty_run_distro_mojo_it;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.LineNumberReader;
|
||||||
|
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -32,8 +36,8 @@ public class TestHelloServlet
|
||||||
public void hello_servlet()
|
public void hello_servlet()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int port = Integer.getInteger( "jetty.runPort" );
|
int port = getPort();
|
||||||
System.out.println( "port used:" + port );
|
Assert.assertTrue(port > 0);
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -41,14 +45,10 @@ public class TestHelloServlet
|
||||||
|
|
||||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse hello annotation servlet:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "hello beer", response.trim() );
|
Assert.assertEquals( "hello beer", response.trim() );
|
||||||
|
|
||||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse ping fragment servlet:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "pong beer", response.trim() );
|
Assert.assertEquals( "pong beer", response.trim() );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -56,4 +56,38 @@ public class TestHelloServlet
|
||||||
httpClient.stop();
|
httpClient.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPort()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int port = -1;
|
||||||
|
String s = System.getProperty("jetty.port.file");
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
File f = new File(s);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (f.exists())
|
||||||
|
{
|
||||||
|
try (FileReader r = new FileReader(f);
|
||||||
|
LineNumberReader lnr = new LineNumberReader(r);
|
||||||
|
)
|
||||||
|
{
|
||||||
|
s = lnr.readLine();
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
port = Integer.parseInt(s.trim());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (--attempts < 0)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
Thread.currentThread().sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.eclipse.jetty.its.jetty-run-distro-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-run-distro-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-project</artifactId>
|
<artifactId>jetty-simple-project</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Jetty :: Simple</name>
|
<name>Jetty :: Simple</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||||
<jetty.version>@project.version@</jetty.version>
|
<jetty.version>@project.version@</jetty.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>jetty-simple-base</module>
|
<module>jetty-simple-base</module>
|
||||||
<module>jetty-simple-webapp</module>
|
<module>jetty-simple-webapp</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -31,59 +31,54 @@
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.7.21</version>
|
<version>1.7.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.5</version>
|
<version>2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
<version>${jetty.version}</version>
|
<version>${jetty.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${jetty.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
</plugins>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
</pluginManagement>
|
||||||
<artifactId>jetty-maven-plugin</artifactId>
|
</build>
|
||||||
<version>${jetty.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
<name>Jetty :: Simple :: Webapp</name>
|
<name>Jetty :: Simple :: Webapp</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
|
||||||
<jetty.jvmArgs>@jetty.jvmArgs@</jetty.jvmArgs>
|
<jetty.jvmArgs>@jetty.jvmArgs@</jetty.jvmArgs>
|
||||||
|
<jetty.port.file>${project.build.directory}/jetty-run-forked-port.txt</jetty.port.file>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -39,6 +39,13 @@
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||||
|
<artifactId>jetty-test-helper</artifactId>
|
||||||
|
<version>4.2</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -68,7 +75,7 @@
|
||||||
<version>2.20</version>
|
<version>2.20</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -89,8 +96,11 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<nonBlocking>true</nonBlocking>
|
<nonBlocking>true</nonBlocking>
|
||||||
<waitForChild>false</waitForChild>
|
<waitForChild>false</waitForChild>
|
||||||
<jettyXml>${project.build.directory}/config/jetty.xml</jettyXml>
|
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||||
<jvmArgs>${jetty.jvmArgs}</jvmArgs>
|
<jvmArgs>${jetty.jvmArgs}</jvmArgs>
|
||||||
|
<jettyProperties>
|
||||||
|
<jettyProperty>jetty.port.file=${jetty.port.file}</jettyProperty>
|
||||||
|
</jettyProperties>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
<!--
|
<!--
|
||||||
|
@ -104,32 +114,6 @@
|
||||||
-->
|
-->
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
|
||||||
<version>3.0.2</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>copy-resources-jetty</id>
|
|
||||||
<phase>generate-resources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-resources</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${project.build.directory}/config</outputDirectory>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>${basedir}/src/config/</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
<includes>
|
|
||||||
<include>**/**</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,17 @@
|
||||||
</Item>
|
</Item>
|
||||||
</Array>
|
</Array>
|
||||||
</Arg>
|
</Arg>
|
||||||
|
<Call name="addLifeCycleListener">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.maven.plugin.ServerConnectorListener">
|
||||||
|
<Set name="fileName"><Property name="jetty.port.file" default="port.txt"/></Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
<Set name="host"><Property name="jetty.host" /></Set>
|
<Set name="host"><Property name="jetty.host" /></Set>
|
||||||
<Set name="port"><Property name="jetty.port" default="${jetty.runPort}" /></Set>
|
<Set name="port"><Property name="jetty.port" default="0" />0</Set>
|
||||||
<Set name="idleTimeout">30000</Set>
|
<Set name="idleTimeout">30000</Set>
|
||||||
</New>
|
</New>
|
||||||
</Arg>
|
</Arg>
|
||||||
</Call>
|
</Call>
|
||||||
</Configure>
|
</Configure>
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.its.jetty_run_forked_mojo_it;
|
package org.eclipse.jetty.its.jetty_run_forked_mojo_it;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.LineNumberReader;
|
||||||
|
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -31,8 +35,9 @@ public class TestHelloServlet
|
||||||
public void hello_servlet()
|
public void hello_servlet()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int port = Integer.getInteger( "jetty.runPort" );
|
|
||||||
System.out.println( "port used:" + port );
|
int port = getPort();
|
||||||
|
Assert.assertTrue(port > 0);
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -40,14 +45,10 @@ public class TestHelloServlet
|
||||||
|
|
||||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse hello annotation servlet:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "hello beer", response.trim() );
|
Assert.assertEquals( "hello beer", response.trim() );
|
||||||
|
|
||||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse ping fragment servlet:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "pong beer", response.trim() );
|
Assert.assertEquals( "pong beer", response.trim() );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -55,4 +56,38 @@ public class TestHelloServlet
|
||||||
httpClient.stop();
|
httpClient.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getPort()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int port = -1;
|
||||||
|
String s = System.getProperty("jetty.port.file");
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
File f = new File(s);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (f.exists())
|
||||||
|
{
|
||||||
|
try (FileReader r = new FileReader(f);
|
||||||
|
LineNumberReader lnr = new LineNumberReader(r);
|
||||||
|
)
|
||||||
|
{
|
||||||
|
s = lnr.readLine();
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
port = Integer.parseInt(s.trim());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (--attempts < 0)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
Thread.currentThread().sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return port;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,90 +1,85 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-project</artifactId>
|
<artifactId>jetty-simple-project</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Jetty :: Simple</name>
|
<name>Jetty :: Simple</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||||
<jetty.version>@project.version@</jetty.version>
|
<jetty.version>@project.version@</jetty.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>jetty-simple-base</module>
|
<module>jetty-simple-base</module>
|
||||||
<module>jetty-simple-webapp</module>
|
<module>jetty-simple-webapp</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-base</artifactId>
|
<artifactId>jetty-simple-base</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.7.21</version>
|
<version>1.7.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.5</version>
|
<version>2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
<version>${jetty.version}</version>
|
<version>${jetty.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${jetty.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
</plugins>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
</pluginManagement>
|
||||||
<artifactId>jetty-maven-plugin</artifactId>
|
</build>
|
||||||
<version>${jetty.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
|
|
||||||
<name>Jetty :: Simple :: Webapp</name>
|
<name>Jetty :: Simple :: Webapp</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jetty.port.file>${project.build.directory}/jetty-run-mojo.txt</jetty.port.file>
|
||||||
|
</properties>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -68,7 +71,7 @@
|
||||||
<version>2.20</version>
|
<version>2.20</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -83,10 +86,14 @@
|
||||||
<goal>start</goal>
|
<goal>start</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<systemProperty>
|
||||||
|
<name>jetty.port.file</name>
|
||||||
|
<value>${jetty.port.file}</value>
|
||||||
|
</systemProperty>
|
||||||
|
</systemProperties>
|
||||||
<nonBlocking>true</nonBlocking>
|
<nonBlocking>true</nonBlocking>
|
||||||
<httpConnector>
|
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||||
<port>@jetty.runPort@</port>
|
|
||||||
</httpConnector>
|
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
|
@ -24,10 +24,17 @@
|
||||||
</Item>
|
</Item>
|
||||||
</Array>
|
</Array>
|
||||||
</Arg>
|
</Arg>
|
||||||
|
<Call name="addLifeCycleListener">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.maven.plugin.ServerConnectorListener">
|
||||||
|
<Set name="fileName"><Property name="jetty.port.file" default="port.txt"/></Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
<Set name="host"><Property name="jetty.host" /></Set>
|
<Set name="host"><Property name="jetty.host" /></Set>
|
||||||
<Set name="port"><Property name="jetty.port" default="${jetty.runPort}" /></Set>
|
<Set name="port"><Property name="jetty.port" default="0" />0</Set>
|
||||||
<Set name="idleTimeout">30000</Set>
|
<Set name="idleTimeout">30000</Set>
|
||||||
</New>
|
</New>
|
||||||
</Arg>
|
</Arg>
|
||||||
</Call>
|
</Call>
|
||||||
</Configure>
|
</Configure>
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.its.jetty_run_mojo_it;
|
package org.eclipse.jetty.its.jetty_run_mojo_it;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.LineNumberReader;
|
||||||
|
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -32,8 +36,7 @@ public class TestHelloServlet
|
||||||
public void hello_servlet()
|
public void hello_servlet()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int port = Integer.getInteger( "jetty.runPort" );
|
int port = getPort();
|
||||||
System.out.println( "port used:" + port );
|
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -41,14 +44,10 @@ public class TestHelloServlet
|
||||||
|
|
||||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse hello annotation servlet:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "hello beer", response.trim() );
|
Assert.assertEquals( "hello beer", response.trim() );
|
||||||
|
|
||||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse ping fragment servlet:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "pong beer", response.trim() );
|
Assert.assertEquals( "pong beer", response.trim() );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -56,4 +55,37 @@ public class TestHelloServlet
|
||||||
httpClient.stop();
|
httpClient.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPort()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int port = -1;
|
||||||
|
String s = System.getProperty("jetty.port.file");
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
File f = new File(s);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (f.exists())
|
||||||
|
{
|
||||||
|
try (FileReader r = new FileReader(f);
|
||||||
|
LineNumberReader lnr = new LineNumberReader(r);
|
||||||
|
)
|
||||||
|
{
|
||||||
|
s = lnr.readLine();
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
port = Integer.parseInt(s.trim());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (--attempts < 0)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
Thread.currentThread().sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return port;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,96 +1,91 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-project</artifactId>
|
<artifactId>jetty-simple-project</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Jetty :: Simple</name>
|
<name>Jetty :: Simple</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||||
<jetty.version>@project.version@</jetty.version>
|
<jetty.version>@project.version@</jetty.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>jetty-simple-base</module>
|
<module>jetty-simple-base</module>
|
||||||
<module>jetty-simple-webapp</module>
|
<module>jetty-simple-webapp</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-base</artifactId>
|
<artifactId>jetty-simple-base</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.7.21</version>
|
<version>1.7.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-simple</artifactId>
|
<artifactId>slf4j-simple</artifactId>
|
||||||
<version>1.7.21</version>
|
<version>1.7.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.5</version>
|
<version>2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
<version>${jetty.version}</version>
|
<version>${jetty.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${jetty.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
</plugins>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
</pluginManagement>
|
||||||
<artifactId>jetty-maven-plugin</artifactId>
|
</build>
|
||||||
<version>${jetty.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
|
|
||||||
<name>Jetty :: Simple :: Webapp</name>
|
<name>Jetty :: Simple :: Webapp</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jetty.port.file>${project.build.directory}/jetty-run-war-exploded-port.txt</jetty.port.file>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -64,7 +68,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<skip>true</skip>
|
<skip>true</skip>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -74,7 +78,7 @@
|
||||||
<version>2.20</version>
|
<version>2.20</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*TestHelloServlet*</include>
|
<include>**/*TestHelloServlet*</include>
|
||||||
|
@ -107,9 +111,13 @@
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<nonBlocking>true</nonBlocking>
|
<nonBlocking>true</nonBlocking>
|
||||||
<httpConnector>
|
<systemProperties>
|
||||||
<port>@jetty.runPort@</port>
|
<systemProperty>
|
||||||
</httpConnector>
|
<name>jetty.port.file</name>
|
||||||
|
<value>${jetty.port.file}</value>
|
||||||
|
</systemProperty>
|
||||||
|
</systemProperties>
|
||||||
|
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||||
|
|
||||||
|
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||||
|
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||||
|
<Set name="secureScheme">https</Set>
|
||||||
|
<Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
|
||||||
|
<Set name="outputBufferSize">32768</Set>
|
||||||
|
<Set name="requestHeaderSize">8192</Set>
|
||||||
|
<Set name="responseHeaderSize">8192</Set>
|
||||||
|
<Set name="headerCacheSize">512</Set>
|
||||||
|
</New>
|
||||||
|
|
||||||
|
<Call name="addConnector">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||||
|
<Arg name="server"><Ref refid="Server" /></Arg>
|
||||||
|
<Arg name="factories">
|
||||||
|
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||||
|
<Item>
|
||||||
|
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||||
|
<Arg name="config"><Ref refid="httpConfig" /></Arg>
|
||||||
|
</New>
|
||||||
|
</Item>
|
||||||
|
</Array>
|
||||||
|
</Arg>
|
||||||
|
<Call name="addLifeCycleListener">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.maven.plugin.ServerConnectorListener">
|
||||||
|
<Set name="fileName"><Property name="jetty.port.file" default="port.txt"/></Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
|
<Set name="host"><Property name="jetty.host" /></Set>
|
||||||
|
<Set name="port"><Property name="jetty.port" default="0" />0</Set>
|
||||||
|
<Set name="idleTimeout">30000</Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
|
</Configure>
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.its.jetty_run_war_exploded_mojo_it;
|
package org.eclipse.jetty.its.jetty_run_war_exploded_mojo_it;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.LineNumberReader;
|
||||||
|
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -32,8 +36,8 @@ public class TestHelloServlet
|
||||||
public void hello_servlet()
|
public void hello_servlet()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int port = Integer.getInteger( "jetty.runPort" );
|
int port = getPort();
|
||||||
System.out.println( "port used:" + port );
|
Assert.assertTrue(port > 0);
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -41,14 +45,10 @@ public class TestHelloServlet
|
||||||
|
|
||||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "hello beer", response.trim() );
|
Assert.assertEquals( "hello beer", response.trim() );
|
||||||
|
|
||||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "pong beer", response.trim() );
|
Assert.assertEquals( "pong beer", response.trim() );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -56,4 +56,38 @@ public class TestHelloServlet
|
||||||
httpClient.stop();
|
httpClient.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPort()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int port = -1;
|
||||||
|
String s = System.getProperty("jetty.port.file");
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
File f = new File(s);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (f.exists())
|
||||||
|
{
|
||||||
|
try (FileReader r = new FileReader(f);
|
||||||
|
LineNumberReader lnr = new LineNumberReader(r);
|
||||||
|
)
|
||||||
|
{
|
||||||
|
s = lnr.readLine();
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
port = Integer.parseInt(s.trim());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (--attempts < 0)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
Thread.currentThread().sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,90 +1,85 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-project</artifactId>
|
<artifactId>jetty-simple-project</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Jetty :: Simple</name>
|
<name>Jetty :: Simple</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||||
<jetty.version>@project.version@</jetty.version>
|
<jetty.version>@project.version@</jetty.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>jetty-simple-base</module>
|
<module>jetty-simple-base</module>
|
||||||
<module>jetty-simple-webapp</module>
|
<module>jetty-simple-webapp</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-base</artifactId>
|
<artifactId>jetty-simple-base</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.7.21</version>
|
<version>1.7.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.5</version>
|
<version>2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
<version>${jetty.version}</version>
|
<version>${jetty.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${jetty.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
</plugins>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
</pluginManagement>
|
||||||
<artifactId>jetty-maven-plugin</artifactId>
|
</build>
|
||||||
<version>${jetty.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -14,6 +14,12 @@
|
||||||
|
|
||||||
<name>Jetty :: Simple :: Webapp</name>
|
<name>Jetty :: Simple :: Webapp</name>
|
||||||
|
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jetty.port.file>${project.build.directory}/jetty-run-war-port.txt</jetty.port.file>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -64,7 +70,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<skip>true</skip>
|
<skip>true</skip>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -74,7 +80,7 @@
|
||||||
<version>2.20</version>
|
<version>2.20</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
<includes>
|
<includes>
|
||||||
<include>**/*TestHelloServlet*</include>
|
<include>**/*TestHelloServlet*</include>
|
||||||
|
@ -107,9 +113,13 @@
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<nonBlocking>true</nonBlocking>
|
<nonBlocking>true</nonBlocking>
|
||||||
<httpConnector>
|
<systemProperties>
|
||||||
<port>@jetty.runPort@</port>
|
<systemProperty>
|
||||||
</httpConnector>
|
<name>jetty.port.file</name>
|
||||||
|
<value>${jetty.port.file}</value>
|
||||||
|
</systemProperty>
|
||||||
|
</systemProperties>
|
||||||
|
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||||
|
|
||||||
|
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||||
|
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||||
|
<Set name="secureScheme">https</Set>
|
||||||
|
<Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
|
||||||
|
<Set name="outputBufferSize">32768</Set>
|
||||||
|
<Set name="requestHeaderSize">8192</Set>
|
||||||
|
<Set name="responseHeaderSize">8192</Set>
|
||||||
|
<Set name="headerCacheSize">512</Set>
|
||||||
|
</New>
|
||||||
|
|
||||||
|
<Call name="addConnector">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||||
|
<Arg name="server"><Ref refid="Server" /></Arg>
|
||||||
|
<Arg name="factories">
|
||||||
|
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||||
|
<Item>
|
||||||
|
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||||
|
<Arg name="config"><Ref refid="httpConfig" /></Arg>
|
||||||
|
</New>
|
||||||
|
</Item>
|
||||||
|
</Array>
|
||||||
|
</Arg>
|
||||||
|
<Call name="addLifeCycleListener">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.maven.plugin.ServerConnectorListener">
|
||||||
|
<Set name="fileName"><Property name="jetty.port.file" default="port.txt"/></Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
|
<Set name="host"><Property name="jetty.host" /></Set>
|
||||||
|
<Set name="port"><Property name="jetty.port" default="0" />0</Set>
|
||||||
|
<Set name="idleTimeout">30000</Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
|
</Configure>
|
|
@ -19,6 +19,10 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.its.jetty_run_war_mojo_it;
|
package org.eclipse.jetty.its.jetty_run_war_mojo_it;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.LineNumberReader;
|
||||||
|
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -32,8 +36,8 @@ public class TestHelloServlet
|
||||||
public void hello_servlet()
|
public void hello_servlet()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int port = Integer.getInteger( "jetty.runPort" );
|
int port = getPort();
|
||||||
System.out.println( "port used:" + port );
|
Assert.assertTrue(port > 0);
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -41,14 +45,10 @@ public class TestHelloServlet
|
||||||
|
|
||||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "hello beer", response.trim() );
|
Assert.assertEquals( "hello beer", response.trim() );
|
||||||
|
|
||||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "pong beer", response.trim() );
|
Assert.assertEquals( "pong beer", response.trim() );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -56,4 +56,38 @@ public class TestHelloServlet
|
||||||
httpClient.stop();
|
httpClient.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPort()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int port = -1;
|
||||||
|
String s = System.getProperty("jetty.port.file");
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
File f = new File(s);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (f.exists())
|
||||||
|
{
|
||||||
|
try (FileReader r = new FileReader(f);
|
||||||
|
LineNumberReader lnr = new LineNumberReader(r);
|
||||||
|
)
|
||||||
|
{
|
||||||
|
s = lnr.readLine();
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
port = Integer.parseInt(s.trim());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (--attempts < 0)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
Thread.currentThread().sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,90 +1,85 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-project</artifactId>
|
<artifactId>jetty-simple-project</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Jetty :: Simple</name>
|
<name>Jetty :: Simple</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||||
<jetty.version>@project.version@</jetty.version>
|
<jetty.version>@project.version@</jetty.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>jetty-simple-base</module>
|
<module>jetty-simple-base</module>
|
||||||
<module>jetty-simple-webapp</module>
|
<module>jetty-simple-webapp</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-base</artifactId>
|
<artifactId>jetty-simple-base</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.7.21</version>
|
<version>1.7.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.5</version>
|
<version>2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
<version>${jetty.version}</version>
|
<version>${jetty.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${jetty.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
</plugins>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
</pluginManagement>
|
||||||
<artifactId>jetty-maven-plugin</artifactId>
|
</build>
|
||||||
<version>${jetty.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -14,6 +14,10 @@
|
||||||
|
|
||||||
<name>Jetty :: Simple :: Webapp</name>
|
<name>Jetty :: Simple :: Webapp</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<jetty.port.file>${project.build.directory}/jetty-start-port.txt</jetty.port.file>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -63,7 +67,7 @@
|
||||||
<version>2.20</version>
|
<version>2.20</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<systemPropertyVariables>
|
<systemPropertyVariables>
|
||||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -78,9 +82,13 @@
|
||||||
<goal>start</goal>
|
<goal>start</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<httpConnector>
|
<systemProperties>
|
||||||
<port>@jetty.runPort@</port>
|
<systemProperty>
|
||||||
</httpConnector>
|
<name>jetty.port.file</name>
|
||||||
|
<value>${jetty.port.file}</value>
|
||||||
|
</systemProperty>
|
||||||
|
</systemProperties>
|
||||||
|
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_0.dtd">
|
||||||
|
|
||||||
|
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||||
|
<New id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||||
|
<Set name="secureScheme">https</Set>
|
||||||
|
<Set name="securePort"><Property name="jetty.secure.port" default="8443" /></Set>
|
||||||
|
<Set name="outputBufferSize">32768</Set>
|
||||||
|
<Set name="requestHeaderSize">8192</Set>
|
||||||
|
<Set name="responseHeaderSize">8192</Set>
|
||||||
|
<Set name="headerCacheSize">512</Set>
|
||||||
|
</New>
|
||||||
|
|
||||||
|
<Call name="addConnector">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.server.ServerConnector">
|
||||||
|
<Arg name="server"><Ref refid="Server" /></Arg>
|
||||||
|
<Arg name="factories">
|
||||||
|
<Array type="org.eclipse.jetty.server.ConnectionFactory">
|
||||||
|
<Item>
|
||||||
|
<New class="org.eclipse.jetty.server.HttpConnectionFactory">
|
||||||
|
<Arg name="config"><Ref refid="httpConfig" /></Arg>
|
||||||
|
</New>
|
||||||
|
</Item>
|
||||||
|
</Array>
|
||||||
|
</Arg>
|
||||||
|
<Call name="addLifeCycleListener">
|
||||||
|
<Arg>
|
||||||
|
<New class="org.eclipse.jetty.maven.plugin.ServerConnectorListener">
|
||||||
|
<Set name="fileName"><Property name="jetty.port.file" default="port.txt"/></Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
|
<Set name="host"><Property name="jetty.host" /></Set>
|
||||||
|
<Set name="port"><Property name="jetty.port" default="0" />0</Set>
|
||||||
|
<Set name="idleTimeout">30000</Set>
|
||||||
|
</New>
|
||||||
|
</Arg>
|
||||||
|
</Call>
|
||||||
|
</Configure>
|
|
@ -19,6 +19,11 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.its.jetty_start_mojo_it;
|
package org.eclipse.jetty.its.jetty_start_mojo_it;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.LineNumberReader;
|
||||||
|
|
||||||
import org.eclipse.jetty.client.HttpClient;
|
import org.eclipse.jetty.client.HttpClient;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -32,8 +37,8 @@ public class TestHelloServlet
|
||||||
public void hello_servlet()
|
public void hello_servlet()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
int port = Integer.getInteger( "jetty.runPort" );
|
int port = getPort();
|
||||||
System.out.println( "port used:" + port );
|
Assert.assertTrue(port > 0);
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -41,14 +46,10 @@ public class TestHelloServlet
|
||||||
|
|
||||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "hello beer", response.trim() );
|
Assert.assertEquals( "hello beer", response.trim() );
|
||||||
|
|
||||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||||
|
|
||||||
System.out.println( "httpResponse:" + response );
|
|
||||||
|
|
||||||
Assert.assertEquals( "pong beer", response.trim() );
|
Assert.assertEquals( "pong beer", response.trim() );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
@ -56,4 +57,37 @@ public class TestHelloServlet
|
||||||
httpClient.stop();
|
httpClient.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public int getPort()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
int attempts = 20;
|
||||||
|
int port = -1;
|
||||||
|
String s = System.getProperty("jetty.port.file");
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
File f = new File(s);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (f.exists())
|
||||||
|
{
|
||||||
|
try (FileReader r = new FileReader(f);
|
||||||
|
LineNumberReader lnr = new LineNumberReader(r);
|
||||||
|
)
|
||||||
|
{
|
||||||
|
s = lnr.readLine();
|
||||||
|
Assert.assertNotNull(s);
|
||||||
|
port = Integer.parseInt(s.trim());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (--attempts < 0)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
Thread.currentThread().sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,90 +1,85 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-project</artifactId>
|
<artifactId>jetty-simple-project</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<name>Jetty :: Simple</name>
|
<name>Jetty :: Simple</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||||
<jetty.version>@project.version@</jetty.version>
|
<jetty.version>@project.version@</jetty.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>jetty-simple-base</module>
|
<module>jetty-simple-base</module>
|
||||||
<module>jetty-simple-webapp</module>
|
<module>jetty-simple-webapp</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||||
<artifactId>jetty-simple-base</artifactId>
|
<artifactId>jetty-simple-base</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
<artifactId>javax.servlet-api</artifactId>
|
<artifactId>javax.servlet-api</artifactId>
|
||||||
<version>3.1.0</version>
|
<version>3.1.0</version>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<version>1.7.21</version>
|
<version>1.7.21</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.5</version>
|
<version>2.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>jetty-servlet</artifactId>
|
<artifactId>jetty-servlet</artifactId>
|
||||||
<version>${jetty.version}</version>
|
<version>${jetty.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>jetty-maven-plugin</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>${jetty.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
</plugins>
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
</pluginManagement>
|
||||||
<artifactId>jetty-maven-plugin</artifactId>
|
</build>
|
||||||
<version>${jetty.version}</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</pluginManagement>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,116 @@
|
||||||
|
//
|
||||||
|
// ========================================================================
|
||||||
|
// Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd.
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// All rights reserved. This program and the accompanying materials
|
||||||
|
// are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
// and Apache License v2.0 which accompanies this distribution.
|
||||||
|
//
|
||||||
|
// The Eclipse Public License is available at
|
||||||
|
// http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
//
|
||||||
|
// The Apache License v2.0 is available at
|
||||||
|
// http://www.opensource.org/licenses/apache2.0.php
|
||||||
|
//
|
||||||
|
// You may elect to redistribute this code under either of these licenses.
|
||||||
|
// ========================================================================
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
package org.eclipse.jetty.maven.plugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.ServerConnector;
|
||||||
|
import org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener;
|
||||||
|
import org.eclipse.jetty.util.component.LifeCycle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ServerConnectorListener
|
||||||
|
*
|
||||||
|
* This is for test support, where we need jetty to run on a random port, and we need
|
||||||
|
* a client to be able to find out which port was picked.
|
||||||
|
*/
|
||||||
|
public class ServerConnectorListener extends AbstractLifeCycleListener
|
||||||
|
{
|
||||||
|
|
||||||
|
private String _fileName;
|
||||||
|
private String _sysPropertyName;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener#lifeCycleStarted(org.eclipse.jetty.util.component.LifeCycle)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void lifeCycleStarted(LifeCycle event)
|
||||||
|
{
|
||||||
|
if (getFileName() != null)
|
||||||
|
{
|
||||||
|
File file = new File(getFileName());
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Files.deleteIfExists(file.toPath());
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException (e);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (FileWriter writer = new FileWriter(file))
|
||||||
|
{
|
||||||
|
writer.write(String.valueOf(((ServerConnector)event).getLocalPort()));
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException (e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getSysPropertyName() != null)
|
||||||
|
{
|
||||||
|
System.setProperty(_sysPropertyName,String.valueOf(((ServerConnector)event).getLocalPort()));
|
||||||
|
}
|
||||||
|
super.lifeCycleStarted(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the file name
|
||||||
|
*/
|
||||||
|
public String getFileName()
|
||||||
|
{
|
||||||
|
return _fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param filePath the filePath to set
|
||||||
|
*/
|
||||||
|
public void setFileName(String name)
|
||||||
|
{
|
||||||
|
|
||||||
|
System.err.println("FILE NAME="+name);
|
||||||
|
_fileName = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sysPropertyName
|
||||||
|
*/
|
||||||
|
public String getSysPropertyName()
|
||||||
|
{
|
||||||
|
return _sysPropertyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sysPropertyName the sysPropertyName to set
|
||||||
|
*/
|
||||||
|
public void setSysPropertyName(String sysPropertyName)
|
||||||
|
{
|
||||||
|
_sysPropertyName = sysPropertyName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -575,7 +575,8 @@ public class Session implements SessionHandler.SessionIf
|
||||||
{
|
{
|
||||||
try (Lock lock = _lock.lock())
|
try (Lock lock = _lock.lock())
|
||||||
{
|
{
|
||||||
return (int)(_sessionData.getMaxInactiveMs()/1000);
|
long maxInactiveMs = _sessionData.getMaxInactiveMs();
|
||||||
|
return (int)(maxInactiveMs < 0 ? -1 : maxInactiveMs/1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -430,6 +430,53 @@ public abstract class AbstractModifyMaxInactiveIntervalTest extends AbstractTest
|
||||||
server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetMaxInactiveIntervalWithNegativeMaxInactiveInterval() throws Exception
|
||||||
|
{
|
||||||
|
int maxInactive = -1;
|
||||||
|
DefaultSessionCacheFactory cacheFactory = new DefaultSessionCacheFactory();
|
||||||
|
cacheFactory.setEvictionPolicy(SessionCache.NEVER_EVICT);
|
||||||
|
SessionDataStoreFactory storeFactory = createSessionDataStoreFactory();
|
||||||
|
((AbstractSessionDataStoreFactory)storeFactory).setGracePeriodSec(TestServer.DEFAULT_SCAVENGE_SEC);
|
||||||
|
|
||||||
|
TestServer server = new TestServer(0, maxInactive, __scavenge, cacheFactory, storeFactory);
|
||||||
|
ServletContextHandler ctxA = server.addContext("/mod");
|
||||||
|
ctxA.addServlet(TestModServlet.class, "/test");
|
||||||
|
|
||||||
|
server.start();
|
||||||
|
int port=server.getPort();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HttpClient client = new HttpClient();
|
||||||
|
client.start();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// Perform a request to create a session
|
||||||
|
|
||||||
|
ContentResponse response = client.GET("http://localhost:" + port + "/mod/test?action=create");
|
||||||
|
|
||||||
|
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
|
||||||
|
String sessionCookie = response.getHeaders().get("Set-Cookie");
|
||||||
|
assertTrue(sessionCookie != null);
|
||||||
|
|
||||||
|
//Test that the maxInactiveInterval matches the expected value
|
||||||
|
Request request= client.newRequest("http://localhost:" + port + "/mod/test?action=test&val="+maxInactive);
|
||||||
|
response = request.send();
|
||||||
|
assertEquals(HttpServletResponse.SC_OK,response.getStatus());
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
client.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
server.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class TestModServlet extends HttpServlet
|
public static class TestModServlet extends HttpServlet
|
||||||
|
|
Loading…
Reference in New Issue