Skip to content

Commit 3fc2d10

Browse files
authored
enable Github Action for Unit test (#6726)
1 parent a2a14dc commit 3fc2d10

31 files changed

Lines changed: 190 additions & 41 deletions

File tree

.github/workflows/unit-test.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Unit Test
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
ubuntu-jdk8:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- name: Set up JDK 8
11+
uses: actions/setup-java@v1
12+
with:
13+
java-version: 8
14+
- uses: actions/cache@v2
15+
with:
16+
path: ~/.m2/repository
17+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
18+
- name: Test with Maven
19+
uses: nick-invision/retry@v1
20+
with:
21+
timeout_minutes: 40
22+
max_attempts: 3
23+
command: ./mvnw --batch-mode --no-transfer-progress clean install -DskipTests=false -DskipIntegrationTests=false -Dcheckstyle.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true
24+
- name: Upload coverage to Codecov
25+
uses: codecov/codecov-action@v1
26+
27+
ubuntu-jdk11:
28+
runs-on: ubuntu-latest
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Set up JDK 11
32+
uses: actions/setup-java@v1
33+
with:
34+
java-version: 11
35+
- uses: actions/cache@v2
36+
with:
37+
path: ~/.m2/repository
38+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
39+
- name: Test with Maven
40+
uses: nick-invision/retry@v1
41+
with:
42+
timeout_minutes: 40
43+
max_attempts: 3
44+
command: ./mvnw --batch-mode --no-transfer-progress clean install -DskipTests=false -DskipIntegrationTests=false -Dcheckstyle.skip=false -Drat.skip=false -Dmaven.javadoc.skip=true
45+
- name: Upload coverage to Codecov
46+
uses: codecov/codecov-action@v1
47+
48+
windows-jdk11:
49+
runs-on: windows-latest
50+
steps:
51+
- uses: actions/checkout@v2
52+
- name: Set up JDK 11
53+
uses: actions/setup-java@v1
54+
with:
55+
java-version: 11
56+
- uses: actions/cache@v2
57+
with:
58+
path: ~/.m2/repository
59+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
60+
- name: Test with Maven
61+
uses: nick-invision/retry@v1
62+
with:
63+
timeout_minutes: 40
64+
max_attempts: 3
65+
command: mvn --batch-mode --no-transfer-progress clean install
66+
- name: Upload coverage to Codecov
67+
uses: codecov/codecov-action@v1

dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/metadata/MetadataServiceExporterTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class MetadataServiceExporterTest {
4141

4242
@BeforeAll
4343
public static void init() {
44+
ApplicationModel.reset();
4445
ApplicationModel.getConfigManager().setApplication(new ApplicationConfig("Test"));
4546
ApplicationModel.getConfigManager().addRegistry(new RegistryConfig("test://1.2.3.4"));
4647
ApplicationModel.getConfigManager().addProtocol(new ProtocolConfig("injvm"));

dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,27 @@
5353
import org.springframework.beans.factory.BeanCreationException;
5454
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
5555
import org.springframework.context.support.ClassPathXmlApplicationContext;
56+
import org.springframework.test.annotation.DirtiesContext;
5657

5758
import java.util.Collection;
5859
import java.util.List;
5960

6061
import static org.apache.dubbo.common.constants.CommonConstants.GENERIC_SERIALIZATION_BEAN;
6162
import static org.apache.dubbo.rpc.Constants.GENERIC_KEY;
6263
import static org.hamcrest.MatcherAssert.assertThat;
64+
import static org.hamcrest.Matchers.containsString;
65+
import static org.junit.jupiter.api.Assertions.assertEquals;
6366
import static org.junit.jupiter.api.Assertions.assertNotNull;
6467
import static org.junit.jupiter.api.Assertions.assertNull;
65-
import static org.junit.jupiter.api.Assertions.assertEquals;
6668
import static org.junit.jupiter.api.Assertions.assertTrue;
67-
import static org.junit.jupiter.api.Assertions.fail ;
68-
import static org.hamcrest.Matchers.containsString;
69+
import static org.junit.jupiter.api.Assertions.fail;
6970

7071

7172
/**
7273
* ConfigTest
7374
*/
7475
@Disabled
76+
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
7577
public class ConfigTest {
7678

7779
@Test

dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ServiceBeanTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020

2121
import org.hamcrest.MatcherAssert;
2222
import org.junit.jupiter.api.Test;
23+
import org.springframework.test.annotation.DirtiesContext;
2324

2425
import static org.hamcrest.CoreMatchers.not;
2526
import static org.hamcrest.CoreMatchers.nullValue;
2627
import static org.mockito.Mockito.mock;
2728

29+
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
2830
public class ServiceBeanTest {
2931
@Test
3032
public void testGetService() {

dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/AnnotationPropertyValuesAdapterTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.springframework.core.convert.converter.Converter;
2929
import org.springframework.core.convert.support.DefaultConversionService;
3030
import org.springframework.mock.env.MockEnvironment;
31+
import org.springframework.test.annotation.DirtiesContext;
3132
import org.springframework.util.ReflectionUtils;
3233
import org.springframework.validation.DataBinder;
3334

@@ -42,6 +43,7 @@
4243
*
4344
* @since 2.5.11
4445
*/
46+
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
4547
public class AnnotationPropertyValuesAdapterTest {
4648

4749
@Test

dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/DubboReferenceGenericTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818

1919
import org.apache.dubbo.config.annotation.DubboReference;
2020
import org.apache.dubbo.config.spring.api.HelloService;
21+
2122
import org.junit.jupiter.api.Test;
2223
import org.junit.jupiter.api.extension.ExtendWith;
2324
import org.springframework.beans.factory.annotation.Autowired;
2425
import org.springframework.context.annotation.Bean;
26+
import org.springframework.test.annotation.DirtiesContext;
2527
import org.springframework.test.context.ContextConfiguration;
2628
import org.springframework.test.context.TestPropertySource;
2729
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -46,6 +48,7 @@
4648
"consumer.version = ${demo.service.version}",
4749
"consumer.url = dubbo://127.0.0.1:12345?version=2.5.7",
4850
})
51+
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
4952
public class DubboReferenceGenericTest {
5053

5154
@Bean

dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/MergedAnnotationTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
import org.junit.jupiter.api.Assertions;
2626
import org.junit.jupiter.api.Test;
2727
import org.springframework.core.annotation.AnnotatedElementUtils;
28+
import org.springframework.test.annotation.DirtiesContext;
2829
import org.springframework.util.ReflectionUtils;
2930

3031
import java.lang.reflect.Field;
3132

33+
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
3234
public class MergedAnnotationTest {
3335

3436
@Test

dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceAnnotationBeanPostProcessorTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.dubbo.config.spring.api.HelloService;
2424
import org.apache.dubbo.config.utils.ReferenceConfigCache;
2525
import org.apache.dubbo.rpc.model.ApplicationModel;
26+
2627
import org.aspectj.lang.ProceedingJoinPoint;
2728
import org.aspectj.lang.annotation.Around;
2829
import org.aspectj.lang.annotation.Aspect;
@@ -39,6 +40,7 @@
3940
import org.springframework.context.annotation.Bean;
4041
import org.springframework.context.annotation.EnableAspectJAutoProxy;
4142
import org.springframework.stereotype.Component;
43+
import org.springframework.test.annotation.DirtiesContext;
4244
import org.springframework.test.context.ContextConfiguration;
4345
import org.springframework.test.context.TestPropertySource;
4446
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -67,6 +69,7 @@
6769
"consumer.url = dubbo://127.0.0.1:12345?version=2.5.7",
6870
})
6971
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
72+
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
7073
public class ReferenceAnnotationBeanPostProcessorTest {
7174

7275
@BeforeAll

dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ReferenceBeanBuilderTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.apache.dubbo.config.annotation.Reference;
2222
import org.apache.dubbo.config.spring.ReferenceBean;
2323
import org.apache.dubbo.rpc.model.ApplicationModel;
24+
2425
import org.junit.jupiter.api.Assertions;
2526
import org.junit.jupiter.api.BeforeAll;
2627
import org.junit.jupiter.api.Test;
@@ -29,6 +30,7 @@
2930
import org.springframework.context.ApplicationContext;
3031
import org.springframework.core.annotation.AnnotationAttributes;
3132
import org.springframework.core.annotation.AnnotationUtils;
33+
import org.springframework.test.annotation.DirtiesContext;
3234
import org.springframework.test.context.ContextConfiguration;
3335
import org.springframework.test.context.junit.jupiter.SpringExtension;
3436

@@ -50,6 +52,7 @@
5052
*/
5153
@ExtendWith(SpringExtension.class)
5254
@ContextConfiguration(classes = ReferenceBeanBuilderTest.class)
55+
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
5356
public class ReferenceBeanBuilderTest {
5457

5558
@DubboReference(

dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/ServiceAnnotationBeanPostProcessorTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.apache.dubbo.config.spring.ServiceBean;
2020
import org.apache.dubbo.config.spring.api.HelloService;
2121
import org.apache.dubbo.rpc.model.ApplicationModel;
22+
2223
import org.junit.jupiter.api.AfterEach;
2324
import org.junit.jupiter.api.Assertions;
2425
import org.junit.jupiter.api.BeforeEach;
@@ -28,6 +29,7 @@
2829
import org.springframework.beans.factory.annotation.Value;
2930
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
3031
import org.springframework.context.annotation.Bean;
32+
import org.springframework.test.annotation.DirtiesContext;
3133
import org.springframework.test.context.ContextConfiguration;
3234
import org.springframework.test.context.TestPropertySource;
3335
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -49,6 +51,7 @@
4951
"provider.package = org.apache.dubbo.config.spring.context.annotation.provider",
5052
"packagesToScan = ${provider.package}",
5153
})
54+
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
5255
public class ServiceAnnotationBeanPostProcessorTest {
5356

5457
@BeforeEach

0 commit comments

Comments
 (0)