Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c97f8d1

Browse files
committedOct 26, 2018
Add mock and integration tests to test using SDK on module path with Java 9+
1 parent 7fca513 commit c97f8d1

File tree

20 files changed

+887
-11
lines changed

20 files changed

+887
-11
lines changed
 

‎buildspecs/build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@ version: 0.2
33
phases:
44
build:
55
commands:
6-
- mvn clean install -Dmaven.wagon.httpconnectionManager.maxPerRoute=2
6+
- mvn clean install -Dmaven.wagon.httpconnectionManager.maxPerRoute=2
7+
- JAVA_VERSION=$(java -version 2>&1 | head -n 1 | cut -d\" -f 2)
8+
- echo $JAVA_VERSION
9+
- |
10+
if [ "$JAVA_VERSION" \> "9" ]; then
11+
cd test/module-path-tests
12+
mvn package
13+
mvn exec:exec -P mock-tests
14+
fi

‎buildspecs/integ-test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@ version: 0.2
33
phases:
44
build:
55
commands:
6-
- mvn clean verify -Dskip.unit.tests -P integration-tests -Dfindbugs.skip -Dcheckstyle.skip -pl !:dynamodbmapper-v1 -Dfailsafe.rerunFailingTestsCount=1 -Dmaven.wagon.httpconnectionManager.maxPerRoute=2
6+
- mvn clean verify -Dskip.unit.tests -P integration-tests -Dfindbugs.skip -Dcheckstyle.skip -pl !:dynamodbmapper-v1 -Dfailsafe.rerunFailingTestsCount=1 -Dmaven.wagon.httpconnectionManager.maxPerRoute=2
7+
- JAVA_VERSION=$(java -version 2>&1 | head -n 1 | cut -d\" -f 2)
8+
- echo $JAVA_VERSION
9+
- |
10+
if [ "$JAVA_VERSION" \> "9" ]; then
11+
cd test/module-path-tests
12+
mvn package
13+
mvn exec:exec -P integ-tests
14+
fi

‎buildspecs/on-demand-integ-test.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,12 @@ version: 0.2
33
phases:
44
build:
55
commands:
6-
- mvn clean verify -Dskip.unit.tests -P integration-tests -Dfindbugs.skip -Dcheckstyle.skip -pl !:dynamodbmapper-v1 -Dfailsafe.rerunFailingTestsCount=1 -Dmaven.wagon.httpconnectionManager.maxPerRoute=2 --fail-at-end
6+
- mvn clean verify -Dskip.unit.tests -P integration-tests -Dfindbugs.skip -Dcheckstyle.skip -pl !:dynamodbmapper-v1 -Dfailsafe.rerunFailingTestsCount=1 -Dmaven.wagon.httpconnectionManager.maxPerRoute=2 --fail-at-end
7+
- JAVA_VERSION=$(java -version 2>&1 | head -n 1 | cut -d\" -f 2)
8+
- echo $JAVA_VERSION
9+
- |
10+
if [ "$JAVA_VERSION" \> "9" ]; then
11+
cd test/module-path-tests
12+
mvn package
13+
mvn exec:exec -P integ-tests
14+
fi

‎http-clients/apache-client/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,6 @@
4949
<version>${awsjavasdk.version}</version>
5050
<scope>test</scope>
5151
</dependency>
52-
<dependency>
53-
<groupId>org.slf4j</groupId>
54-
<artifactId>slf4j-api</artifactId>
55-
</dependency>
5652
<dependency>
5753
<groupId>org.apache.httpcomponents</groupId>
5854
<artifactId>httpclient</artifactId>

‎pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124
<checkstyle.version>7.8.2</checkstyle.version>
125125
<jacoco-maven-plugin.version>0.8.1</jacoco-maven-plugin.version>
126126
<nexus-staging-maven-plugin.version>1.6.8</nexus-staging-maven-plugin.version>
127+
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
127128

128129
<!-- These properties are used by Step functions for its dependencies -->
129130
<json-path.version>2.4.0</json-path.version>
@@ -528,6 +529,7 @@
528529
<failsOnError>true</failsOnError>
529530
<logViolationsToConsole>true</logViolationsToConsole>
530531
<failOnViolation>true</failOnViolation>
532+
<excludes>**/module-info.java</excludes>
531533
</configuration>
532534
</plugin>
533535
<plugin>

‎protocols/aws-ion-protocol/pom.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@
5858
<groupId>com.fasterxml.jackson.core</groupId>
5959
<artifactId>jackson-core</artifactId>
6060
</dependency>
61-
<dependency>
62-
<groupId>software.amazon.ion</groupId>
63-
<artifactId>ion-java</artifactId>
64-
</dependency>
6561
<dependency>
6662
<groupId>junit</groupId>
6763
<artifactId>junit</artifactId>

‎test/module-path-tests/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# AWS SDK Module Path Tests
2+
3+
## Description
4+
This module is used to test using SDK on module path with Java 9+.
5+
6+
- Mock tests: calling xml/json prococol sync/async clients using mock http clients.
7+
- Integ tests: calling service clients using `UrlConnectionHttpClient`, `ApacheHttpClient` and `NettyNioAsyncHttpClient`.
8+
9+
## How to run
10+
```
11+
mvn clean package
12+
mvn exec:exec -P mock-tests
13+
mvn exec:exec -P integ-tests
14+
```
15+
16+

‎test/module-path-tests/pom.xml

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License").
6+
~ You may not use this file except in compliance with the License.
7+
~ A copy of the License is located at
8+
~
9+
~ http://aws.amazon.com/apache2.0
10+
~
11+
~ or in the "license" file accompanying this file. This file is distributed
12+
~ on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
~ express or implied. See the License for the specific language governing
14+
~ permissions and limitations under the License.
15+
-->
16+
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
20+
<parent>
21+
<artifactId>aws-sdk-java-pom</artifactId>
22+
<groupId>software.amazon.awssdk</groupId>
23+
<version>2.0.0-preview-13-SNAPSHOT</version>
24+
<relativePath>../../pom.xml</relativePath>
25+
</parent>
26+
<modelVersion>4.0.0</modelVersion>
27+
28+
<artifactId>module-path-tests</artifactId>
29+
<!-- Setting it to a different version so it can always load dependencies from maven
30+
rather than local module-->
31+
<version>1.0.0-SNAPSHOT</version>
32+
33+
<name>AWS Java SDK :: Test :: Module Path Tests</name>
34+
<description>A set of tests to run v2 in module path with Java 9+.</description>
35+
<url>https://aws.amazon.com/sdkforjava</url>
36+
37+
<dependencies>
38+
<dependency>
39+
<groupId>software.amazon.awssdk</groupId>
40+
<artifactId>s3</artifactId>
41+
<version>${project.parent.version}</version>
42+
<exclusions>
43+
<exclusion>
44+
<!-- TODO remove exclusions after we fix netty module -->
45+
<artifactId>netty-nio-client</artifactId>
46+
<groupId>software.amazon.awssdk</groupId>
47+
</exclusion>
48+
</exclusions>
49+
</dependency>
50+
<dependency>
51+
<groupId>software.amazon.awssdk</groupId>
52+
<artifactId>protocol-tests</artifactId>
53+
<version>${project.parent.version}</version>
54+
<exclusions>
55+
<exclusion>
56+
<!-- TODO remove exclusions after we fix netty module -->
57+
<artifactId>netty-nio-client</artifactId>
58+
<groupId>software.amazon.awssdk</groupId>
59+
</exclusion>
60+
</exclusions>
61+
</dependency>
62+
<dependency>
63+
<groupId>software.amazon.awssdk</groupId>
64+
<artifactId>apache-client</artifactId>
65+
<version>${project.parent.version}</version>
66+
</dependency>
67+
<dependency>
68+
<groupId>software.amazon.awssdk</groupId>
69+
<artifactId>url-connection-client</artifactId>
70+
<version>${project.parent.version}</version>
71+
</dependency>
72+
<dependency>
73+
<groupId>org.slf4j</groupId>
74+
<artifactId>slf4j-simple</artifactId>
75+
<version>${slf4j.version}</version>
76+
</dependency>
77+
<dependency>
78+
<groupId>software.amazon.awssdk</groupId>
79+
<artifactId>service-test-utils</artifactId>
80+
<version>${project.parent.version}</version>
81+
<scope>compile</scope>
82+
</dependency>
83+
</dependencies>
84+
<build>
85+
<plugins>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-compiler-plugin</artifactId>
89+
<executions>
90+
<execution>
91+
<id>default-compile</id>
92+
<configuration>
93+
<source>9</source>
94+
<release>9</release>
95+
</configuration>
96+
</execution>
97+
</executions>
98+
<configuration>
99+
<jdkToolchain>
100+
<version>[9,)</version>
101+
</jdkToolchain>
102+
<release>9</release>
103+
</configuration>
104+
</plugin>
105+
<plugin>
106+
<groupId>org.apache.maven.plugins</groupId>
107+
<artifactId>maven-surefire-plugin</artifactId>
108+
</plugin>
109+
<!-- Disable spotbugs speed up the build. -->
110+
<plugin>
111+
<groupId>com.github.spotbugs</groupId>
112+
<artifactId>spotbugs-maven-plugin</artifactId>
113+
<configuration>
114+
<skip>true</skip>
115+
</configuration>
116+
</plugin>
117+
</plugins>
118+
</build>
119+
120+
<profiles>
121+
<profile>
122+
<id>mock-tests</id>
123+
<build>
124+
<plugins>
125+
<plugin>
126+
<groupId>org.codehaus.mojo</groupId>
127+
<!-- https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html -->
128+
<artifactId>exec-maven-plugin</artifactId>
129+
<version>${exec-maven-plugin.version}</version>
130+
<configuration>
131+
<executable>java</executable>
132+
<arguments>
133+
<argument>--module-path</argument>
134+
<modulepath/>
135+
<argument>--module</argument>
136+
<argument>software.amazon.awssdk.modulepath.tests/software.amazon.awssdk.modulepath.tests.MockTestsRunner
137+
</argument>
138+
</arguments>
139+
</configuration>
140+
</plugin>
141+
</plugins>
142+
</build>
143+
</profile>
144+
145+
<profile>
146+
<id>integ-tests</id>
147+
<build>
148+
<plugins>
149+
<plugin>
150+
<groupId>org.codehaus.mojo</groupId>
151+
<!-- https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html -->
152+
<artifactId>exec-maven-plugin</artifactId>
153+
<version>${exec-maven-plugin.version}</version>
154+
<configuration>
155+
<executable>java</executable>
156+
<arguments>
157+
<argument>--module-path</argument>
158+
<modulepath/>
159+
<argument>--module</argument>
160+
<argument>software.amazon.awssdk.modulepath.tests/software.amazon.awssdk.modulepath.tests.IntegTestsRunner
161+
</argument>
162+
</arguments>
163+
</configuration>
164+
</plugin>
165+
</plugins>
166+
</build>
167+
</profile>
168+
</profiles>
169+
</project>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
module software.amazon.awssdk.modulepath.tests {
17+
requires software.amazon.awssdk.regions;
18+
requires software.amazon.awssdk.http.urlconnection;
19+
requires software.amazon.awssdk.http.apache;
20+
requires software.amazon.awssdk.http;
21+
requires software.amazon.awssdk.core;
22+
requires software.amazon.awssdk.awscore;
23+
requires software.amazon.awssdk.auth;
24+
requires software.amazon.awssdk.services.s3;
25+
requires software.amazon.awssdk.protocol.tests;
26+
requires org.reactivestreams;
27+
requires software.amazon.awssdk.utils;
28+
requires software.amazon.awssdk.testutils.service;
29+
30+
// This is fine because those are just used in unit test.
31+
// https://jira.qos.ch/browse/SLF4J-420
32+
requires slf4j.api;
33+
requires slf4j.simple;
34+
35+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.modulepath.tests;
17+
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
import software.amazon.awssdk.modulepath.tests.integtests.BaseApiCall;
21+
import software.amazon.awssdk.modulepath.tests.integtests.S3ApiCall;
22+
23+
/**
24+
* Tests runner to test module path on real service.
25+
*/
26+
public class IntegTestsRunner {
27+
28+
private IntegTestsRunner() {
29+
}
30+
31+
public static void main(String... args) {
32+
33+
List<BaseApiCall> tests = new ArrayList<>();
34+
tests.add(new S3ApiCall());
35+
36+
tests.forEach(test -> {
37+
test.usingApacheClient();
38+
test.usingUrlConnectionClient();
39+
test.usingNettyClient();
40+
});
41+
}
42+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2010-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package software.amazon.awssdk.modulepath.tests;
17+
18+
import java.util.ArrayList;
19+
import java.util.List;
20+
import software.amazon.awssdk.modulepath.tests.mocktests.BaseMockApiCall;
21+
import software.amazon.awssdk.modulepath.tests.mocktests.JsonProtocolApiCall;
22+
import software.amazon.awssdk.modulepath.tests.mocktests.XmlProtocolApiCall;
23+
24+
/**
25+
* Executor to run mock tests on module path.
26+
*/
27+
public class MockTestsRunner {
28+
29+
private MockTestsRunner() {
30+
}
31+
32+
public static void main(String... args) {
33+
List<BaseMockApiCall> tests = new ArrayList<>();
34+
tests.add(new XmlProtocolApiCall());
35+
tests.add(new JsonProtocolApiCall());
36+
37+
tests.forEach(t -> {
38+
t.successfulApiCall();
39+
t.failedApiCall();
40+
41+
t.successfulAsyncApiCall();
42+
t.failedAsyncApiCall();
43+
});
44+
}
45+
}

0 commit comments

Comments
 (0)