Ingo
Ingo

Reputation: 1572

How to launch the GAE/J devserver before running integration tests from Maven?

I want to switch from KindleIT's to Google's App Engine Maven plugin. When using the KindleIT plugin, I launched the GAE dev server right in the pre-integration-test phase. I shutdown the dev server once the integration tests are complete in post-integration-test. We are using the surefire plugin to run our unit and integration tests.

<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>

I am doing that because I want to run integration tests agains the locally running GAE app. How can I do the same with Google's App Engine plugin?

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

I want to use something like the

mvn appengine:devserver

goal. But this just launches the devserver in the foreground. I want Maven to launch the dev server in the background before the tests.

Upvotes: 2

Views: 668

Answers (2)

danipenaperez
danipenaperez

Reputation: 693

Use maven-jetty-plugin. This plugin starts jettty instance and run your war/gae project.

you can run this plugin in pre-integration-test phase, then run integration test, and in the post-integration-test-phase the server will shutdown.

I´m working with gae application, and works fine with this plugin.

This is my configuration, i hope help you:

        <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>

In addition, maybe you´ll found this exection on execution: Exception in thread "Shutdown" java.lang.NoClassDefFoundError: org/apache/jasper /runtime/JspApplicationContextImpl

This will be solved adding this dependency to your pom.xml

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

Upvotes: 1

MattStep
MattStep

Reputation: 431

This isn't supported yet on the official plugin, but we're working on it and I'm hoping to get it into a snapshot build soon. I'll keep you posted, but this issue is where I'm tracking my work on that: https://code.google.com/p/appengine-maven-plugin/issues/detail?id=5

Upvotes: 2

Related Questions