Skip to content
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
117 changes: 63 additions & 54 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,28 @@
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.test.skip>false</maven.test.skip>
<maven.deploy.skip>false</maven.deploy.skip>
<maven.deploy.version>3.0.0</maven.deploy.version>
<maven.shade.version>3.5.0</maven.shade.version>
<maven.source.version>3.0.1</maven.source.version>
<maven.exec.version>3.0.1</maven.exec.version>
<maven.jar.version>3.1.2</maven.jar.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.version>3.7.0</maven.compiler.version>
<maven.gpg.version>3.1.0</maven.gpg.version>
<maven.compiler.release>17</maven.compiler.release>

<maven.test.skip>false</maven.test.skip>
<maven.ignore.testfailure>false</maven.ignore.testfailure>
<maven.surefire.version>3.1.2</maven.surefire.version>
<maven.javadoc.version>3.0.1</maven.javadoc.version>
<maven.deploy.skip>false</maven.deploy.skip>
<maven.compiler.version>3.11.0</maven.compiler.version>
<maven.surefire.version>3.0.0-M9</maven.surefire.version>
<maven.failsafe.version>3.0.0-M9</maven.failsafe.version>
<maven.jar.version>3.3.0</maven.jar.version>
<maven.source.version>3.3.0</maven.source.version>
<maven.javadoc.version>3.5.0</maven.javadoc.version>
<maven.deploy.version>3.1.1</maven.deploy.version>
<maven.shade.version>3.4.1</maven.shade.version>
<maven.exec.version>3.1.0</maven.exec.version>
<maven.gpg.version>3.1.0</maven.gpg.version>

<jacoco.version>0.8.11</jacoco.version>
<central-publishing-maven-plugin.version>0.7.0</central-publishing-maven-plugin.version>
<exec.maven.version>3.1.0</exec.maven.version>
<junit.version>5.14.2</junit.version>
<file.encoding>UTF-8</file.encoding>
</properties>

Expand All @@ -124,46 +130,19 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.9.3</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
<!-- 保留 JUnit 4 测试 -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.powermock</groupId>-->
<!-- <artifactId>powermock-module-junit4</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.powermock</groupId>-->
<!-- <artifactId>powermock-api-mockito2</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.powermock</groupId>-->
<!-- <artifactId>powermock-api-support</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.powermock</groupId>-->
<!-- <artifactId>powermock-module-junit4-rule</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<version>0.8.11</version>
<version>${jacoco.version}</version>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
Expand Down Expand Up @@ -199,14 +178,14 @@
<argLine>
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.io=ALL-UNNAMED
</argLine>
<testFailureIgnore>${maven.ignore.testfailure}</testFailureIgnore>
<skipTests>false</skipTests>
<systemPropertyVariables>
<jacoco-agent.destfile>${project.build.directory}/coverage.exec
</jacoco-agent.destfile>
</systemPropertyVariables>
<reportsDirectory>../../site/junit</reportsDirectory>
<useSystemClassLoader>false</useSystemClassLoader>
<forkCount>1</forkCount>
<reuseForks>true</reuseForks>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -272,22 +251,22 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.8</version>
<version>${jacoco.version}</version>
<configuration>
<skip>false</skip>
<destFile>${project.build.directory}/coverage.exec</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>default-instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
<execution>
<id>default-restore-instrumented-classes</id>
<id>prepare-agent</id>
<goals>
<goal>restore-instrumented-classes</goal>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefireArgLine</propertyName>
<destFile>${project.build.directory}/coverage.exec</destFile>
</configuration>
</execution>
<execution>
<id>report</id>
Expand All @@ -300,13 +279,39 @@
<outputDirectory>../../site/${project.artifactId}</outputDirectory>
</configuration>
</execution>
<execution>
<id>aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec.maven.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven.failsafe.version}</version>
<configuration>
<argLine>
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
</argLine>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>

Expand All @@ -327,6 +332,10 @@
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;


/**
Expand All @@ -31,7 +31,7 @@ public class YamlUtilsTest {

private YamlUtils yamlUtils;

@Before
@BeforeEach
public void setUp() throws Exception {
this.properties = new HashMap<>();
properties.put("string", "string");
Expand All @@ -41,72 +41,72 @@ public void setUp() throws Exception {
this.yamlUtils = new YamlUtils("");
}

@After
@AfterEach
public void tearDown() throws Exception {
properties.clear();
}

@Test
public void testGetString() {
String string = yamlUtils.getString(properties, "string");
Assert.assertEquals("string", string);
Assertions.assertEquals("string", string);

properties.put("string", null);

try {
yamlUtils.getString(properties, "string");
} catch (Exception e) {
Assert.assertTrue(e instanceof IllegalArgumentException);
Assertions.assertTrue(e instanceof IllegalArgumentException);
}
}

@Test
public void testGetInteger() {
int integer = yamlUtils.getInteger(properties, "integer");
Assert.assertEquals(integer, 10);
Assertions.assertEquals(integer, 10);

properties.put("integer", null);

try {
yamlUtils.getInteger(properties, "integer");
} catch (Exception e) {
Assert.assertTrue(e instanceof IllegalArgumentException);
Assertions.assertTrue(e instanceof IllegalArgumentException);
}
}

@Test
public void testGetBoolean() {
boolean bool = yamlUtils.getBoolean(properties, "boolean");
Assert.assertTrue(bool);
Assertions.assertTrue(bool);

properties.put("boolean", null);
try {
yamlUtils.getBoolean(properties, "boolean");
} catch (Exception e) {
Assert.assertTrue(e instanceof IllegalArgumentException);
Assertions.assertTrue(e instanceof IllegalArgumentException);
}
}

@Test
public void testGetCollection() {
Collection collection = yamlUtils.getCollection(properties, "collection");
Assert.assertNotNull(collection);
Assertions.assertNotNull(collection);
properties.put("collection", null);
try {
yamlUtils.getBoolean(properties, "collection");
} catch (Exception e) {
Assert.assertTrue(e instanceof IllegalArgumentException);
Assertions.assertTrue(e instanceof IllegalArgumentException);
}
}

@Test
public void testGetStringList() {
List<String> collection = yamlUtils.getStringList(properties, "collection");
Assert.assertNotNull(collection);
Assertions.assertNotNull(collection);
try {
yamlUtils.requireMap(Arrays.asList(1, 2), "key");
} catch (Exception e) {
Assert.assertTrue(e instanceof IllegalArgumentException);
Assertions.assertTrue(e instanceof IllegalArgumentException);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

import com.tencent.trpc.container.config.ApplicationConfigParser;
import com.tencent.trpc.core.extension.ExtensionLoader;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class EnvironmentConfigurationTest {

private Environment environment;

@Before
@BeforeEach

Check warning on line 14 in trpc-container/trpc-container-default/src/test/java/com/tencent/trpc/container/config/system/EnvironmentConfigurationTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] reported by reviewdog 🐶 缺少 Javadoc 。 Raw Output: /github/workspace/./trpc-container/trpc-container-default/src/test/java/com/tencent/trpc/container/config/system/EnvironmentConfigurationTest.java:14:5: info: 缺少 Javadoc 。 (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
public void init() {
System.setProperty("global.namespace", "${env_type_enhancer}");
System.setProperty("server.app", "wechat");
Expand All @@ -34,7 +34,7 @@
environment = new Environment(parser);
}

@After
@AfterEach

Check warning on line 37 in trpc-container/trpc-container-default/src/test/java/com/tencent/trpc/container/config/system/EnvironmentConfigurationTest.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] reported by reviewdog 🐶 缺少 Javadoc 。 Raw Output: /github/workspace/./trpc-container/trpc-container-default/src/test/java/com/tencent/trpc/container/config/system/EnvironmentConfigurationTest.java:37:5: info: 缺少 Javadoc 。 (com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck)
public void teardown() {
System.clearProperty("global.namespace");
System.clearProperty("server.app");
Expand All @@ -57,6 +57,6 @@
@Test
public void testGetInternalProperty() {
Object internalProperty = environment.getInternalProperty("server.app");
Assert.assertEquals(internalProperty, "wechat");
Assertions.assertEquals(internalProperty, "wechat");
}
}
}
Loading
Loading