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>
|
||||
|
||||
<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>
|
||||
</properties>
|
||||
|
||||
|
@ -68,7 +68,7 @@
|
|||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -87,52 +87,20 @@
|
|||
<goal>run-distro</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<jettyBase>${basedir}/src/base</jettyBase>
|
||||
<jettyProperties>
|
||||
<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>
|
||||
<waitForChild>false</waitForChild>
|
||||
<modules>
|
||||
<module>jsp</module>
|
||||
<module>jstl</module>
|
||||
<module>testmod</module>
|
||||
</modules>
|
||||
</configuration>
|
||||
</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>
|
||||
</plugin>
|
||||
</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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -32,8 +36,8 @@ public class TestHelloServlet
|
|||
public void hello_servlet()
|
||||
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();
|
||||
try
|
||||
{
|
||||
|
@ -41,14 +45,10 @@ public class TestHelloServlet
|
|||
|
||||
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() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse ping fragment servlet:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
|
@ -56,4 +56,38 @@ public class TestHelloServlet
|
|||
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"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
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>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-distro-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-distro-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
@ -31,59 +31,54 @@
|
|||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
<properties>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.jvmArgs>@jetty.jvmArgs@</jetty.jvmArgs>
|
||||
<jetty.port.file>${project.build.directory}/jetty-run-forked-port.txt</jetty.port.file>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
@ -39,6 +39,13 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.toolchain</groupId>
|
||||
<artifactId>jetty-test-helper</artifactId>
|
||||
<version>4.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
|
@ -68,7 +75,7 @@
|
|||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -89,8 +96,11 @@
|
|||
<configuration>
|
||||
<nonBlocking>true</nonBlocking>
|
||||
<waitForChild>false</waitForChild>
|
||||
<jettyXml>${project.build.directory}/config/jetty.xml</jettyXml>
|
||||
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||
<jvmArgs>${jetty.jvmArgs}</jvmArgs>
|
||||
<jettyProperties>
|
||||
<jettyProperty>jetty.port.file=${jetty.port.file}</jettyProperty>
|
||||
</jettyProperties>
|
||||
</configuration>
|
||||
</execution>
|
||||
<!--
|
||||
|
@ -104,32 +114,6 @@
|
|||
-->
|
||||
</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>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
@ -24,10 +24,17 @@
|
|||
</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="${jetty.runPort}" /></Set>
|
||||
<Set name="port"><Property name="jetty.port" default="0" />0</Set>
|
||||
<Set name="idleTimeout">30000</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
||||
</Configure>
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
|
||||
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.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -31,8 +35,9 @@ public class TestHelloServlet
|
|||
public void hello_servlet()
|
||||
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();
|
||||
try
|
||||
{
|
||||
|
@ -40,14 +45,10 @@ public class TestHelloServlet
|
|||
|
||||
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() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse ping fragment servlet:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
|
@ -55,4 +56,38 @@ public class TestHelloServlet
|
|||
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"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
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>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
<properties>
|
||||
<jetty.port.file>${project.build.directory}/jetty-run-mojo.txt</jetty.port.file>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
|
@ -68,7 +71,7 @@
|
|||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -83,10 +86,14 @@
|
|||
<goal>start</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<systemProperties>
|
||||
<systemProperty>
|
||||
<name>jetty.port.file</name>
|
||||
<value>${jetty.port.file}</value>
|
||||
</systemProperty>
|
||||
</systemProperties>
|
||||
<nonBlocking>true</nonBlocking>
|
||||
<httpConnector>
|
||||
<port>@jetty.runPort@</port>
|
||||
</httpConnector>
|
||||
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
@ -24,10 +24,17 @@
|
|||
</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="${jetty.runPort}" /></Set>
|
||||
<Set name="port"><Property name="jetty.port" default="0" />0</Set>
|
||||
<Set name="idleTimeout">30000</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
||||
</Configure>
|
|
@ -19,6 +19,10 @@
|
|||
|
||||
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.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -32,8 +36,7 @@ public class TestHelloServlet
|
|||
public void hello_servlet()
|
||||
throws Exception
|
||||
{
|
||||
int port = Integer.getInteger( "jetty.runPort" );
|
||||
System.out.println( "port used:" + port );
|
||||
int port = getPort();
|
||||
HttpClient httpClient = new HttpClient();
|
||||
try
|
||||
{
|
||||
|
@ -41,14 +44,10 @@ public class TestHelloServlet
|
|||
|
||||
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() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse ping fragment servlet:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
|
@ -56,4 +55,37 @@ public class TestHelloServlet
|
|||
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"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
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>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
<properties>
|
||||
<jetty.port.file>${project.build.directory}/jetty-run-war-exploded-port.txt</jetty.port.file>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
|
@ -64,7 +68,7 @@
|
|||
<configuration>
|
||||
<skip>true</skip>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -74,7 +78,7 @@
|
|||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
</systemPropertyVariables>
|
||||
<includes>
|
||||
<include>**/*TestHelloServlet*</include>
|
||||
|
@ -107,9 +111,13 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<nonBlocking>true</nonBlocking>
|
||||
<httpConnector>
|
||||
<port>@jetty.runPort@</port>
|
||||
</httpConnector>
|
||||
<systemProperties>
|
||||
<systemProperty>
|
||||
<name>jetty.port.file</name>
|
||||
<value>${jetty.port.file}</value>
|
||||
</systemProperty>
|
||||
</systemProperties>
|
||||
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||
</configuration>
|
||||
</execution>
|
||||
</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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -32,8 +36,8 @@ public class TestHelloServlet
|
|||
public void hello_servlet()
|
||||
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();
|
||||
try
|
||||
{
|
||||
|
@ -41,14 +45,10 @@ public class TestHelloServlet
|
|||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
|
@ -56,4 +56,38 @@ public class TestHelloServlet
|
|||
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"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
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>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -14,6 +14,12 @@
|
|||
|
||||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
|
||||
<properties>
|
||||
<jetty.port.file>${project.build.directory}/jetty-run-war-port.txt</jetty.port.file>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
|
@ -64,7 +70,7 @@
|
|||
<configuration>
|
||||
<skip>true</skip>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -74,7 +80,7 @@
|
|||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
</systemPropertyVariables>
|
||||
<includes>
|
||||
<include>**/*TestHelloServlet*</include>
|
||||
|
@ -107,9 +113,13 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<nonBlocking>true</nonBlocking>
|
||||
<httpConnector>
|
||||
<port>@jetty.runPort@</port>
|
||||
</httpConnector>
|
||||
<systemProperties>
|
||||
<systemProperty>
|
||||
<name>jetty.port.file</name>
|
||||
<value>${jetty.port.file}</value>
|
||||
</systemProperty>
|
||||
</systemProperties>
|
||||
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||
</configuration>
|
||||
</execution>
|
||||
</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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -32,8 +36,8 @@ public class TestHelloServlet
|
|||
public void hello_servlet()
|
||||
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();
|
||||
try
|
||||
{
|
||||
|
@ -41,14 +45,10 @@ public class TestHelloServlet
|
|||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
|
@ -56,4 +56,38 @@ public class TestHelloServlet
|
|||
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"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
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>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-run-war-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
|
||||
<name>Jetty :: Simple :: Webapp</name>
|
||||
|
||||
<properties>
|
||||
<jetty.port.file>${project.build.directory}/jetty-start-port.txt</jetty.port.file>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
|
@ -63,7 +67,7 @@
|
|||
<version>2.20</version>
|
||||
<configuration>
|
||||
<systemPropertyVariables>
|
||||
<jetty.runPort>@jetty.runPort@</jetty.runPort>
|
||||
<jetty.port.file>${jetty.port.file}</jetty.port.file>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
@ -78,9 +82,13 @@
|
|||
<goal>start</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<httpConnector>
|
||||
<port>@jetty.runPort@</port>
|
||||
</httpConnector>
|
||||
<systemProperties>
|
||||
<systemProperty>
|
||||
<name>jetty.port.file</name>
|
||||
<value>${jetty.port.file}</value>
|
||||
</systemProperty>
|
||||
</systemProperties>
|
||||
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
|
||||
</configuration>
|
||||
</execution>
|
||||
</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;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.LineNumberReader;
|
||||
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -32,8 +37,8 @@ public class TestHelloServlet
|
|||
public void hello_servlet()
|
||||
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();
|
||||
try
|
||||
{
|
||||
|
@ -41,14 +46,10 @@ public class TestHelloServlet
|
|||
|
||||
String response = httpClient.GET( "http://localhost:" + port + "/hello?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "hello beer", response.trim() );
|
||||
|
||||
response = httpClient.GET( "http://localhost:" + port + "/ping?name=beer" ).getContentAsString();
|
||||
|
||||
System.out.println( "httpResponse:" + response );
|
||||
|
||||
Assert.assertEquals( "pong beer", response.trim() );
|
||||
}
|
||||
finally
|
||||
|
@ -56,4 +57,37 @@ public class TestHelloServlet
|
|||
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"?>
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
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>
|
||||
|
||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-project</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jetty :: Simple</name>
|
||||
<name>Jetty :: Simple</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven-war-plugin-version>3.0.0</maven-war-plugin-version>
|
||||
<jetty.version>@project.version@</jetty.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
<modules>
|
||||
<module>jetty-simple-base</module>
|
||||
<module>jetty-simple-webapp</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.its.jetty-start-mojo-it</groupId>
|
||||
<artifactId>jetty-simple-base</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.21</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<target>1.8</target>
|
||||
<source>1.8</source>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</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())
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@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
|
||||
|
|
Loading…
Reference in New Issue