Skip to content

Commit 7efe05c

Browse files
author
Javen
committed
Seperate unit test and integration test.
mvn test will only execute unit tests.
1 parent 088439c commit 7efe05c

27 files changed

+149
-20
lines changed

.classpath

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<classpath>
33
<classpathentry kind="src" path="src/main/java"/>
4+
<classpathentry kind="src" path="example/main/java"/>
45
<classpathentry kind="src" path="src/test/resources"/>
56
<classpathentry kind="src" path="src/main/resources"/>
67
<classpathentry kind="src" path="src/test/java"/>

src/main/java/cn/jpush/api/examples/DevcieExample.java renamed to example/main/java/cn/jpush/api/examples/DevcieExample.java

File renamed without changes.

src/main/java/cn/jpush/api/examples/PushExample.java renamed to example/main/java/cn/jpush/api/examples/PushExample.java

File renamed without changes.

src/main/java/cn/jpush/api/examples/ReportsExample.java renamed to example/main/java/cn/jpush/api/examples/ReportsExample.java

File renamed without changes.

src/main/java/cn/jpush/api/examples/package-info.java renamed to example/main/java/cn/jpush/api/examples/package-info.java

File renamed without changes.

example/main/java/log4j.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
log4j.rootLogger=DEBUG,CONSOLE
2+
3+
log4j.logger.org.eclipse.jetty=INFO
4+
5+
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
6+
log4j.appender.CONSOLE.Target=System.out
7+
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
8+
log4j.appender.CONSOLE.layout.ConversionPattern=%d{yy/MM/dd HH:mm:ss} %p %c{2}: %m%n

pom.xml

Lines changed: 68 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<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/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<groupId>cn.jpush.api</groupId>
@@ -23,7 +24,7 @@
2324
<jdkVersion>1.6</jdkVersion>
2425
<jdkVersion.test>1.8</jdkVersion.test>
2526
</properties>
26-
27+
2728
<parent>
2829
<groupId>org.sonatype.oss</groupId>
2930
<artifactId>oss-parent</artifactId>
@@ -43,16 +44,16 @@
4344
<artifactId>gson</artifactId>
4445
<version>2.3</version>
4546
</dependency>
46-
47+
4748
<dependency>
4849
<groupId>org.slf4j</groupId>
4950
<artifactId>slf4j-api</artifactId>
5051
<version>1.7.7</version>
5152
</dependency>
52-
53-
53+
54+
5455
<!-- Test Dependencies -->
55-
56+
5657
<dependency>
5758
<groupId>org.slf4j</groupId>
5859
<artifactId>slf4j-log4j12</artifactId>
@@ -65,7 +66,7 @@
6566
<version>1.2.17</version>
6667
<scope>test</scope>
6768
</dependency>
68-
69+
6970
<dependency>
7071
<groupId>junit</groupId>
7172
<artifactId>junit</artifactId>
@@ -89,21 +90,22 @@
8990
<source>${jdkVersion}</source>
9091
<target>${jdkVersion}</target>
9192
<compilerVersion>1.5</compilerVersion>
92-
<showDeprecation>true</showDeprecation>
93-
<showWarnings>true</showWarnings>
94-
<debug>true</debug>
95-
<fork>true</fork>
96-
<compilerArgs>
97-
<arg>-Xlint:unchecked</arg>
98-
</compilerArgs>
93+
<showDeprecation>true</showDeprecation>
94+
<showWarnings>true</showWarnings>
95+
<debug>true</debug>
96+
<fork>true</fork>
97+
<compilerArgs>
98+
<arg>-Xlint:unchecked</arg>
99+
</compilerArgs>
99100
</configuration>
100101
</plugin>
101-
102+
102103
<plugin>
103104
<groupId>org.apache.maven.plugins</groupId>
104105
<artifactId>maven-gpg-plugin</artifactId>
105106
<version>1.5</version>
106107
</plugin>
108+
107109
<plugin>
108110
<groupId>org.apache.maven.plugins</groupId>
109111
<artifactId>maven-release-plugin</artifactId>
@@ -123,6 +125,7 @@
123125
<tagNameFormat>v@{project.version}</tagNameFormat>
124126
</configuration>
125127
</plugin>
128+
126129
<plugin>
127130
<groupId>com.github.github</groupId>
128131
<artifactId>site-maven-plugin</artifactId>
@@ -140,16 +143,62 @@
140143
</execution>
141144
</executions>
142145
</plugin>
146+
143147
<plugin>
144148
<groupId>org.apache.maven.plugins</groupId>
145149
<artifactId>maven-surefire-plugin</artifactId>
146-
<version>2.16</version>
150+
<version>2.17</version>
147151
<configuration>
152+
<encoding>UTF-8</encoding>
153+
<parallel>methods</parallel>
154+
<threadCount>10</threadCount>
155+
<groups>cn.jpush.api.FastTests</groups>
148156
<argLine>-Dfile.encoding=UTF-8</argLine>
149-
<excludes>
150-
<exclude>**/mock/*Test.java</exclude>
151-
</excludes>
157+
<excludes>
158+
<exclude>**/mock/*Test.java</exclude>
159+
</excludes>
152160
</configuration>
161+
<dependencies>
162+
<dependency>
163+
<groupId>org.apache.maven.surefire</groupId>
164+
<artifactId>surefire-junit47</artifactId>
165+
<version>2.17</version>
166+
</dependency>
167+
</dependencies>
168+
</plugin>
169+
170+
<plugin>
171+
<groupId>org.apache.maven.plugins</groupId>
172+
<artifactId>maven-failsafe-plugin</artifactId>
173+
<version>2.17</version>
174+
<configuration>
175+
<encoding>UTF-8</encoding>
176+
<groups>cn.jpush.api.SlowTests</groups>
177+
<argLine>-Dfile.encoding=UTF-8</argLine>
178+
<excludes>
179+
<exclude>**/mock/*Test.java</exclude>
180+
</excludes>
181+
</configuration>
182+
<executions>
183+
<execution>
184+
<goals>
185+
<goal>integration-test</goal>
186+
<goal>verify</goal>
187+
</goals>
188+
<configuration>
189+
<includes>
190+
<include>**/*.class</include>
191+
</includes>
192+
</configuration>
193+
</execution>
194+
</executions>
195+
<dependencies>
196+
<dependency>
197+
<groupId>org.apache.maven.surefire</groupId>
198+
<artifactId>surefire-junit47</artifactId>
199+
<version>2.17</version>
200+
</dependency>
201+
</dependencies>
153202
</plugin>
154203
</plugins>
155204
</build>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package cn.jpush.api;
2+
3+
public interface FastTests {
4+
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package cn.jpush.api;
2+
3+
public interface SlowTests {
4+
5+
}

src/test/java/cn/jpush/api/push/model/MessageTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@
77
import java.util.Map;
88

99
import org.junit.Test;
10+
import org.junit.experimental.categories.Category;
11+
12+
import cn.jpush.api.FastTests;
1013

1114
import com.google.gson.JsonElement;
1215
import com.google.gson.JsonObject;
1316
import com.google.gson.JsonPrimitive;
1417

18+
@Category(FastTests.class)
1519
public class MessageTest {
1620

1721
@Test(expected = IllegalArgumentException.class)

0 commit comments

Comments
 (0)