【问题标题】:How to launch the GAE/J devserver before running integration tests from Maven?如何在从 Maven 运行集成测试之前启动 GAE/J 开发服务器?
【发布时间】:2013-04-08 03:13:16
【问题描述】:

我想从KindleIT's 切换到Google's App Engine Maven 插件。使用 KindleIT 插件时,我在预集成测试阶段启动了 GAE 开发服务器。一旦集成测试在集成后测试中完成,我就会关闭开发服务器。我们使用surefire plugin 来运行我们的单元和集成测试。

<plugin>
  <groupId>net.kindleit</groupId>
  <artifactId>maven-gae-plugin</artifactId>
  <version>0.9.5</version>
  <executions>
    <execution>
      <id>gae-start</id>
      <phase>pre-integration-test</phase>
      <goals>
        <goal>start</goal>
      </goals>
    </execution>
    <execution>
      <id>gae-stop</id>
      <phase>post-integration-test</phase>
      <goals>
        <goal>stop</goal>
      </goals>
    </execution>
  </executions> 
</plugin>

我这样做是因为我想对本地运行的 GAE 应用程序运行集成测试。 如何使用 Google 的 App Engine 插件实现相同的功能?

<plugin>
  <groupId>com.google.appengine</groupId>
  <artifactId>appengine-maven-plugin</artifactId>
  <version>${gae.version}</version>
</plugin>

我想使用类似的东西

mvn appengine:devserver

目标。但这只是在前台启动开发服务器。我希望 Maven 在测试之前在后台启动开发服务器。

【问题讨论】:

    标签: java google-app-engine maven integration-testing


    【解决方案1】:

    官方插件尚不支持此功能,但我们正在努力,我希望尽快将其纳入快照版本。我会及时通知你,但这个问题是我跟踪我的工作的地方: https://code.google.com/p/appengine-maven-plugin/issues/detail?id=5

    【讨论】:

    • 感谢分享链接!我出演了the issue。你能提供一个ETA吗?你认为距离这个目标还有几天、几周或几个月的时间吗?谢谢!
    • 只要 GAE 凭证不能存储在任何地方,插件就不能在 CI 服务器上使用。有一个关于storing email and password in ~/.m2/Settings.xml的功能请求。
    【解决方案2】:

    使用 maven-jetty-plugin。这个插件启动 jettty 实例并运行你的 war/gae 项目。

    您可以在 pre-integration-test 阶段运行此插件,然后运行集成测试,在 post-integration-test-阶段服务器将关闭。

    我正在使用 gae 应用程序,并且可以很好地使用此插件。

    这是我的配置,希望对你有所帮助:

            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.15</version>
                <configuration>
                    <contextPath>/</contextPath>
                    <scanIntervalSeconds>3</scanIntervalSeconds>
                    <stopKey>foo</stopKey>
                    <stopPort>9999</stopPort> 
                    <connectors>
                        <connector implementation ="org.mortbay.jetty.nio.SelectChannelConnector" >
                            <port>${deploy.server.port}</port>
                            <maxIdleTime>60000</maxIdleTime>
                        </connector>
                    </connectors>
                </configuration>
                <executions>
                        <execution>
                                <id>start-jetty</id>
                                <phase>pre-integration-test</phase>
                                <goals>
                                        <goal>run</goal>
                                </goals>
                                <configuration>
                                        <scanIntervalSeconds>0</scanIntervalSeconds>
                                        <daemon>true</daemon>
                                </configuration>
                        </execution>
                        <execution>
                                <id>stop-jetty</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                        <goal>stop</goal>
                                </goals>
                        </execution>
                </executions>
            </plugin>
         </plugins>
    

    另外,也许你会在执行时发现这个执行: 线程“关闭”java.lang.NoClassDefFoundError 中的异常:org/apache/jasper /runtime/JspApplicationContextImpl

    将这个依赖添加到你的 pom.xml 中会解决这个问题

            <dependency>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>jsp-2.1</artifactId>
                <version>6.0.0</version>
              </dependency>
    

    【讨论】:

      猜你喜欢
      • 2018-01-14
      • 2014-10-10
      • 1970-01-01
      • 1970-01-01
      • 2016-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多