Issue #1743 Ensure tests stop jetty

Signed-off-by: Jan Bartel <janb@webtide.com>
This commit is contained in:
Jan Bartel 2019-10-01 11:29:00 +10:00
parent 5d0032062d
commit 2ef7160418
5 changed files with 35 additions and 6 deletions

View File

@ -14,7 +14,7 @@
<name>Jetty :: Simple :: Webapp</name>
<properties>
<jetty.port.file>${project.build.directory}/jetty-start-distro-port.txt</jetty.port.file>
<jetty.port.file>${project.build.directory}/jetty-start-war-distro-port.txt</jetty.port.file>
<jetty.jvmArgs>@jetty.jvmArgs@</jetty.jvmArgs>
<jetty.deployMode>DISTRO</jetty.deployMode>
</properties>
@ -80,9 +80,6 @@
<dependenciesToScan>
<dependency>org.eclipse.jetty:jetty-maven-plugin</dependency>
</dependenciesToScan>
<includes>
<include>**/*TestGetContent*</include>
</includes>
</configuration>
<executions>
<execution>
@ -110,6 +107,8 @@
<goal>start-war</goal>
</goals>
<configuration>
<stopPort>@jetty.stopPort@</stopPort>
<stopKey>@jetty.stopKey@</stopKey>
<webApp>
<!-- starts the assembled webapp by default -->
</webApp>

View File

@ -16,6 +16,18 @@
* specific language governing permissions and limitations
* under the License.
*/
System.out.println( "running postbuild.groovy port " + jettyStopPort + ", key:" + jettyStopKey )
int port = Integer.parseInt( jettyStopPort )
Socket s=new Socket(InetAddress.getByName("127.0.0.1"),port )
OutputStream out=s.getOutputStream()
out.write(( jettyStopKey +"\r\nforcestop\r\n").getBytes())
out.flush()
s.close()
File buildLog = new File( basedir, 'build.log' )
assert buildLog.text.contains( 'Distro process starting' )
assert buildLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.IntegrationTestGetContent')

View File

@ -75,6 +75,8 @@
<goal>start-war</goal>
</goals>
<configuration>
<stopPort>@jetty.stopPort@</stopPort>
<stopKey>@jetty.stopKey@</stopKey>
<webApp>
<war>${project.build.directory}/${project.artifactId}-${project.version}</war>
</webApp>

View File

@ -16,6 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
System.out.println( "running postbuild.groovy port " + jettyStopPort + ", key:" + jettyStopKey )
int port = Integer.parseInt( jettyStopPort )
Socket s=new Socket(InetAddress.getByName("127.0.0.1"),port )
OutputStream out=s.getOutputStream()
out.write(( jettyStopKey +"\r\nforcestop\r\n").getBytes())
out.flush()
s.close()
File outputLog = new File( basedir, 'build.log' )
assert outputLog.text.contains( 'Forked process starting' )
assert outputLog.text.contains( 'Running org.eclipse.jetty.maven.plugin.it.IntegrationTestGetContent')

View File

@ -44,14 +44,16 @@ public class TestJettyEmbedder
public void testJettyEmbedderFromDefaults() throws Exception
{
JettyWebAppContext webApp = new JettyWebAppContext();
MavenServerConnector connector = new MavenServerConnector();
connector.setPort(0);
JettyEmbedder jetty = new JettyEmbedder();
jetty.setHttpConnector(connector);
jetty.setExitVm(false);
jetty.setServer(null);
jetty.setContextHandlers(null);
jetty.setRequestLog(null);
jetty.setJettyXmlFiles(null);
jetty.setHttpConnector(null);
jetty.setJettyProperties(null);
jetty.setLoginServices(null);
jetty.setContextXml(MavenTestingUtils.getTestResourceFile("embedder-context.xml").getAbsolutePath());
@ -86,13 +88,16 @@ public class TestJettyEmbedder
otherHandler.setContextPath("/other");
otherHandler.setBaseResource(Resource.newResource(MavenTestingUtils.getTestResourceDir("root")));
MavenServerConnector connector = new MavenServerConnector();
connector.setPort(0);
JettyEmbedder jetty = new JettyEmbedder();
jetty.setHttpConnector(connector);
jetty.setExitVm(false);
jetty.setServer(server);
jetty.setContextHandlers(Arrays.asList(otherHandler));
jetty.setRequestLog(null);
jetty.setJettyXmlFiles(Arrays.asList(MavenTestingUtils.getTestResourceFile("embedder-jetty.xml")));
jetty.setHttpConnector(null);
jetty.setJettyProperties(jettyProperties);
jetty.setLoginServices(null);
jetty.setContextXml(MavenTestingUtils.getTestResourceFile("embedder-context.xml").getAbsolutePath());