Skip to content

Commit c1ac53b

Browse files
committed
APF-1243: Added integration test for appfuse-ws archetype. Had to downgrade to CXF 2.6.0 for Enunciate and add @JsonIgnore to getAuthorities() method in User.java.
1 parent 264b23f commit c1ac53b

File tree

7 files changed

+97
-72
lines changed

7 files changed

+97
-72
lines changed

archetypes/appfuse-ws/src/pom.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
<groupId>org.codehaus.mojo</groupId>
5959
<artifactId>dbunit-maven-plugin</artifactId>
6060
</plugin>
61+
<!-- Sets cargo.port and cargo.ajp.port to open ports -->
62+
<plugin>
63+
<groupId>org.codehaus.mojo</groupId>
64+
<artifactId>build-helper-maven-plugin</artifactId>
65+
</plugin>
6166
<plugin>
6267
<groupId>org.codehaus.enunciate</groupId>
6368
<artifactId>maven-enunciate-cxf-plugin</artifactId>
@@ -90,6 +95,18 @@
9095
</execution>
9196
</executions>
9297
</plugin>
98+
<plugin>
99+
<artifactId>maven-surefire-plugin</artifactId>
100+
<configuration>
101+
<excludes>
102+
<exclude>**/*IT*.java</exclude>
103+
</excludes>
104+
<includes>
105+
<include>**/*Test.java</include>
106+
<include>**/*Tests.java</include>
107+
</includes>
108+
</configuration>
109+
</plugin>
93110
<plugin>
94111
<groupId>org.eclipse.jetty</groupId>
95112
<artifactId>jetty-maven-plugin</artifactId>
@@ -143,6 +160,10 @@
143160
<artifactId>enunciate-cxf-rt</artifactId>
144161
<version>${enunciate.version}</version>
145162
</dependency>
163+
<dependency>
164+
<groupId>commons-dbcp</groupId>
165+
<artifactId>commons-dbcp</artifactId>
166+
</dependency>
146167
<dependency>
147168
<groupId>org.subethamail</groupId>
148169
<artifactId>subethasmtp-wiser</artifactId>
@@ -158,7 +179,46 @@
158179

159180
<!-- Framework/Plugin versions -->
160181
<appfuse.version>3.5.0-SNAPSHOT</appfuse.version>
182+
<!-- Enunciate doesn't work with CXF 3.x -->
183+
<cxf.version>2.6.0</cxf.version>
161184
<enunciate.version>1.28</enunciate.version>
162185
<java.version>1.7</java.version>
186+
<!-- This is necessary since the root AppFuse pom.xml has skipITs=true -->
187+
<skipITs>false</skipITs>
163188
</properties>
189+
190+
<profiles>
191+
<profile>
192+
<id>itest</id>
193+
<build>
194+
<plugins>
195+
<plugin>
196+
<groupId>org.codehaus.cargo</groupId>
197+
<artifactId>cargo-maven2-plugin</artifactId>
198+
</plugin>
199+
<plugin>
200+
<artifactId>maven-failsafe-plugin</artifactId>
201+
<configuration>
202+
<includes>
203+
<include>**/*IT*.java</include>
204+
</includes>
205+
<systemProperties>
206+
<context.path>${project.artifactId}</context.path>
207+
<cargo.host>${cargo.host}</cargo.host>
208+
<cargo.port>${cargo.port}</cargo.port>
209+
</systemProperties>
210+
</configuration>
211+
<executions>
212+
<execution>
213+
<goals>
214+
<goal>integration-test</goal>
215+
<goal>verify</goal>
216+
</goals>
217+
</execution>
218+
</executions>
219+
</plugin>
220+
</plugins>
221+
</build>
222+
</profile>
223+
</profiles>
164224
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package org.appfuse.api;
2+
3+
import org.apache.commons.logging.Log;
4+
import org.apache.commons.logging.LogFactory;
5+
import org.appfuse.model.User;
6+
import org.junit.Test;
7+
import org.springframework.http.*;
8+
import org.springframework.web.client.RestTemplate;
9+
10+
import java.net.URI;
11+
12+
import static org.junit.Assert.*;
13+
14+
public class UserApiITest {
15+
private final static Log log = LogFactory.getLog(UserApiITest.class);
16+
private RestTemplate restTemplate = new RestTemplate();
17+
18+
@Test
19+
public void testGetUsers() {
20+
ResponseEntity<User[]> result = restTemplate.getForEntity(getUsersPath(), User[].class);
21+
HttpStatus status = result.getStatusCode();
22+
User[] users = result.getBody();
23+
24+
log.debug("Users found: " + users.length);
25+
assertTrue(users.length > 0);
26+
assertEquals(HttpStatus.OK, status);
27+
}
28+
29+
public URI getUsersPath() {
30+
String contextPath = "/" + System.getProperty("context.path", "");
31+
String host = System.getProperty("cargo.host", "localhost");
32+
String port = System.getProperty("cargo.port", "8080");
33+
return URI.create("http://" + host + ":" + port + contextPath + "/api/users.json");
34+
}
35+
}

archetypes/appfuse-ws/src/src/test/resources/applicationContext-resources.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

archetypes/appfuse-ws/src/src/test/resources/jdbc.properties

Lines changed: 0 additions & 13 deletions
This file was deleted.

archetypes/appfuse-ws/src/src/test/resources/log4j2.xml

Lines changed: 0 additions & 28 deletions
This file was deleted.

archetypes/appfuse-ws/src/src/test/resources/mail.properties

Lines changed: 0 additions & 9 deletions
This file was deleted.

data/common/src/main/java/org/appfuse/model/User.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,9 @@ public void addRole(Role role) {
207207
* @see org.springframework.security.core.userdetails.UserDetails#getAuthorities()
208208
*/
209209
@Transient
210+
@JsonIgnore // needed for UserApiITest in appfuse-ws archetype
210211
public Set<GrantedAuthority> getAuthorities() {
211-
Set<GrantedAuthority> authorities = new LinkedHashSet<GrantedAuthority>();
212+
Set<GrantedAuthority> authorities = new LinkedHashSet<>();
212213
authorities.addAll(roles);
213214
return authorities;
214215
}

0 commit comments

Comments
 (0)