Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit b9e3865

Browse files
joakimeaozarov
authored andcommitted
Fixes #262 - Integration testing more stable in maven. (#283)
* Fixes #262 - Integration testing more stable in maven. * Forces maven-failsafe-plugin in parent (with version) * Renames integration tests from *Test.java to *IT.java to better conform to new recommendations from maven-failsafe-plugin (convention over configuration!) * Issue #262 - Checkstyle updates * Added checkstyle/checkstyle-suppressions.xml * Updated root pom.xml to use new suppression techniques in a way that's friendly to a maven reactor build
1 parent d5728c1 commit b9e3865

23 files changed

+76
-25
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
5+
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
6+
7+
<suppressions>
8+
<suppress files="[a-zA-Z0-9]*IT.java" checks="AbbreviationAsWordInName"/>
9+
<suppress files="[a-zA-Z0-9]*IT.java" checks="JavadocMethod"/>
10+
<suppress files="[a-zA-Z0-9]*Test.java" checks="JavadocMethod"/>
11+
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
12+
</suppressions>
13+
14+

checkstyle/google-checks.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<property name="severity" value="warning"/>
2121
<property name="fileExtensions" value="java, properties, xml"/>
2222

23+
<module name="SuppressionFilter">
24+
<property name="file" value="${checkstyle.suppressions.file}"/>
25+
</module>
26+
2327
<!-- Checks for whitespace -->
2428
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
2529
<module name="FileTabCharacter">

jetty9-compat-base/src/it/java/com/google/apphosting/runtime/jetty9/SessionManagerTest.java renamed to jetty9-compat-base/src/test/java/com/google/apphosting/runtime/jetty9/SessionManagerIT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
*
7474
* @author [email protected] (Freeland Abbott)
7575
*/
76-
public class SessionManagerTest extends TestCase {
76+
public class SessionManagerIT extends TestCase {
7777

7878
private static final int SESSION_EXPIRATION_SECONDS = 60;
7979

@@ -147,7 +147,7 @@ public String testNamespace() {
147147
return "";
148148
}
149149

150-
public static class NamespacedStartTest extends SessionManagerTest {
150+
public static class NamespacedStartTest extends SessionManagerIT {
151151
@Override
152152
public String startNamespace() {
153153
return "start-namespace";
@@ -159,7 +159,7 @@ public String testNamespace() {
159159
}
160160
}
161161

162-
public static class NamespacedTest extends SessionManagerTest {
162+
public static class NamespacedTest extends SessionManagerIT {
163163
@Override
164164
public String startNamespace() {
165165
return "";
@@ -171,7 +171,7 @@ public String testNamespace() {
171171
}
172172
}
173173

174-
public static class NamespacedTestTest extends SessionManagerTest {
174+
public static class NamespacedTestTest extends SessionManagerIT {
175175
@Override
176176
public String startNamespace() {
177177
return "start-namespace";
@@ -511,7 +511,7 @@ public void testMemcacheOnlyLifecycle() {
511511
* new SessionManager(Collections.&lt;SessionStore&gt;singletonList(new DatastoreSessionStore()));
512512
* HttpServletRequest request = makeMockRequest(true);
513513
* replay(request);
514-
*
514+
* <p>
515515
* AppEngineSession session = manager.newSession(request);
516516
* session.setAttribute("foo", "bar");
517517
* session.save();

jetty9-compat-base/src/it/java/com/google/apphosting/vmruntime/jetty9/ApiRequest.java renamed to jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/ApiRequest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ public class ApiRequest {
2727
public final String methodName;
2828
public final byte[] requestData;
2929

30+
/**
31+
* Simple API request.
32+
*
33+
* @param environment the environment
34+
* @param packageName the package name
35+
* @param methodName the method name
36+
* @param requestData the request data
37+
*/
3038
public ApiRequest(
3139
VmApiProxyEnvironment environment,
3240
String packageName,
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
/**
5353
* Tests for AppEngineAuthentication.
5454
*
55-
* Test plan: Create and configure a ConstraintSecurityHandler to use our AppEngineAuthentication
55+
* <p>Test plan: Create and configure a ConstraintSecurityHandler to use our AppEngineAuthentication
5656
* classes, then configure some paths to require users to be logged in. We then fire requests at the
5757
* security handler by calling its handle() method and verify that unauthenticated requests are
5858
* redirected to a login url, while authenticated requests are allowed through.
@@ -125,8 +125,8 @@ public void tearDown() throws Exception {
125125
/**
126126
* Fire one request at the security handler (and by extension to the AuthServlet behind it).
127127
*
128-
* @param path The path to hit.
129-
* @param request The request object to use.
128+
* @param path The path to hit.
129+
* @param request The request object to use.
130130
* @param response The response object to use. Must be created by Mockito.mock()
131131
* @return Any data written to response.getWriter()
132132
*/

jetty9-compat-base/src/it/java/com/google/apphosting/vmruntime/jetty9/AsyncServletTest.java renamed to jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/AsyncServletIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import java.util.Arrays;
3333
import java.util.List;
3434

35-
public class AsyncServletTest extends VmRuntimeTestBase {
35+
public class AsyncServletIT extends VmRuntimeTestBase {
3636

3737
/**
3838
* Test that blob upload requests are intercepted by the blob upload filter.

jetty9-compat-base/src/it/java/com/google/apphosting/vmruntime/jetty9/LoggingTest.java renamed to jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/LoggingIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import java.io.InputStreamReader;
3131
import java.nio.charset.StandardCharsets;
3232

33-
public class LoggingTest extends VmRuntimeTestBase {
33+
public class LoggingIT extends VmRuntimeTestBase {
3434

3535
public void testGet() throws Exception {
3636

jetty9-compat-base/src/it/java/com/google/apphosting/vmruntime/jetty9/NoAppWebXmlTest.java renamed to jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/NoAppWebXmlIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020

2121
/**
2222
* Testing that appengine-web.xml can be optional.
23-
*
2423
*/
25-
public class NoAppWebXmlTest extends VmRuntimeTestBase {
24+
public class NoAppWebXmlIT extends VmRuntimeTestBase {
2625

2726
@Override
2827
protected void setUp() throws Exception {

jetty9-compat-base/src/it/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeJettyAuthTest.java renamed to jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeJettyAuthIT.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626

2727
/**
2828
* Testing Jetty9 auth handling.
29-
*
3029
*/
31-
public class VmRuntimeJettyAuthTest extends VmRuntimeTestBase {
30+
public class VmRuntimeJettyAuthIT extends VmRuntimeTestBase {
3231

3332
public void testAuth_UserNotRequired() throws Exception {
3433
String[] lines = fetchUrl(createUrl("/test-auth"));
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueServiceError.ErrorCode;
2626
import com.google.apphosting.api.ApiBasePb.VoidProto;
2727
import com.google.apphosting.api.ApiProxy;
28-
//import com.google.apphosting.datastore.DatastoreV3Pb.Transaction;
2928
import com.google.apphosting.api.DatastorePb.Transaction;
3029

3130
import org.apache.commons.httpclient.Header;
@@ -36,11 +35,12 @@
3635

3736
import java.net.HttpURLConnection;
3837

38+
//import com.google.apphosting.datastore.DatastoreV3Pb.Transaction;
39+
3940
/**
4041
* Misc individual Jetty9 vmengines tests.
41-
*
4242
*/
43-
public class VmRuntimeJettyKitchenSink2Test extends VmRuntimeTestBase {
43+
public class VmRuntimeJettyKitchenSink2IT extends VmRuntimeTestBase {
4444

4545
/**
4646
* Test that the count servlet was loaded, and that local state is preserved
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@
3434

3535
/**
3636
* Misc individual Jetty9 vmengines tests.
37-
*
3837
*/
39-
public class VmRuntimeJettyKitchenSinkTest extends VmRuntimeTestBase {
38+
public class VmRuntimeJettyKitchenSinkIT extends VmRuntimeTestBase {
4039

4140
@Override
4241
protected void setUp() throws Exception {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
*
4545
* @author [email protected] (Tomas Isdal)
4646
*/
47-
public class VmRuntimeJettySessionTest extends VmRuntimeTestBase {
47+
public class VmRuntimeJettySessionIT extends VmRuntimeTestBase {
4848

4949
@Override
5050
protected void setUp() throws Exception {
@@ -123,6 +123,7 @@ public void testWelcomeServlet() throws Exception {
123123
// code = fetchResponseCode(createUrl("/_ah/health"));
124124
// assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, code);
125125
// }
126+
126127
/**
127128
* Create a datastore put response with the minimal fields required to make
128129
* the put succeed.

jetty9-compat-base/src/it/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeTestBase.java renamed to jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeTestBase.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
/**
4141
* Base test class for the Java VmRuntime.
42-
*
42+
* <p>
4343
* Test methods that are Jetty version independent should be implemented in this class.
4444
*/
4545
@Ignore
@@ -106,6 +106,7 @@ protected String[] fetchUrl(URL url) throws IOException {
106106

107107
/**
108108
* Convenience method for fetching from a HttpURLConnection. This allows headers to be set.
109+
*
109110
* @param connection the connection to use
110111
* @return A string array of the lines in the response.
111112
*/
@@ -161,7 +162,10 @@ protected HttpURLConnection openConnection(String path) throws IOException {
161162
conn.setRequestProperty("Metadata-Flavor", "Google");
162163
return conn;
163164
}
164-
/** Timeout in milliseconds to retrieve data from the server. */
165+
166+
/**
167+
* Timeout in milliseconds to retrieve data from the server.
168+
*/
165169
private static final int TIMEOUT_MILLIS = 120 * 1000;
166170

167171
protected String getMetadataFromServer(String path) throws IOException {

jetty9-compat-base/src/it/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeWebAppContextTest.java renamed to jetty9-compat-base/src/test/java/com/google/apphosting/vmruntime/jetty9/VmRuntimeWebAppContextTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242

4343
/**
4444
* Test VmRuntimeWebAppContext directly, without using VmRuntimeTestBase
45-
*
4645
*/
4746
public class VmRuntimeWebAppContextTest {
4847

pom.xml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131

3232
<properties>
3333
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
34+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
3435
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
3536
<jetty.version>9.3.8.v20160314</jetty.version>
3637
<appengine.api.version>1.9.38</appengine.api.version>
3738
<docker.label.prefix>async-</docker.label.prefix>
38-
<checkstyle.config.location>checkstyle/google-checks.xml</checkstyle.config.location>
3939
</properties>
4040

4141
<developers>
@@ -152,13 +152,14 @@
152152
<artifactId>docker-maven-plugin</artifactId>
153153
<version>0.3.2</version>
154154
</plugin>
155+
155156
<plugin>
156157
<groupId>org.apache.maven.plugins</groupId>
157158
<artifactId>maven-surefire-plugin</artifactId>
158159
<version>2.18</version>
159160
</plugin>
160161

161-
<plugin>
162+
<plugin>
162163
<groupId>org.apache.maven.plugins</groupId>
163164
<artifactId>maven-source-plugin</artifactId>
164165
<version>2.4</version>
@@ -198,6 +199,7 @@
198199
<artifactId>maven-deploy-plugin</artifactId>
199200
<version>2.8.2</version>
200201
</plugin>
202+
201203
<plugin>
202204
<groupId>org.apache.maven.plugins</groupId>
203205
<artifactId>maven-release-plugin</artifactId>
@@ -226,6 +228,8 @@
226228
<goal>check</goal>
227229
</goals>
228230
<configuration>
231+
<configLocation>checkstyle/google-checks.xml</configLocation>
232+
<suppressionsLocation>checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
229233
<consoleOutput>true</consoleOutput>
230234
<failOnViolation>true</failOnViolation>
231235
<violationSeverity>error</violationSeverity>
@@ -235,6 +239,26 @@
235239
</execution>
236240
</executions>
237241
</plugin>
242+
<plugin>
243+
<groupId>org.apache.maven.plugins</groupId>
244+
<artifactId>maven-failsafe-plugin</artifactId>
245+
<version>2.19.1</version>
246+
<executions>
247+
<execution>
248+
<goals>
249+
<goal>integration-test</goal>
250+
<goal>verify</goal>
251+
</goals>
252+
</execution>
253+
</executions>
254+
<dependencies>
255+
<dependency>
256+
<groupId>org.apache.maven.surefire</groupId>
257+
<artifactId>surefire-junit47</artifactId>
258+
<version>2.19.1</version>
259+
</dependency>
260+
</dependencies>
261+
</plugin>
238262
</plugins>
239263
</build>
240264

0 commit comments

Comments
 (0)