Skip to content

Commit

Permalink
Simplify integration test configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
dsyer committed Nov 22, 2011
1 parent ecdc6ee commit 049f7f9
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 72 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ Security programming models and configuration idioms.

# Getting Started

Clone from GIT and then use Maven (2.2.*):
[Dowload](https://github.com/SpringSource/spring-security-oauth/tags)
or clone from
[GIT](https://github.com/SpringSource/spring-security-oauth) and then
use Maven (2.2.*):

$ git clone ...
$ mvn install -P bootstrap
Expand All @@ -23,6 +26,15 @@ Software License Version 2.0 (see license.txt).

Samples and integration tests are in [a subdirectory](./samples).
There is a separate README there for orientation and information.
Once you have installed the artifacts locally (as per the getting
started instructions above) you should be able to

$ cd samples/oauth2/tonr
$ mvn tomcat:run

and visit the app in your browser at [http://localhost:8080/tonr/][]
to check that it works. (This is for the OAuth 2.0 sample, for the
OAuth 1.0a sample just remove the "2" from the directory path.)

## Changelog

Expand Down
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,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>
Expand Down Expand Up @@ -151,11 +151,6 @@
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.25</version>
</plugin>
<plugin>
<!-- configures the springsource bundlor plugin, which generates OSGI-compatible MANIFEST.MF files during the 'compile'
phase of the maven build. this plugin is declared within the pluginManagement section because not every module that inherits
Expand Down
12 changes: 0 additions & 12 deletions samples/oauth/sparklr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<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) -->
Expand Down
73 changes: 53 additions & 20 deletions samples/oauth2/sparklr/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand All @@ -19,27 +20,21 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<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 unit test run, tests to be executed during integration-test -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.9</version>
<version>2.7.1</version>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--skip deploy (this is just a test module) -->
Expand All @@ -49,6 +44,23 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<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>
Expand All @@ -60,6 +72,27 @@
<addContextWarDependencies>true</addContextWarDependencies>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id></id>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<inherited>false</inherited>
<configuration>
<file>target/${pom.artifactId}-${pom.version}.war</file>
<groupId>${pom.groupId}.test</groupId>
<artifactId>sparklr</artifactId>
<version>${pom.version}</version>
<packaging>war</packaging>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Expand Down
14 changes: 0 additions & 14 deletions samples/oauth2/sparklr/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,6 @@
</init-param>
</filter>

<filter>
<filter-name>oauth2EndpointUrlFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.servlet.FrameworkServlet.CONTEXT.spring</param-value>
</init-param>
</filter>

<filter-mapping>
<filter-name>oauth2EndpointUrlFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
Expand Down
45 changes: 36 additions & 9 deletions samples/oauth2/tonr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7.1</version>
<executions>
<execution>
<id>surefire-it</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
Expand All @@ -26,6 +43,23 @@
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<version>1.1</version>
<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>
Expand Down Expand Up @@ -57,8 +91,8 @@
<dependencies>

<dependency>
<groupId>${pom.groupId}</groupId>
<artifactId>sparklr2</artifactId>
<groupId>${pom.groupId}.test</groupId>
<artifactId>sparklr</artifactId>
<version>${pom.version}</version>
<type>war</type>
<scope>tomcat</scope>
Expand Down Expand Up @@ -114,13 +148,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>

</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.httpclient.HttpMethodBase;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Assume;
Expand All @@ -26,7 +24,7 @@
import org.springframework.http.ResponseEntity;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.CommonsClientHttpRequestFactory;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RequestCallback;
Expand Down Expand Up @@ -255,15 +253,13 @@ public HttpStatus getStatusCode(String path) {

public RestTemplate getRestTemplate() {
RestTemplate client = new RestTemplate();
CommonsClientHttpRequestFactory requestFactory = new CommonsClientHttpRequestFactory() {
client.setRequestFactory(new SimpleClientHttpRequestFactory() {
@Override
protected void postProcessCommonsHttpMethod(HttpMethodBase httpMethod) {
httpMethod.setFollowRedirects(false);
// We don't want stateful conversations for this test
httpMethod.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
super.prepareConnection(connection, httpMethod);
connection.setInstanceFollowRedirects(false);
}
};
client.setRequestFactory(requestFactory);
});
client.setErrorHandler(new ResponseErrorHandler() {
// Pass errors through in response entity for status code analysis
public boolean hasError(ClientHttpResponse response) throws IOException {
Expand Down

0 comments on commit 049f7f9

Please sign in to comment.