Permalink
Browse files

Simplify integration test incantation

  • Loading branch information...
1 parent 114474a commit 00cf04c55b8672f06b59940ee73d881e907f1866 @dsyer dsyer committed Nov 22, 2011
Showing with 125 additions and 145 deletions.
  1. +17 −21 README.md
  2. +30 −25 api/pom.xml
  3. +48 −49 app/pom.xml
  4. +4 −6 app/src/main/webapp/WEB-INF/spring-servlet.xml
  5. +1 −1 pom.xml
  6. +25 −43 uaa/pom.xml
View
@@ -9,22 +9,17 @@ If this works you are in business:
$ cd uaa
$ mvn install
-Each module has a `mvn tomcat:run` target to run individually (but not
-simulataneously), or you could import them as projects into STS (use
-2.8.0 or better if you can). The apps all work together the apps
-running on the same port (8080) as `/uaa`, `/app` and `/api`.
+Each module has a `mvn tomcat:run` target to run individually, or you
+could import them as projects into STS (use 2.8.0 or better if you
+can). The apps all work together the apps running on the same port
+(8080) as `/uaa`, `/app` and `/api`.
### Demo of command line usage
-To run multiple apps we need a Tomcat manager app:
-
- $ cd uaa
- $ mvn tomcat:run -N
-
First run the uaa server as described above:
$ cd uaa
- $ mvn tomcat:deploy
+ $ mvn tomcat:run
Then start another terminal and from the project base directory, run:
@@ -36,10 +31,11 @@ This authenticates and obtains an access token from the server using the OAuth2
grant, similar to the approach intended for a client like VMC. The token is
stored in the file `.access_token`.
-Now run the `api` server:
+Now kill the `uaa` server and run the `api` server (which starts the
+`uaa` server as well):
$ cd api
- $ mvn tomcat:deploy
+ $ mvn tomcat:run
And then (from the base directory) execute:
@@ -52,12 +48,12 @@ which should return a JSON array of (pretend) running applications.
With all apps deployed into a running server on port 8080 the tests
will include integration tests (a check is done before each test that
the app is running). You can deploy them in your IDE or using the
-command line with `mvn tomcat:deploy`.
+command line with `mvn tomcat:run`.
-For individual modules you can also run integration tests from the
-command line in one go with
+For individual modules, or for the whole project, you can also run
+integration tests from the command line in one go with
- $ mvn tomcat:run -Dmaven.tomcat.fork=true test
+ $ mvn integration-test
(This might require an initial `mvn install` from the parent directory
to get the wars in your local repo first.)
@@ -115,20 +111,20 @@ Security OAuth that can do the heavy lifting.
An example resource server. It hosts a service which returns
a list of mock applications under `/apps`.
-Run it using `mvn tomcat:deploy` from the `api` directory. This will
-deploy the app to a Tomcat manager on port 8080.
+Run it using `mvn tomcat:run` from the `api` directory (once all other
+tomcat processes have been shutdown). This will deploy the app to a
+Tomcat manager on port 8080.
## The App Application
This is a user interface (primarily aimed at browser) app that uses
OpenId Connect for authentication (i.e. SSO) and OAuth2 for access
grants. It authenticates with the Auth service, and then accesses
-resources in the API service. Run it with `mvn tomcat:deploy` from
-the `app` directory.
+resources in the API service. Run it with `mvn tomcat:run` from the
+`app` directory (once all other tomcat processes have been shutdown).
### Use Cases
-
1. See all apps
GET /app/apps
View
@@ -12,7 +12,7 @@
<artifactId>cloudfoundry-identity-api</artifactId>
<packaging>war</packaging>
- <name>OAuth2 Aware Resource Service</name>
+ <name>Sample resource server for Cloudfoundry Identity Services</name>
<properties>
<m2eclipse.wtp.contextRoot>/api</m2eclipse.wtp.contextRoot>
@@ -31,15 +31,11 @@
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
- <goal>deploy</goal>
- </goals>
- </execution>
- <execution>
- <id>stop-tomcat</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>undeploy</goal>
+ <goal>run</goal>
</goals>
+ <configuration>
+ <fork>true</fork>
+ </configuration>
</execution>
</executions>
</plugin>
@@ -64,28 +60,28 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <warSourceDirectory>src/main/webapp</warSourceDirectory>
- <webResources>
- <resource>
- <directory>src/main/webapp</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
- </webResources>
- </configuration>
- </plugin>
- <plugin>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>start-tomcat</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <fork>true</fork>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -100,6 +96,15 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
<configuration>
<skip>${skipTests}</skip>
<includes>
View
@@ -11,7 +11,7 @@
<artifactId>cloudfoundry-identity-app</artifactId>
<packaging>war</packaging>
- <name>User app for Bento</name>
+ <name>Sample user webapp for Cloudfoundry Identity Services</name>
<properties>
<m2eclipse.wtp.contextRoot>/app</m2eclipse.wtp.contextRoot>
@@ -30,15 +30,11 @@
<id>start-tomcat</id>
<phase>pre-integration-test</phase>
<goals>
- <goal>deploy</goal>
- </goals>
- </execution>
- <execution>
- <id>stop-tomcat</id>
- <phase>post-integration-test</phase>
- <goals>
- <goal>undeploy</goal>
+ <goal>run</goal>
</goals>
+ <configuration>
+ <fork>true</fork>
+ </configuration>
</execution>
</executions>
</plugin>
@@ -63,41 +59,28 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <warSourceDirectory>src/main/webapp</warSourceDirectory>
- <webResources>
- <resource>
- <directory>src/main/webapp</directory>
- <filtering>true</filtering>
- <includes>
- <include>**/*.xml</include>
- </includes>
- </resource>
- </webResources>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <skip>${skipTests}</skip>
- <includes>
- <include>**/*Tests.java</include>
- </includes>
- <excludes>
- <exclude>**/Abstract*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- <plugin>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>tomcat-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>start-tomcat</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <configuration>
+ <fork>true</fork>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
<pluginManagement>
<plugins>
@@ -108,6 +91,28 @@
<path>/app</path>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <skip>${skipTests}</skip>
+ <includes>
+ <include>**/*Tests.java</include>
+ </includes>
+ <excludes>
+ <exclude>**/Abstract*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
</plugins>
</pluginManagement>
</build>
@@ -131,18 +136,12 @@
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
<scope>compile</scope>
- <exclusions>
- <exclusion>
- <artifactId>commons-logging</artifactId>
- <groupId>commons-logging</groupId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>1.5.8</version>
- <scope>runtime</scope>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
@@ -186,7 +185,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.7</version>
+ <version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -14,10 +14,10 @@
<sec:http pattern="/resources/**" security="none" />
<sec:http pattern="/favicon.ico" security="none" />
- <http xmlns="http://www.springframework.org/schema/security" entry-point-ref="loginEntryPoint" >
+ <http xmlns="http://www.springframework.org/schema/security" entry-point-ref="loginEntryPoint">
<intercept-url pattern="/**" access="ROLE_USER" />
<logout logout-success-url="/loggedout.jsp" />
- <anonymous enabled="false"/>
+ <anonymous enabled="false" />
<custom-filter ref="oauth2ClientFilter" after="EXCEPTION_TRANSLATION_FILTER" />
<custom-filter ref="openidClientFilter" before="FILTER_SECURITY_INTERCEPTOR" />
</http>
@@ -39,11 +39,9 @@
<constructor-arg ref="api" />
</bean>
</property>
- <property name="userInfoUrl" value="${userInfoUri}"/>
+ <property name="userInfoUrl" value="${userInfoUri}" />
</bean>
- <bean id="oauth2TokenServices" class="org.springframework.security.oauth2.client.token.service.InMemoryOAuth2ClientTokenServices" />
-
<mvc:resources location="/resources/" mapping="/resources/**" />
<mvc:annotation-driven />
@@ -83,7 +81,7 @@
<property name="treeUrlPattern" value="${treeUrlPattern}" />
</bean>
- <bean id="homeController" class="org.cloudfoundry.identity.app.web.HomeController"/>
+ <bean id="homeController" class="org.cloudfoundry.identity.app.web.HomeController" />
<!--define an oauth 2 resource for api access -->
<oauth:resource id="api" type="authorization_code" client-id="app" client-secret="appclientsecret"
View
@@ -39,7 +39,7 @@
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
- <exclude>cargo-installs,target/tomcat5x,target/war</exclude>
+ <exclude>target/tomcat,target/war</exclude>
</configuration>
</plugin>
<plugin>
Oops, something went wrong.

0 comments on commit 00cf04c

Please sign in to comment.