Issue #1743 WIP tests

Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
Jan Bartel 2019-09-18 16:34:56 +10:00
parent de3e104d27
commit cf61839c46
45 changed files with 106 additions and 95 deletions

View File

@ -18,6 +18,7 @@
<maven.compiler.target>8</maven.compiler.target>
<!--maven.compiler.release>11</maven.compiler.release-->
<jetty.port.file>${project.build.directory}/jetty-run-mojo-annotation.txt</jetty.port.file>
<jetty.runType>EMBED</jetty.runType>
</properties>
<dependencies>
@ -86,7 +87,9 @@
<systemProperties>
<jetty.port.file>${jetty.port.file}</jetty.port.file>
</systemProperties>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
<jettyXmls>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
</jettyXmls>
</configuration>
</execution>
</executions>

View File

@ -17,5 +17,5 @@
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'all good guys get a good Beer')

View File

@ -17,5 +17,5 @@
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'ClassNotFoundException')
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'ClassNotFoundException')

View File

@ -9,6 +9,10 @@
<artifactId>web</artifactId>
<packaging>war</packaging>
<properties>
<jetty.runType>EMBED</jetty.runType>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
@ -41,13 +45,14 @@
<executions>
<execution>
<id>start-jetty</id>
<phase>test-compile</phase>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
<goal>newstart</goal>
</goals>
<configuration>
<nonBlocking>true</nonBlocking>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
<jettyXmls>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
</jettyXmls>
</configuration>
</execution>
</executions>

View File

@ -33,12 +33,12 @@ public class ClassLoadingTestingServletContextListener
try
{
Api api = new Api();
//System.out.println("Class " + api.getClass().getName() + " is available and loaded by classloader " + api.getClass().getClassLoader().toString() + ". Expected ClassNotFoundException.");
}
catch (java.lang.Exception exception)
{
exception.printStackTrace();
}
//System.out.println("Class " + api.getClass().getName() + " is available and loaded by classloader " + api.getClass().getClassLoader().toString() + ". Expected ClassNotFoundException.");
}
@Override

View File

@ -1,2 +1,2 @@
invoker.goals = test -fae
invoker.goals = verify -fae
invoker.debug = true

View File

@ -87,7 +87,7 @@
<executions>
<execution>
<id>start-jetty</id>
<phase>test-compile</phase>
<phase>process-test-classes</phase>
<goals>
<goal>newstart</goal>
</goals>

View File

@ -12,7 +12,7 @@ s.close()
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Forking command line' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.TestGetContent')
assert buildLog.text.contains( 'pingServlet ok')
assert buildLog.text.contains( 'helloServlet')

View File

@ -1 +0,0 @@
invoker.goals = test -fae

View File

@ -17,7 +17,7 @@
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.TestGetContent')
assert buildLog.text.contains( 'pingServlet ok')
assert buildLog.text.contains( 'helloServlet')
assert buildLog.text.contains( 'helloServlet')

View File

@ -17,6 +17,6 @@
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.TestGetContent')
assert buildLog.text.contains( 'contentCheck')

View File

@ -17,7 +17,7 @@
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( '(1a) >> javax.servlet.ServletContextListener loaded from jar:' )

View File

@ -22,6 +22,7 @@
<properties>
<jetty.port.file>${project.build.directory}/jetty-run-mojo.txt</jetty.port.file>
<jetty.runType>EMBED</jetty.runType>
</properties>
<build>
@ -34,17 +35,15 @@
<id>start-jetty</id>
<phase>test-compile</phase>
<goals>
<goal>start</goal>
<goal>newstart</goal>
</goals>
<configuration>
<systemProperties>
<systemProperty>
<name>jetty.port.file</name>
<value>${jetty.port.file}</value>
</systemProperty>
<jetty.port.file>${jetty.port.file}</jetty.port.file>
</systemProperties>
<nonBlocking>true</nonBlocking>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
<jettyXmls>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
</jettyXmls>
</configuration>
</execution>
</executions>

View File

@ -1,2 +0,0 @@
invoker.goals = verify -V
#test-compile failsafe:integration-test

View File

@ -17,7 +17,7 @@
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.TestGetContent')
assert buildLog.text.contains( 'pingServlet ok')
assert buildLog.text.contains( 'helloServlet')
assert buildLog.text.contains( 'helloServlet')

View File

@ -0,0 +1 @@
invoker.goals = verify -fae

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-forked-mojo-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-forked-mojo-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
@ -15,14 +15,14 @@
<properties>
<jetty.jvmArgs>@jetty.jvmArgs@</jetty.jvmArgs>
<jetty.port.file>${project.build.directory}/jetty-run-forked-port.txt</jetty.port.file>
<jetty.port.file>${project.build.directory}/jetty-start-forked-port.txt</jetty.port.file>
<jetty.runType>FORK</jetty.runType>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-forked-mojo-it</groupId>
<artifactId>jetty-simple-base</artifactId>
</dependency>
@ -87,7 +87,7 @@
<executions>
<execution>
<id>start-jetty</id>
<phase>test-compile</phase>
<phase>process-test-classes</phase>
<goals>
<goal>newstart</goal>
</goals>
@ -97,7 +97,7 @@
</jettyXmls>
<jvmArgs>${jetty.jvmArgs}</jvmArgs>
<jettyProperties>
<jettyProperty>jetty.port.file=${jetty.port.file}</jettyProperty>
<jetty.port.file>${jetty.port.file}</jetty.port.file>
</jettyProperties>
</configuration>
</execution>

View File

@ -8,7 +8,7 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-forked-mojo-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
@ -31,7 +31,7 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.its.jetty-run-forked-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-forked-mojo-it</groupId>
<artifactId>jetty-simple-base</artifactId>
<version>${project.version}</version>
</dependency>

View File

@ -17,7 +17,7 @@
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.TestGetContent')
assert buildLog.text.contains( 'pingServlet ok')
assert buildLog.text.contains( 'helloServlet')
assert buildLog.text.contains( 'helloServlet')

View File

@ -0,0 +1,2 @@
invoker.goals = verify -V -X
#test-compile failsafe:integration-test

View File

@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-war-forked-mojo-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

View File

@ -3,9 +3,10 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-war-forked-mojo-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>jetty-simple-webapp</artifactId>
@ -14,12 +15,13 @@
<name>Jetty :: Simple :: Webapp</name>
<properties>
<jetty.port.file>${project.build.directory}/jetty-run-war-exploded-port.txt</jetty.port.file>
<jetty.port.file>${project.build.directory}/jetty-start-war-forked-port.txt</jetty.port.file>
<jetty.runType>FORK</jetty.runType>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-war-forked-mojo-it</groupId>
<artifactId>jetty-simple-base</artifactId>
</dependency>
<dependency>
@ -62,6 +64,30 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>newstart-war</goal>
</goals>
<configuration>
<webApp>
<war>${project.build.directory}/${project.artifactId}-${project.version}</war>
</webApp>
<systemProperties>
<jetty.port.file>${jetty.port.file}</jetty.port.file>
</systemProperties>
<jettyXmls>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
</jettyXmls>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
@ -94,29 +120,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<executions>
<execution>
<id>start-jetty</id>
<phase>test-compile</phase>
<goals>
<goal>run-exploded</goal>
</goals>
<configuration>
<nonBlocking>true</nonBlocking>
<systemProperties>
<systemProperty>
<name>jetty.port.file</name>
<value>${jetty.port.file}</value>
</systemProperty>
</systemProperties>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -6,9 +6,10 @@
<groupId>org.eclipse.jetty.its</groupId>
<artifactId>it-parent-pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../it-parent-pom/pom.xml</relativePath>
</parent>
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-war-forked-mojo-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
@ -30,7 +31,7 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.its.jetty-run-war-exploded-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-war-forked-mojo-it</groupId>
<artifactId>jetty-simple-base</artifactId>
<version>${project.version}</version>
</dependency>

View File

@ -16,8 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.TestGetContent')
assert buildLog.text.contains( 'pingServlet ok')
assert buildLog.text.contains( 'helloServlet')
File outputLog = new File( basedir, 'jetty-simple-webapp/target/jetty-start-war.out' )
assert outputLog.text.contains( 'Started Server' )
assert outputLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.TestGetContent')
assert outputLog.text.contains( 'pingServlet ok')
assert outputLog.text.contains( 'helloServlet')

View File

@ -8,15 +8,15 @@
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>org.eclipse.jetty.its.jetty-deploy-war-mojo-it</groupId>
<groupId>org.eclipse.jetty.its.jetty-start-war-mojo-it</groupId>
<artifactId>jetty-simple-project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Jetty :: Simple deploy war mojo test</name>
<name>Jetty :: Simple start war mojo test</name>
<properties>
<jetty.port.file>${project.build.directory}/jetty-deploy-war-port.txt</jetty.port.file>
<jetty.port.file>${project.build.directory}/jetty-start-war-port.txt</jetty.port.file>
</properties>
<dependencies>
@ -75,7 +75,7 @@
<id>start-jetty</id>
<phase>test-compile</phase>
<goals>
<goal>newdeploy</goal>
<goal>newstart-war</goal>
</goals>
<configuration>
<supportedPackagings>

View File

@ -17,6 +17,6 @@
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.TestGetContent')
assert buildLog.text.contains( 'contentCheck')
assert buildLog.text.contains( 'contentCheck')

View File

@ -13,6 +13,7 @@
<properties>
<jetty.port.file>${project.build.directory}/jetty-run-mojo.txt</jetty.port.file>
<jetty.runType>EMBED</jetty.runType>
</properties>
<dependencies>
@ -89,18 +90,16 @@
<id>run</id>
<phase>test-compile</phase>
<goals>
<goal>run</goal>
<goal>newrun</goal>
</goals>
<configuration>
<systemProperties>
<systemProperty>
<name>jetty.port.file</name>
<value>${jetty.port.file}</value>
</systemProperty>
<jetty.port.file>${jetty.port.file}</jetty.port.file>
</systemProperties>
<nonBlocking>true</nonBlocking>
<contextXml>${basedir}/src/main/jettyconf/context.xml</contextXml>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
<jettyXmls>
<jettyXml>${basedir}/src/config/jetty.xml</jettyXml>
</jettyXmls>
</configuration>
</execution>
</executions>

View File

@ -17,6 +17,6 @@
* under the License.
*/
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Started Jetty Server' )
assert buildLog.text.contains( 'Started Server' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.TestGetContent')
assert buildLog.text.contains( 'contentCheck')
assert buildLog.text.contains( 'contentCheck')

View File

@ -1140,6 +1140,7 @@ public abstract class AbstractWebAppMojo extends AbstractMojo
//the former could be the location of a packed war, while the latter is the location
//after any unpacking. With this mojo, you are running an unpacked, unassembled webapp,
//so the two locations should be equal.
System.err.println("SRC WEBAPP: "+webAppSourceDirectory);
Resource webAppSourceDirectoryResource = Resource.newResource(webAppSourceDirectory.getCanonicalPath());
if (webApp.getWar() == null)
webApp.setWar(webAppSourceDirectoryResource.toString());

View File

@ -51,7 +51,7 @@ import org.eclipse.jetty.util.StringUtil;
@Execute(phase = LifecyclePhase.PACKAGE)
public class NewJettyRunWarMojo extends AbstractWebAppMojo
{
//Start of parameters only valid for runType=inprocess
//Start of parameters only valid for runType=EMBED
/**
* The interval in seconds to pause before checking if changes
* have occurred and re-deploying as necessary. A value

View File

@ -44,8 +44,8 @@ import org.eclipse.jetty.util.StringUtil;
* HTTP client components via binding to the test-integration build phase.
* </p>
*/
@Mojo(name = "newdeploy", requiresDependencyResolution = ResolutionScope.RUNTIME)
public class NewJettyDeployMojo extends AbstractWebAppMojo
@Mojo(name = "newstart-war", requiresDependencyResolution = ResolutionScope.RUNTIME)
public class NewJettyStartWarMojo extends AbstractWebAppMojo
{
protected JettyEmbedder embedder;
protected JettyForker forker;
@ -55,10 +55,10 @@ public class NewJettyDeployMojo extends AbstractWebAppMojo
@Override
public void configureWebApp() throws Exception
{
if (StringUtil.isBlank(webApp.getWar()))
throw new MojoExecutionException("No war specified");
super.configureWebApp();
if (StringUtil.isBlank(webApp.getWar()))
configureUnassembledWebApp();
getLog().info("War = "+webApp.getWar());
}
@ -92,7 +92,7 @@ public class NewJettyDeployMojo extends AbstractWebAppMojo
{
forker = newJettyForker();
forker.setWaitForChild(false); //we never wait for child
forker.setJettyOutputFile(getJettyOutputFile("jetty-deploy.out"));
forker.setJettyOutputFile(getJettyOutputFile("jetty-start-war.out"));
forker.start(); //forks jetty instance
}
@ -112,7 +112,7 @@ public class NewJettyDeployMojo extends AbstractWebAppMojo
{
distroForker = newJettyDistroForker();
distroForker.setWaitForChild(false); //never wait for child
distroForker.setJettyOutputFile(getJettyOutputFile("jetty-deploy.out"));
distroForker.setJettyOutputFile(getJettyOutputFile("jetty-start-war.out"));
distroForker.start(); //forks a jetty distro
}
catch (Exception e)