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

Fixes #262 - Integration testing more stable in maven. #283

Merged
merged 3 commits into from
Jun 9, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions checkstyle/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">

<suppressions>
<suppress files="[a-zA-Z0-9]*IT.java" checks="AbbreviationAsWordInName"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, should it be prefixed with [/\\]test[/\\]src[/\\]java[/\\] (also for the other IT, Test checks)?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would vote for the simpler form, as maven is free to copy/move files around into the /target/ (aka ${project.build.directory}) directory, which checkstyle also looks inside of.

Copy link
Contributor

@aozarov aozarov Jun 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can live with it though I wish we could avoid being lenient where we shouldn't.

<suppress files="[a-zA-Z0-9]*IT.java" checks="JavadocMethod"/>
<suppress files="[a-zA-Z0-9]*Test.java" checks="JavadocMethod"/>
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
</suppressions>


4 changes: 4 additions & 0 deletions checkstyle/google-checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java, properties, xml"/>

<module name="SuppressionFilter">
<property name="file" value="${checkstyle.suppressions.file}"/>
</module>

<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="FileTabCharacter">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
*
* @author [email protected] (Freeland Abbott)
*/
public class SessionManagerTest extends TestCase {
public class SessionManagerIT extends TestCase {

private static final int SESSION_EXPIRATION_SECONDS = 60;

Expand Down Expand Up @@ -147,7 +147,7 @@ public String testNamespace() {
return "";
}

public static class NamespacedStartTest extends SessionManagerTest {
public static class NamespacedStartTest extends SessionManagerIT {
@Override
public String startNamespace() {
return "start-namespace";
Expand All @@ -159,7 +159,7 @@ public String testNamespace() {
}
}

public static class NamespacedTest extends SessionManagerTest {
public static class NamespacedTest extends SessionManagerIT {
@Override
public String startNamespace() {
return "";
Expand All @@ -171,7 +171,7 @@ public String testNamespace() {
}
}

public static class NamespacedTestTest extends SessionManagerTest {
public static class NamespacedTestTest extends SessionManagerIT {
@Override
public String startNamespace() {
return "start-namespace";
Expand Down Expand Up @@ -511,7 +511,7 @@ public void testMemcacheOnlyLifecycle() {
* new SessionManager(Collections.&lt;SessionStore&gt;singletonList(new DatastoreSessionStore()));
* HttpServletRequest request = makeMockRequest(true);
* replay(request);
*
* <p>
* AppEngineSession session = manager.newSession(request);
* session.setAttribute("foo", "bar");
* session.save();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public class ApiRequest {
public final String methodName;
public final byte[] requestData;

/**
* Simple API request.
*
* @param environment the environment
* @param packageName the package name
* @param methodName the method name
* @param requestData the request data
*/
public ApiRequest(
VmApiProxyEnvironment environment,
String packageName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
/**
* Tests for AppEngineAuthentication.
*
* Test plan: Create and configure a ConstraintSecurityHandler to use our AppEngineAuthentication
* <p>Test plan: Create and configure a ConstraintSecurityHandler to use our AppEngineAuthentication
* classes, then configure some paths to require users to be logged in. We then fire requests at the
* security handler by calling its handle() method and verify that unauthenticated requests are
* redirected to a login url, while authenticated requests are allowed through.
Expand Down Expand Up @@ -125,8 +125,8 @@ public void tearDown() throws Exception {
/**
* Fire one request at the security handler (and by extension to the AuthServlet behind it).
*
* @param path The path to hit.
* @param request The request object to use.
* @param path The path to hit.
* @param request The request object to use.
* @param response The response object to use. Must be created by Mockito.mock()
* @return Any data written to response.getWriter()
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.util.Arrays;
import java.util.List;

public class AsyncServletTest extends VmRuntimeTestBase {
public class AsyncServletIT extends VmRuntimeTestBase {

/**
* Test that blob upload requests are intercepted by the blob upload filter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class LoggingTest extends VmRuntimeTestBase {
public class LoggingIT extends VmRuntimeTestBase {

public void testGet() throws Exception {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@

/**
* Testing that appengine-web.xml can be optional.
*
*/
public class NoAppWebXmlTest extends VmRuntimeTestBase {
public class NoAppWebXmlIT extends VmRuntimeTestBase {

@Override
protected void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@

/**
* Testing Jetty9 auth handling.
*
*/
public class VmRuntimeJettyAuthTest extends VmRuntimeTestBase {
public class VmRuntimeJettyAuthIT extends VmRuntimeTestBase {

public void testAuth_UserNotRequired() throws Exception {
String[] lines = fetchUrl(createUrl("/test-auth"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.google.appengine.api.taskqueue.TaskQueuePb.TaskQueueServiceError.ErrorCode;
import com.google.apphosting.api.ApiBasePb.VoidProto;
import com.google.apphosting.api.ApiProxy;
//import com.google.apphosting.datastore.DatastoreV3Pb.Transaction;
import com.google.apphosting.api.DatastorePb.Transaction;

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

import java.net.HttpURLConnection;

//import com.google.apphosting.datastore.DatastoreV3Pb.Transaction;

/**
* Misc individual Jetty9 vmengines tests.
*
*/
public class VmRuntimeJettyKitchenSink2Test extends VmRuntimeTestBase {
public class VmRuntimeJettyKitchenSink2IT extends VmRuntimeTestBase {

/**
* Test that the count servlet was loaded, and that local state is preserved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@

/**
* Misc individual Jetty9 vmengines tests.
*
*/
public class VmRuntimeJettyKitchenSinkTest extends VmRuntimeTestBase {
public class VmRuntimeJettyKitchenSinkIT extends VmRuntimeTestBase {

@Override
protected void setUp() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*
* @author [email protected] (Tomas Isdal)
*/
public class VmRuntimeJettySessionTest extends VmRuntimeTestBase {
public class VmRuntimeJettySessionIT extends VmRuntimeTestBase {

@Override
protected void setUp() throws Exception {
Expand Down Expand Up @@ -123,6 +123,7 @@ public void testWelcomeServlet() throws Exception {
// code = fetchResponseCode(createUrl("/_ah/health"));
// assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, code);
// }

/**
* Create a datastore put response with the minimal fields required to make
* the put succeed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

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

/**
* Convenience method for fetching from a HttpURLConnection. This allows headers to be set.
*
* @param connection the connection to use
* @return A string array of the lines in the response.
*/
Expand Down Expand Up @@ -161,7 +162,10 @@ protected HttpURLConnection openConnection(String path) throws IOException {
conn.setRequestProperty("Metadata-Flavor", "Google");
return conn;
}
/** Timeout in milliseconds to retrieve data from the server. */

/**
* Timeout in milliseconds to retrieve data from the server.
*/
private static final int TIMEOUT_MILLIS = 120 * 1000;

protected String getMetadataFromServer(String path) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

/**
* Test VmRuntimeWebAppContext directly, without using VmRuntimeTestBase
*
*/
public class VmRuntimeWebAppContextTest {

Expand Down
28 changes: 26 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.build.timestamp.format>yyyyMMddHHmm</maven.build.timestamp.format>
<jetty.version>9.3.8.v20160314</jetty.version>
<appengine.api.version>1.9.38</appengine.api.version>
<docker.label.prefix>async-</docker.label.prefix>
<checkstyle.config.location>checkstyle/google-checks.xml</checkstyle.config.location>
</properties>

<developers>
Expand Down Expand Up @@ -152,13 +152,14 @@
<artifactId>docker-maven-plugin</artifactId>
<version>0.3.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
</plugin>

<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
Expand Down Expand Up @@ -198,6 +199,7 @@
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand Down Expand Up @@ -226,6 +228,8 @@
<goal>check</goal>
</goals>
<configuration>
<configLocation>checkstyle/google-checks.xml</configLocation>
<suppressionsLocation>checkstyle/checkstyle-suppressions.xml</suppressionsLocation>
<consoleOutput>true</consoleOutput>
<failOnViolation>true</failOnViolation>
<violationSeverity>error</violationSeverity>
Expand All @@ -235,6 +239,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.19.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.19.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>

Expand Down