From 9e249cfd846a673aba365e1a42f85950f71bd433 Mon Sep 17 00:00:00 2001
From: strangelookingnerd
<49242855+strangelookingnerd@users.noreply.github.com>
Date: Sat, 23 Nov 2024 09:22:17 +0100
Subject: [PATCH] Migrate tests to JUnit5 (#14922)
* Migrate tests to JUnit5
* remove spring default qos-enable
---
dubbo-dependencies-bom/pom.xml | 13 ----
.../pom.xml | 6 --
...dpointAnnotationAutoConfigurationTest.java | 77 ++++++++++---------
.../health/DubboHealthIndicatorTest.java | 31 ++++----
.../actuate/endpoint/DubboEndpointTest.java | 24 +++---
.../dubbo-spring-boot-autoconfigure/pom.xml | 6 --
.../apache/dubbo/spring/boot/TestSuite.java | 34 --------
.../BinderDubboConfigBinderTest.java | 18 ++---
.../CompatibleDubboAutoConfigurationTest.java | 21 ++---
...utoConfigurationTestWithoutProperties.java | 32 ++++----
...oRelaxedBinding2AutoConfigurationTest.java | 14 ++--
...AutoConfigurationOnMultipleConfigTest.java | 47 +++++------
...boAutoConfigurationOnSingleConfigTest.java | 43 ++++++-----
...ropertiesEnvironmentPostProcessorTest.java | 26 ++++---
.../dubbo-spring-boot/pom.xml | 6 --
.../apache/dubbo/spring/boot/TestSuite.java | 36 ---------
...AwaitingNonWebApplicationListenerTest.java | 28 +++----
...nitionConflictApplicationListenerTest.java | 29 +++----
.../WelcomeLogoApplicationListenerTest.java | 17 ++--
...ropertiesEnvironmentPostProcessorTest.java | 32 ++++----
.../spring/boot/util/DubboUtilsTest.java | 45 +++++------
21 files changed, 251 insertions(+), 334 deletions(-)
delete mode 100644 dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/TestSuite.java
delete mode 100644 dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/TestSuite.java
diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml
index 94817b7131e..7a2f10018e5 100644
--- a/dubbo-dependencies-bom/pom.xml
+++ b/dubbo-dependencies-bom/pom.xml
@@ -158,7 +158,6 @@
5.11.3
1.11.3
- 4.13.2
4.2.2
2.2
2.2.2
@@ -775,18 +774,6 @@
${junit_jupiter_version}
test
-
- org.junit.vintage
- junit-vintage-engine
- ${junit_jupiter_version}
- test
-
-
- junit
- junit
- ${junit_version}
- test
-
org.awaitility
awaitility
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-actuator-autoconfigure/pom.xml b/dubbo-spring-boot-project/dubbo-spring-boot-actuator-autoconfigure/pom.xml
index b7330156eef..27d7f6f39e7 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot-actuator-autoconfigure/pom.xml
+++ b/dubbo-spring-boot-project/dubbo-spring-boot-actuator-autoconfigure/pom.xml
@@ -119,12 +119,6 @@
test
-
-
- org.junit.vintage
- junit-vintage-engine
- test
-
net.bytebuddy
byte-buddy
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-actuator-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java b/dubbo-spring-boot-project/dubbo-spring-boot-actuator-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java
index 03504a09d1f..7b7b2c964e6 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot-actuator-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot-actuator-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/actuate/autoconfigure/DubboEndpointAnnotationAutoConfigurationTest.java
@@ -33,7 +33,6 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.junit.Assert;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
@@ -47,6 +46,11 @@
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.web.client.RestTemplate;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* {@link DubboEndpointAnnotationAutoConfiguration} Test
*
@@ -112,12 +116,12 @@ class DubboEndpointAnnotationAutoConfigurationTest {
private String actuatorBaseURL;
@BeforeEach
- public void init() {
+ void init() {
DubboBootstrap.reset();
}
@AfterEach
- public void destroy() {
+ void destroy() {
DubboBootstrap.reset();
}
@@ -128,10 +132,10 @@ void testShutdown() throws Exception {
Map shutdownCounts = (Map) value.get("shutdown.count");
- Assert.assertEquals(0, shutdownCounts.get("registries"));
- Assert.assertEquals(1, shutdownCounts.get("protocols"));
- Assert.assertEquals(1, shutdownCounts.get("services"));
- Assert.assertEquals(0, shutdownCounts.get("references"));
+ assertEquals(0, shutdownCounts.get("registries"));
+ assertEquals(1, shutdownCounts.get("protocols"));
+ assertEquals(1, shutdownCounts.get("services"));
+ assertEquals(0, shutdownCounts.get("references"));
}
@Test
@@ -140,35 +144,35 @@ void testConfigs() {
Map>> configsMap = dubboConfigsMetadataEndpoint.configs();
Map> beansMetadata = configsMap.get("ApplicationConfig");
- Assert.assertEquals(
+ assertEquals(
"dubbo-demo-application", beansMetadata.get("my-application").get("name"));
beansMetadata = configsMap.get("ConsumerConfig");
- Assert.assertTrue(beansMetadata.isEmpty());
+ assertTrue(beansMetadata.isEmpty());
beansMetadata = configsMap.get("MethodConfig");
- Assert.assertTrue(beansMetadata.isEmpty());
+ assertTrue(beansMetadata.isEmpty());
beansMetadata = configsMap.get("ModuleConfig");
- Assert.assertEquals("dubbo-demo-module", beansMetadata.get("my-module").get("name"));
+ assertEquals("dubbo-demo-module", beansMetadata.get("my-module").get("name"));
beansMetadata = configsMap.get("MonitorConfig");
- Assert.assertTrue(beansMetadata.isEmpty());
+ assertTrue(beansMetadata.isEmpty());
beansMetadata = configsMap.get("ProtocolConfig");
- Assert.assertEquals("dubbo", beansMetadata.get("my-protocol").get("name"));
+ assertEquals("dubbo", beansMetadata.get("my-protocol").get("name"));
beansMetadata = configsMap.get("ProviderConfig");
- Assert.assertEquals("127.0.0.1", beansMetadata.get("my-provider").get("host"));
+ assertEquals("127.0.0.1", beansMetadata.get("my-provider").get("host"));
beansMetadata = configsMap.get("ReferenceConfig");
- Assert.assertTrue(beansMetadata.isEmpty());
+ assertTrue(beansMetadata.isEmpty());
beansMetadata = configsMap.get("RegistryConfig");
- Assert.assertEquals("N/A", beansMetadata.get("my-registry").get("address"));
+ assertEquals("N/A", beansMetadata.get("my-registry").get("address"));
beansMetadata = configsMap.get("ServiceConfig");
- Assert.assertFalse(beansMetadata.isEmpty());
+ assertFalse(beansMetadata.isEmpty());
}
@Test
@@ -176,12 +180,12 @@ void testServices() {
Map> services = dubboServicesMetadataEndpoint.services();
- Assert.assertEquals(1, services.size());
+ assertEquals(1, services.size());
Map demoServiceMeta = services.get(
"ServiceBean:org.apache.dubbo.spring.boot.actuate.autoconfigure.DubboEndpointAnnotationAutoConfigurationTest$DemoService:1.0.0:");
- Assert.assertEquals("1.0.0", demoServiceMeta.get("version"));
+ assertEquals("1.0.0", demoServiceMeta.get("version"));
}
@Test
@@ -189,13 +193,13 @@ void testReferences() {
Map> references = dubboReferencesMetadataEndpoint.references();
- Assert.assertTrue(!references.isEmpty());
+ assertFalse(references.isEmpty());
String injectedField =
"private " + DemoService.class.getName() + " " + ConsumerConfiguration.class.getName() + ".demoService";
Map referenceMap = references.get(injectedField);
- Assert.assertNotNull(referenceMap);
- Assert.assertEquals(DemoService.class, referenceMap.get("interfaceClass"));
- Assert.assertEquals(
+ assertNotNull(referenceMap);
+ assertEquals(DemoService.class, referenceMap.get("interfaceClass"));
+ assertEquals(
BaseServiceMetadata.buildServiceKey(
DemoService.class.getName(),
ConsumerConfiguration.DEMO_GROUP,
@@ -208,19 +212,18 @@ void testProperties() {
SortedMap properties = dubboPropertiesEndpoint.properties();
- Assert.assertEquals("my-application", properties.get("dubbo.application.id"));
- Assert.assertEquals("dubbo-demo-application", properties.get("dubbo.application.name"));
- Assert.assertEquals("my-module", properties.get("dubbo.module.id"));
- Assert.assertEquals("dubbo-demo-module", properties.get("dubbo.module.name"));
- Assert.assertEquals("my-registry", properties.get("dubbo.registry.id"));
- Assert.assertEquals("N/A", properties.get("dubbo.registry.address"));
- Assert.assertEquals("my-protocol", properties.get("dubbo.protocol.id"));
- Assert.assertEquals("dubbo", properties.get("dubbo.protocol.name"));
- Assert.assertEquals("20880", properties.get("dubbo.protocol.port"));
- Assert.assertEquals("my-provider", properties.get("dubbo.provider.id"));
- Assert.assertEquals("127.0.0.1", properties.get("dubbo.provider.host"));
- Assert.assertEquals(
- "org.apache.dubbo.spring.boot.actuate.autoconfigure", properties.get("dubbo.scan.basePackages"));
+ assertEquals("my-application", properties.get("dubbo.application.id"));
+ assertEquals("dubbo-demo-application", properties.get("dubbo.application.name"));
+ assertEquals("my-module", properties.get("dubbo.module.id"));
+ assertEquals("dubbo-demo-module", properties.get("dubbo.module.name"));
+ assertEquals("my-registry", properties.get("dubbo.registry.id"));
+ assertEquals("N/A", properties.get("dubbo.registry.address"));
+ assertEquals("my-protocol", properties.get("dubbo.protocol.id"));
+ assertEquals("dubbo", properties.get("dubbo.protocol.name"));
+ assertEquals("20880", properties.get("dubbo.protocol.port"));
+ assertEquals("my-provider", properties.get("dubbo.provider.id"));
+ assertEquals("127.0.0.1", properties.get("dubbo.provider.host"));
+ assertEquals("org.apache.dubbo.spring.boot.actuate.autoconfigure", properties.get("dubbo.scan.basePackages"));
}
@Test
@@ -235,7 +238,7 @@ void testHttpEndpoints() throws JsonProcessingException {
private void testHttpEndpoint(String actuatorURI, Supplier
-
-
- org.junit.vintage
- junit-vintage-engine
- test
-
net.bytebuddy
byte-buddy
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/TestSuite.java b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/TestSuite.java
deleted file mode 100644
index b0e2d5863d5..00000000000
--- a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/TestSuite.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.spring.boot;
-
-import org.apache.dubbo.spring.boot.autoconfigure.CompatibleDubboAutoConfigurationTest;
-import org.apache.dubbo.spring.boot.autoconfigure.CompatibleDubboAutoConfigurationTestWithoutProperties;
-import org.apache.dubbo.spring.boot.autoconfigure.base.DubboAutoConfigurationOnMultipleConfigTest;
-import org.apache.dubbo.spring.boot.autoconfigure.base.DubboAutoConfigurationOnSingleConfigTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- CompatibleDubboAutoConfigurationTest.class,
- CompatibleDubboAutoConfigurationTestWithoutProperties.class,
- DubboAutoConfigurationOnMultipleConfigTest.class,
- DubboAutoConfigurationOnSingleConfigTest.class
-})
-public class TestSuite {}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinderTest.java b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinderTest.java
index a81a187d729..b12c37c6af4 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinderTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/BinderDubboConfigBinderTest.java
@@ -23,23 +23,23 @@
import java.util.Map;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.apache.dubbo.config.spring.util.PropertySourcesUtils.getSubProperties;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* {@link BinderDubboConfigBinder} Test
*
* @since 2.7.0
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@TestPropertySource(locations = "classpath:/dubbo.properties")
@ContextConfiguration(classes = BinderDubboConfigBinder.class)
class BinderDubboConfigBinderTest {
@@ -56,17 +56,17 @@ void testBinder() {
ApplicationConfig applicationConfig = new ApplicationConfig();
Map properties = getSubProperties(environment.getPropertySources(), "dubbo.application");
dubboConfigBinder.bind(properties, true, true, applicationConfig);
- Assert.assertEquals("hello", applicationConfig.getName());
- Assert.assertEquals("world", applicationConfig.getOwner());
+ assertEquals("hello", applicationConfig.getName());
+ assertEquals("world", applicationConfig.getOwner());
RegistryConfig registryConfig = new RegistryConfig();
properties = getSubProperties(environment.getPropertySources(), "dubbo.registry");
dubboConfigBinder.bind(properties, true, true, registryConfig);
- Assert.assertEquals("10.20.153.17", registryConfig.getAddress());
+ assertEquals("10.20.153.17", registryConfig.getAddress());
ProtocolConfig protocolConfig = new ProtocolConfig();
properties = getSubProperties(environment.getPropertySources(), "dubbo.protocol");
dubboConfigBinder.bind(properties, true, true, protocolConfig);
- Assert.assertEquals(Integer.valueOf(20881), protocolConfig.getPort());
+ assertEquals(Integer.valueOf(20881), protocolConfig.getPort());
}
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTest.java b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTest.java
index ced20cf1172..93c04b413ce 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTest.java
@@ -20,28 +20,29 @@
import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationPostProcessor;
import org.apache.dubbo.config.spring.util.DubboBeanUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.PropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* {@link DubboAutoConfiguration} Test
* @see DubboAutoConfiguration
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(
classes = {CompatibleDubboAutoConfigurationTest.class},
properties = {"dubbo.scan.base-packages = org.apache.dubbo.spring.boot.autoconfigure"})
@EnableAutoConfiguration
@PropertySource(value = "classpath:/META-INF/dubbo.properties")
-public class CompatibleDubboAutoConfigurationTest {
+class CompatibleDubboAutoConfigurationTest {
@Autowired
private ObjectProvider serviceAnnotationPostProcessor;
@@ -50,12 +51,12 @@ public class CompatibleDubboAutoConfigurationTest {
private ApplicationContext applicationContext;
@Test
- public void testBeans() {
- Assert.assertNotNull(serviceAnnotationPostProcessor);
- Assert.assertNotNull(serviceAnnotationPostProcessor.getIfAvailable());
+ void testBeans() {
+ assertNotNull(serviceAnnotationPostProcessor);
+ assertNotNull(serviceAnnotationPostProcessor.getIfAvailable());
ReferenceAnnotationBeanPostProcessor referenceAnnotationBeanPostProcessor =
DubboBeanUtils.getReferenceAnnotationBeanPostProcessor(applicationContext);
- Assert.assertNotNull(referenceAnnotationBeanPostProcessor);
+ assertNotNull(referenceAnnotationBeanPostProcessor);
}
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTestWithoutProperties.java b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTestWithoutProperties.java
index 746b759c7c6..1aa78f7004c 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTestWithoutProperties.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/CompatibleDubboAutoConfigurationTestWithoutProperties.java
@@ -21,28 +21,30 @@
import org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationPostProcessor;
import org.apache.dubbo.config.spring.util.DubboBeanUtils;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
/**
* {@link DubboAutoConfiguration} Test
*
* @see DubboAutoConfiguration
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(
classes = CompatibleDubboAutoConfigurationTestWithoutProperties.class,
properties = {"dubbo.application.name=demo"})
@EnableAutoConfiguration
-public class CompatibleDubboAutoConfigurationTestWithoutProperties {
+class CompatibleDubboAutoConfigurationTestWithoutProperties {
@Autowired(required = false)
private ServiceAnnotationPostProcessor serviceAnnotationPostProcessor;
@@ -50,22 +52,22 @@ public class CompatibleDubboAutoConfigurationTestWithoutProperties {
@Autowired
private ApplicationContext applicationContext;
- @Before
- public void init() {
+ @BeforeEach
+ void init() {
DubboBootstrap.reset();
}
- @After
- public void destroy() {
+ @AfterEach
+ void destroy() {
DubboBootstrap.reset();
}
@Test
- public void testBeans() {
- Assert.assertNull(serviceAnnotationPostProcessor);
+ void testBeans() {
+ assertNull(serviceAnnotationPostProcessor);
ReferenceAnnotationBeanPostProcessor referenceAnnotationBeanPostProcessor =
DubboBeanUtils.getReferenceAnnotationBeanPostProcessor(applicationContext);
- Assert.assertNotNull(referenceAnnotationBeanPostProcessor);
+ assertNotNull(referenceAnnotationBeanPostProcessor);
}
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfigurationTest.java b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfigurationTest.java
index 8faa1bbd1ab..0cc4dfe26bb 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfigurationTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/DubboRelaxedBinding2AutoConfigurationTest.java
@@ -24,8 +24,8 @@
import java.util.Map;
import java.util.Set;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -34,19 +34,19 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.util.ClassUtils;
import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_BEAN_NAME;
import static org.apache.dubbo.spring.boot.util.DubboUtils.RELAXED_DUBBO_CONFIG_BINDER_BEAN_NAME;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* {@link DubboRelaxedBinding2AutoConfiguration} Test
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(
classes = DubboRelaxedBinding2AutoConfigurationTest.class,
properties = {"dubbo.scan.basePackages = org.apache.dubbo.spring.boot.autoconfigure"})
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/base/DubboAutoConfigurationOnMultipleConfigTest.java b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/base/DubboAutoConfigurationOnMultipleConfigTest.java
index dd0683efddf..e5e2031c62e 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/base/DubboAutoConfigurationOnMultipleConfigTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/base/DubboAutoConfigurationOnMultipleConfigTest.java
@@ -26,25 +26,26 @@
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* {@link DubboAutoConfiguration} Test On multiple Dubbo Configuration
*
* @since 2.7.0
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@TestPropertySource(
properties = {
"dubbo.applications.application1.name=dubbo-demo-multi-application",
@@ -61,7 +62,7 @@
@SpringBootTest(classes = {DubboAutoConfigurationOnMultipleConfigTest.class})
@EnableAutoConfiguration
@ComponentScan
-public class DubboAutoConfigurationOnMultipleConfigTest {
+class DubboAutoConfigurationOnMultipleConfigTest {
/**
* @see TestBeansConfiguration
@@ -94,34 +95,34 @@ public class DubboAutoConfigurationOnMultipleConfigTest {
@Qualifier("provider1")
ProviderConfig provider;
- @Before
- public void init() {
+ @BeforeEach
+ void init() {
DubboBootstrap.reset();
}
- @After
- public void destroy() {
+ @AfterEach
+ void destroy() {
DubboBootstrap.reset();
}
@Test
- public void testMultiConfig() {
+ void testMultiConfig() {
// application
- Assert.assertEquals("dubbo-demo-multi-application", application.getName());
+ assertEquals("dubbo-demo-multi-application", application.getName());
// module
- Assert.assertEquals("dubbo-demo-module", module.getName());
+ assertEquals("dubbo-demo-module", module.getName());
// registry
- Assert.assertEquals("test://192.168.99.100:32770", registry.getAddress());
- Assert.assertEquals("test", registry.getProtocol());
- Assert.assertEquals(Integer.valueOf(32770), registry.getPort());
+ assertEquals("test://192.168.99.100:32770", registry.getAddress());
+ assertEquals("test", registry.getProtocol());
+ assertEquals(Integer.valueOf(32770), registry.getPort());
// monitor
- Assert.assertEquals("test://127.0.0.1:32770", monitor.getAddress());
+ assertEquals("test://127.0.0.1:32770", monitor.getAddress());
// protocol
- Assert.assertEquals("dubbo", protocol.getName());
- Assert.assertEquals(Integer.valueOf(20880), protocol.getPort());
+ assertEquals("dubbo", protocol.getName());
+ assertEquals(Integer.valueOf(20880), protocol.getPort());
// consumer
- Assert.assertEquals("netty", consumer.getClient());
+ assertEquals("netty", consumer.getClient());
// provider
- Assert.assertEquals("127.0.0.1", provider.getHost());
+ assertEquals("127.0.0.1", provider.getHost());
}
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/base/DubboAutoConfigurationOnSingleConfigTest.java b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/base/DubboAutoConfigurationOnSingleConfigTest.java
index ba8224bd694..fe8eb6149ff 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/base/DubboAutoConfigurationOnSingleConfigTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/autoconfigure/base/DubboAutoConfigurationOnSingleConfigTest.java
@@ -26,24 +26,25 @@
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.spring.boot.autoconfigure.DubboAutoConfiguration;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* {@link DubboAutoConfiguration} Test On single Dubbo Configuration
*
* @since 2.7.0
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@TestPropertySource(
properties = {
"dubbo.application.name = dubbo-demo-single-application",
@@ -58,7 +59,7 @@
@SpringBootTest(classes = {DubboAutoConfigurationOnSingleConfigTest.class})
@EnableAutoConfiguration
@ComponentScan
-public class DubboAutoConfigurationOnSingleConfigTest {
+class DubboAutoConfigurationOnSingleConfigTest {
@Autowired
private ApplicationConfig applicationConfig;
@@ -81,32 +82,32 @@ public class DubboAutoConfigurationOnSingleConfigTest {
@Autowired
private ProtocolConfig protocolConfig;
- @Before
- public void init() {
+ @BeforeEach
+ void init() {
DubboBootstrap.reset();
}
- @After
- public void destroy() {
+ @AfterEach
+ void destroy() {
DubboBootstrap.reset();
}
@Test
- public void testSingleConfig() {
+ void testSingleConfig() {
// application
- Assert.assertEquals("dubbo-demo-single-application", applicationConfig.getName());
+ assertEquals("dubbo-demo-single-application", applicationConfig.getName());
// module
- Assert.assertEquals("dubbo-demo-module", moduleConfig.getName());
+ assertEquals("dubbo-demo-module", moduleConfig.getName());
// registry
- Assert.assertEquals("test://192.168.99.100:32770", registryConfig.getAddress());
+ assertEquals("test://192.168.99.100:32770", registryConfig.getAddress());
// monitor
- Assert.assertEquals("test://127.0.0.1:32770", monitorConfig.getAddress());
+ assertEquals("test://127.0.0.1:32770", monitorConfig.getAddress());
// protocol
- Assert.assertEquals("dubbo", protocolConfig.getName());
- Assert.assertEquals(Integer.valueOf(20880), protocolConfig.getPort());
+ assertEquals("dubbo", protocolConfig.getName());
+ assertEquals(Integer.valueOf(20880), protocolConfig.getPort());
// consumer
- Assert.assertEquals("netty", consumerConfig.getClient());
+ assertEquals("netty", consumerConfig.getClient());
// provider
- Assert.assertEquals("127.0.0.1", providerConfig.getHost());
+ assertEquals("127.0.0.1", providerConfig.getHost());
}
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
index cb9963777de..952e5aebb93 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot-autoconfigure/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
@@ -18,8 +18,7 @@
import java.util.HashMap;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.core.Ordered;
import org.springframework.core.env.MapPropertySource;
@@ -27,6 +26,9 @@
import org.springframework.core.env.PropertySource;
import org.springframework.mock.env.MockEnvironment;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
/**
* {@link DubboDefaultPropertiesEnvironmentPostProcessor} Test
*/
@@ -39,7 +41,7 @@ class DubboDefaultPropertiesEnvironmentPostProcessorTest {
@Test
void testOrder() {
- Assert.assertEquals(Ordered.LOWEST_PRECEDENCE, instance.getOrder());
+ assertEquals(Ordered.LOWEST_PRECEDENCE, instance.getOrder());
}
@Test
@@ -51,16 +53,16 @@ void testPostProcessEnvironment() {
MutablePropertySources propertySources = environment.getPropertySources();
// Nothing to change
PropertySource defaultPropertySource = propertySources.get("defaultProperties");
- Assert.assertNotNull(defaultPropertySource);
- Assert.assertEquals("true", defaultPropertySource.getProperty("dubbo.config.multiple"));
- Assert.assertEquals("true", defaultPropertySource.getProperty("dubbo.application.qos-enable"));
+ assertNotNull(defaultPropertySource);
+ assertEquals("true", defaultPropertySource.getProperty("dubbo.config.multiple"));
+ // assertEquals("true", defaultPropertySource.getProperty("dubbo.application.qos-enable"));
// Case 2 : Only set property "spring.application.name"
environment.setProperty("spring.application.name", "demo-dubbo-application");
instance.postProcessEnvironment(environment, springApplication);
defaultPropertySource = propertySources.get("defaultProperties");
Object dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name");
- Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+ assertEquals("demo-dubbo-application", dubboApplicationName);
// Case 3 : Only set property "dubbo.application.name"
// Reset environment
@@ -69,9 +71,9 @@ void testPostProcessEnvironment() {
environment.setProperty("dubbo.application.name", "demo-dubbo-application");
instance.postProcessEnvironment(environment, springApplication);
defaultPropertySource = propertySources.get("defaultProperties");
- Assert.assertNotNull(defaultPropertySource);
+ assertNotNull(defaultPropertySource);
dubboApplicationName = environment.getProperty("dubbo.application.name");
- Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+ assertEquals("demo-dubbo-application", dubboApplicationName);
// Case 4 : If "defaultProperties" PropertySource is present in PropertySources
// Reset environment
@@ -82,7 +84,7 @@ void testPostProcessEnvironment() {
instance.postProcessEnvironment(environment, springApplication);
defaultPropertySource = propertySources.get("defaultProperties");
dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name");
- Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+ assertEquals("demo-dubbo-application", dubboApplicationName);
// Case 5 : Reset dubbo.config.multiple and dubbo.application.qos-enable
environment = new MockEnvironment();
@@ -91,7 +93,7 @@ void testPostProcessEnvironment() {
environment.setProperty("dubbo.config.multiple", "false");
environment.setProperty("dubbo.application.qos-enable", "false");
instance.postProcessEnvironment(environment, springApplication);
- Assert.assertEquals("false", environment.getProperty("dubbo.config.multiple"));
- Assert.assertEquals("false", environment.getProperty("dubbo.application.qos-enable"));
+ assertEquals("false", environment.getProperty("dubbo.config.multiple"));
+ assertEquals("false", environment.getProperty("dubbo.application.qos-enable"));
}
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot/pom.xml b/dubbo-spring-boot-project/dubbo-spring-boot/pom.xml
index cbf87b03368..8e970abedc9 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot/pom.xml
+++ b/dubbo-spring-boot-project/dubbo-spring-boot/pom.xml
@@ -60,12 +60,6 @@
test
-
-
- org.junit.vintage
- junit-vintage-engine
- test
-
net.bytebuddy
byte-buddy
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/TestSuite.java b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/TestSuite.java
deleted file mode 100644
index 47eb6af7cf0..00000000000
--- a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/TestSuite.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.spring.boot;
-
-import org.apache.dubbo.spring.boot.context.event.AwaitingNonWebApplicationListenerTest;
-import org.apache.dubbo.spring.boot.context.event.DubboConfigBeanDefinitionConflictApplicationListenerTest;
-import org.apache.dubbo.spring.boot.context.event.WelcomeLogoApplicationListenerTest;
-import org.apache.dubbo.spring.boot.env.DubboDefaultPropertiesEnvironmentPostProcessorTest;
-import org.apache.dubbo.spring.boot.util.DubboUtilsTest;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({
- AwaitingNonWebApplicationListenerTest.class,
- DubboConfigBeanDefinitionConflictApplicationListenerTest.class,
- WelcomeLogoApplicationListenerTest.class,
- DubboDefaultPropertiesEnvironmentPostProcessorTest.class,
- DubboUtilsTest.class,
-})
-public class TestSuite {}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java
index 26132270d0e..ef0e5f8500e 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/AwaitingNonWebApplicationListenerTest.java
@@ -18,34 +18,34 @@
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
/**
* {@link AwaitingNonWebApplicationListener} Test
*/
-@Ignore
-public class AwaitingNonWebApplicationListenerTest {
+@Disabled
+class AwaitingNonWebApplicationListenerTest {
- @Before
- public void before() {
+ @BeforeEach
+ void before() {
DubboBootstrap.reset();
}
- @After
- public void after() {
+ @AfterEach
+ void after() {
DubboBootstrap.reset();
}
// @Test
- // public void init() {
+ // void init() {
// AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
// awaited.set(false);
// }
//
// @Test
- // public void testSingleContextNonWebApplication() {
+ // void testSingleContextNonWebApplication() {
// new SpringApplicationBuilder(Object.class)
// .web(false)
// .run()
@@ -53,19 +53,19 @@ public void after() {
//
// ShutdownHookCallbacks.INSTANCE.addCallback(() -> {
// AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
- // Assert.assertTrue(awaited.get());
+ // assertTrue(awaited.get());
// System.out.println("Callback...");
// });
// }
//
// @Test
- // public void testMultipleContextNonWebApplication() {
+ // void testMultipleContextNonWebApplication() {
// new SpringApplicationBuilder(Object.class)
// .parent(Object.class)
// .web(false)
// .run().close();
// AtomicBoolean awaited = AwaitingNonWebApplicationListener.getAwaited();
- // Assert.assertFalse(awaited.get());
+ // assertFalse(awaited.get());
// }
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/DubboConfigBeanDefinitionConflictApplicationListenerTest.java b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/DubboConfigBeanDefinitionConflictApplicationListenerTest.java
index 635b9f2b523..c8f0df0a547 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/DubboConfigBeanDefinitionConflictApplicationListenerTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/DubboConfigBeanDefinitionConflictApplicationListenerTest.java
@@ -22,34 +22,35 @@
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.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* {@link DubboConfigBeanDefinitionConflictApplicationListener} Test
*
* @since 2.7.5
*/
-public class DubboConfigBeanDefinitionConflictApplicationListenerTest {
+class DubboConfigBeanDefinitionConflictApplicationListenerTest {
- @Before
- public void init() {
+ @BeforeEach
+ void init() {
DubboBootstrap.reset();
// context.addApplicationListener(new DubboConfigBeanDefinitionConflictApplicationListener());
}
- @After
- public void destroy() {
+ @AfterEach
+ void destroy() {
DubboBootstrap.reset();
}
// @Test
- public void testNormalCase() {
+ void testNormalCase() {
System.setProperty("dubbo.application.name", "test-dubbo-application");
@@ -59,7 +60,7 @@ public void testNormalCase() {
ApplicationConfig applicationConfig = context.getBean(ApplicationConfig.class);
- Assert.assertEquals("test-dubbo-application", applicationConfig.getName());
+ assertEquals("test-dubbo-application", applicationConfig.getName());
} finally {
System.clearProperty("dubbo.application.name");
context.close();
@@ -67,7 +68,7 @@ public void testNormalCase() {
}
@Test
- public void testDuplicatedConfigsCase() {
+ void testDuplicatedConfigsCase() {
AnnotationConfigApplicationContext context =
new AnnotationConfigApplicationContext(PropertySourceConfig.class, DubboConfig.class, XmlConfig.class);
@@ -79,9 +80,9 @@ public void testDuplicatedConfigsCase() {
ApplicationConfig applicationConfig = beansMap.get("dubbo-consumer-2.7.x");
- Assert.assertEquals(1, beansMap.size());
+ assertEquals(1, beansMap.size());
- Assert.assertEquals("dubbo-consumer-2.7.x", applicationConfig.getName());
+ assertEquals("dubbo-consumer-2.7.x", applicationConfig.getName());
} finally {
context.close();
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java
index 893ed17e0e5..02a72d81f81 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/context/event/WelcomeLogoApplicationListenerTest.java
@@ -16,12 +16,13 @@
*/
package org.apache.dubbo.spring.boot.context.event;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
-import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* {@link WelcomeLogoApplicationListener} Test
@@ -29,16 +30,16 @@
* @see WelcomeLogoApplicationListener
* @since 2.7.0
*/
-@RunWith(SpringRunner.class)
+@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = {WelcomeLogoApplicationListener.class})
-public class WelcomeLogoApplicationListenerTest {
+class WelcomeLogoApplicationListenerTest {
@Autowired
private WelcomeLogoApplicationListener welcomeLogoApplicationListener;
@Test
- public void testOnApplicationEvent() {
+ void testOnApplicationEvent() {
- Assert.assertNotNull(welcomeLogoApplicationListener.buildBannerText());
+ assertNotNull(welcomeLogoApplicationListener.buildBannerText());
}
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
index b17c1af6346..952e5aebb93 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/env/DubboDefaultPropertiesEnvironmentPostProcessorTest.java
@@ -18,8 +18,7 @@
import java.util.HashMap;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.boot.SpringApplication;
import org.springframework.core.Ordered;
import org.springframework.core.env.MapPropertySource;
@@ -27,10 +26,13 @@
import org.springframework.core.env.PropertySource;
import org.springframework.mock.env.MockEnvironment;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
/**
* {@link DubboDefaultPropertiesEnvironmentPostProcessor} Test
*/
-public class DubboDefaultPropertiesEnvironmentPostProcessorTest {
+class DubboDefaultPropertiesEnvironmentPostProcessorTest {
private DubboDefaultPropertiesEnvironmentPostProcessor instance =
new DubboDefaultPropertiesEnvironmentPostProcessor();
@@ -38,12 +40,12 @@ public class DubboDefaultPropertiesEnvironmentPostProcessorTest {
private SpringApplication springApplication = new SpringApplication();
@Test
- public void testOrder() {
- Assert.assertEquals(Ordered.LOWEST_PRECEDENCE, instance.getOrder());
+ void testOrder() {
+ assertEquals(Ordered.LOWEST_PRECEDENCE, instance.getOrder());
}
@Test
- public void testPostProcessEnvironment() {
+ void testPostProcessEnvironment() {
MockEnvironment environment = new MockEnvironment();
// Case 1 : Not Any property
instance.postProcessEnvironment(environment, springApplication);
@@ -51,16 +53,16 @@ public void testPostProcessEnvironment() {
MutablePropertySources propertySources = environment.getPropertySources();
// Nothing to change
PropertySource defaultPropertySource = propertySources.get("defaultProperties");
- Assert.assertNotNull(defaultPropertySource);
- Assert.assertEquals("true", defaultPropertySource.getProperty("dubbo.config.multiple"));
- // Assert.assertEquals("true", defaultPropertySource.getProperty("dubbo.application.qos-enable"));
+ assertNotNull(defaultPropertySource);
+ assertEquals("true", defaultPropertySource.getProperty("dubbo.config.multiple"));
+ // assertEquals("true", defaultPropertySource.getProperty("dubbo.application.qos-enable"));
// Case 2 : Only set property "spring.application.name"
environment.setProperty("spring.application.name", "demo-dubbo-application");
instance.postProcessEnvironment(environment, springApplication);
defaultPropertySource = propertySources.get("defaultProperties");
Object dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name");
- Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+ assertEquals("demo-dubbo-application", dubboApplicationName);
// Case 3 : Only set property "dubbo.application.name"
// Reset environment
@@ -69,9 +71,9 @@ public void testPostProcessEnvironment() {
environment.setProperty("dubbo.application.name", "demo-dubbo-application");
instance.postProcessEnvironment(environment, springApplication);
defaultPropertySource = propertySources.get("defaultProperties");
- Assert.assertNotNull(defaultPropertySource);
+ assertNotNull(defaultPropertySource);
dubboApplicationName = environment.getProperty("dubbo.application.name");
- Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+ assertEquals("demo-dubbo-application", dubboApplicationName);
// Case 4 : If "defaultProperties" PropertySource is present in PropertySources
// Reset environment
@@ -82,7 +84,7 @@ public void testPostProcessEnvironment() {
instance.postProcessEnvironment(environment, springApplication);
defaultPropertySource = propertySources.get("defaultProperties");
dubboApplicationName = defaultPropertySource.getProperty("dubbo.application.name");
- Assert.assertEquals("demo-dubbo-application", dubboApplicationName);
+ assertEquals("demo-dubbo-application", dubboApplicationName);
// Case 5 : Reset dubbo.config.multiple and dubbo.application.qos-enable
environment = new MockEnvironment();
@@ -91,7 +93,7 @@ public void testPostProcessEnvironment() {
environment.setProperty("dubbo.config.multiple", "false");
environment.setProperty("dubbo.application.qos-enable", "false");
instance.postProcessEnvironment(environment, springApplication);
- Assert.assertEquals("false", environment.getProperty("dubbo.config.multiple"));
- Assert.assertEquals("false", environment.getProperty("dubbo.application.qos-enable"));
+ assertEquals("false", environment.getProperty("dubbo.config.multiple"));
+ assertEquals("false", environment.getProperty("dubbo.application.qos-enable"));
}
}
diff --git a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java
index b7598d03135..87a8f8cdb61 100644
--- a/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java
+++ b/dubbo-spring-boot-project/dubbo-spring-boot/src/test/java/org/apache/dubbo/spring/boot/util/DubboUtilsTest.java
@@ -16,8 +16,7 @@
*/
package org.apache.dubbo.spring.boot.util;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.apache.dubbo.spring.boot.util.DubboUtils.BASE_PACKAGES_PROPERTY_NAME;
import static org.apache.dubbo.spring.boot.util.DubboUtils.DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE;
@@ -37,6 +36,8 @@
import static org.apache.dubbo.spring.boot.util.DubboUtils.MULTIPLE_CONFIG_PROPERTY_NAME;
import static org.apache.dubbo.spring.boot.util.DubboUtils.OVERRIDE_CONFIG_FULL_PROPERTY_NAME;
import static org.apache.dubbo.spring.boot.util.DubboUtils.SPRING_APPLICATION_NAME_PROPERTY;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* {@link DubboUtils} Test
@@ -44,39 +45,39 @@
* @see DubboUtils
* @since 2.7.0
*/
-public class DubboUtilsTest {
+class DubboUtilsTest {
@Test
- public void testConstants() {
+ void testConstants() {
- Assert.assertEquals("dubbo", DUBBO_PREFIX);
+ assertEquals("dubbo", DUBBO_PREFIX);
- Assert.assertEquals("dubbo.scan.", DUBBO_SCAN_PREFIX);
+ assertEquals("dubbo.scan.", DUBBO_SCAN_PREFIX);
- Assert.assertEquals("base-packages", BASE_PACKAGES_PROPERTY_NAME);
+ assertEquals("base-packages", BASE_PACKAGES_PROPERTY_NAME);
- Assert.assertEquals("dubbo.config.", DUBBO_CONFIG_PREFIX);
+ assertEquals("dubbo.config.", DUBBO_CONFIG_PREFIX);
- Assert.assertEquals("multiple", MULTIPLE_CONFIG_PROPERTY_NAME);
+ assertEquals("multiple", MULTIPLE_CONFIG_PROPERTY_NAME);
- Assert.assertEquals("dubbo.config.override", OVERRIDE_CONFIG_FULL_PROPERTY_NAME);
+ assertEquals("dubbo.config.override", OVERRIDE_CONFIG_FULL_PROPERTY_NAME);
- Assert.assertEquals("https://github.com/apache/dubbo/tree/3.0/dubbo-spring-boot", DUBBO_SPRING_BOOT_GITHUB_URL);
- Assert.assertEquals("https://github.com/apache/dubbo.git", DUBBO_SPRING_BOOT_GIT_URL);
- Assert.assertEquals("https://github.com/apache/dubbo/issues", DUBBO_SPRING_BOOT_ISSUES_URL);
+ assertEquals("https://github.com/apache/dubbo/tree/3.0/dubbo-spring-boot", DUBBO_SPRING_BOOT_GITHUB_URL);
+ assertEquals("https://github.com/apache/dubbo.git", DUBBO_SPRING_BOOT_GIT_URL);
+ assertEquals("https://github.com/apache/dubbo/issues", DUBBO_SPRING_BOOT_ISSUES_URL);
- Assert.assertEquals("https://github.com/apache/dubbo", DUBBO_GITHUB_URL);
+ assertEquals("https://github.com/apache/dubbo", DUBBO_GITHUB_URL);
- Assert.assertEquals("dev@dubbo.apache.org", DUBBO_MAILING_LIST);
+ assertEquals("dev@dubbo.apache.org", DUBBO_MAILING_LIST);
- Assert.assertEquals("spring.application.name", SPRING_APPLICATION_NAME_PROPERTY);
- Assert.assertEquals("dubbo.application.id", DUBBO_APPLICATION_ID_PROPERTY);
- Assert.assertEquals("dubbo.application.name", DUBBO_APPLICATION_NAME_PROPERTY);
- Assert.assertEquals("dubbo.application.qos-enable", DUBBO_APPLICATION_QOS_ENABLE_PROPERTY);
- Assert.assertEquals("dubbo.config.multiple", DUBBO_CONFIG_MULTIPLE_PROPERTY);
+ assertEquals("spring.application.name", SPRING_APPLICATION_NAME_PROPERTY);
+ assertEquals("dubbo.application.id", DUBBO_APPLICATION_ID_PROPERTY);
+ assertEquals("dubbo.application.name", DUBBO_APPLICATION_NAME_PROPERTY);
+ assertEquals("dubbo.application.qos-enable", DUBBO_APPLICATION_QOS_ENABLE_PROPERTY);
+ assertEquals("dubbo.config.multiple", DUBBO_CONFIG_MULTIPLE_PROPERTY);
- Assert.assertTrue(DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE);
+ assertTrue(DEFAULT_MULTIPLE_CONFIG_PROPERTY_VALUE);
- Assert.assertTrue(DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE);
+ assertTrue(DEFAULT_OVERRIDE_CONFIG_PROPERTY_VALUE);
}
}