在运行集成测试时,Build等待Jetty启动

时间:2015-09-28 17:04:46

标签: maven maven-jetty-plugin

我正在尝试进行一些集成/验收测试。

我想仅在传递环境变量时运行这些测试,因此我使用以下命令:

mvn clean install -Denv="acceptance"

但构建在

停止
2015-09-28 18:56:19.273:INFO:oejsh.ContextHandler:main: Started o.e.j.m.p.JettyWebAppContext@4bbc9862{/,file:///home/stephane/dev/java/projects/kahoot-rest/src/main/webapp/,AVAILABLE}{file:///home/stephane/dev/java/projects/kahoot-rest/src/main/webapp/}
2015-09-28 18:56:19.419:INFO:oejs.ServerConnector:main: Started ServerConnector@26b4acf4{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2015-09-28 18:56:19.423:INFO:oejs.Server:main: Started @171829ms
[INFO] Started Jetty Server

我正在使用Java 1.8。

我的pom.xml文件:

    <profile>
        <id>acceptance</id>
        <activation>
            <property>
                <name>env</name>
                <value>acceptance</value>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>failsafe-maven-plugin</artifactId>
                    <version>2.4.3-alpha-1</version>
                    <configuration>
                        <includes>
                            <include>**/acceptance/*.java</include>
                        </includes>
                        <excludes>
                            <exclude>**/*$*</exclude>
                        </excludes>
                    </configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>9.3.4.RC0</version>
                    <executions>
                        <execution>
                            <id>start-jetty</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>run</goal>
                            </goals>
                        </execution>
                        <execution>
                            <id>stop-jetty</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                            <configuration>
                                <stopKey>stop</stopKey>
                                <stopPort>8081</stopPort>
                            </configuration>
                        </execution>
                    </executions>
                    <configuration>
                        <scanIntervalSeconds>10</scanIntervalSeconds>
                        <connectors>
                            <connector implementation="org.eclipse.jetty.nio.SelectChannelConnector">
                                <port>8080</port>
                                <maxIdleTime>60000</maxIdleTime>
                            </connector>
                        </connectors>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

1 个答案:

答案 0 :(得分:2)

变化

<goal>run</goal>

<goal>start</goal>

并添加守护程序选项

<configuration>
    <daemon>true</daemon>
</configuration>