diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/annotation/DemoServiceImpl.java b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/annotation/DemoServiceImpl.java index 37ffcd5851..9794413533 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/annotation/DemoServiceImpl.java +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/annotation/DemoServiceImpl.java @@ -16,7 +16,7 @@ import com.tencent.trpc.spring.boot.starters.test.GreeterService; import com.tencent.trpc.spring.boot.starters.test.HelloRequestProtocol.HelloRequest; import com.tencent.trpc.spring.boot.starters.test.HelloRequestProtocol.HelloResponse; -import javax.annotation.Resource; +import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/annotation/EnableAnnotationTest.java b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/annotation/EnableAnnotationTest.java index f9afe47748..3048411ee6 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/annotation/EnableAnnotationTest.java +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/annotation/EnableAnnotationTest.java @@ -18,19 +18,16 @@ import com.tencent.trpc.spring.boot.starters.test.HelloRequestProtocol.HelloRequest; import com.tencent.trpc.spring.boot.starters.test.HelloRequestProtocol.HelloResponse; import com.tencent.trpc.spring.boot.starters.test.SpringBootTestApplication; -import javax.annotation.Resource; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import jakarta.annotation.Resource; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -@RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = SpringBootTestApplication.class, webEnvironment = WebEnvironment.NONE) @ContextConfiguration(classes = EnableAnnotationTestConfiguration.class) public class EnableAnnotationTest { @@ -45,25 +42,25 @@ public void contextLoad() { HelloResponse hello = demoService.sayHello(HelloRequest.newBuilder().setMessage("hello").build()); - Assert.assertEquals("hello", hello.getMessage()); - Assert.assertNotNull(demoService.getGreeterService1Bean()); - Assert.assertNotNull(demoService.getGreeterService2Bean()); - Assert.assertNotNull(demoService.getMyTestServer()); - Assert.assertSame(demoService.getGreeterService(), demoService.getGreeterService1Bean()); - Assert.assertSame(demoService.getGreeterService2(), demoService.getGreeterService2Bean()); - Assert.assertSame(demoService.getMyTestServerClient(), demoService.getMyTestServer()); + Assertions.assertEquals("hello", hello.getMessage()); + Assertions.assertNotNull(demoService.getGreeterService1Bean()); + Assertions.assertNotNull(demoService.getGreeterService2Bean()); + Assertions.assertNotNull(demoService.getMyTestServer()); + Assertions.assertSame(demoService.getGreeterService(), demoService.getGreeterService1Bean()); + Assertions.assertSame(demoService.getGreeterService2(), demoService.getGreeterService2Bean()); + Assertions.assertSame(demoService.getMyTestServerClient(), demoService.getMyTestServer()); } @Test public void testFilterInject() { AutoInjectTestFilter filter = (AutoInjectTestFilter) FilterManager.get("auto_inject_test_filter"); - Assert.assertSame(filter, autoInjectTestFilter); - Assert.assertNotNull(filter.getGreeterService()); - Assert.assertNotNull(filter.getGreeterService2()); - Assert.assertNotNull(filter.getMyTestServer()); - Assert.assertSame(filter.getGreeterService(), demoService.getGreeterService1Bean()); - Assert.assertSame(filter.getGreeterService2(), demoService.getGreeterService2Bean()); - Assert.assertSame(filter.getMyTestServer(), demoService.getMyTestServer()); + Assertions.assertSame(filter, autoInjectTestFilter); + Assertions.assertNotNull(filter.getGreeterService()); + Assertions.assertNotNull(filter.getGreeterService2()); + Assertions.assertNotNull(filter.getMyTestServer()); + Assertions.assertSame(filter.getGreeterService(), demoService.getGreeterService1Bean()); + Assertions.assertSame(filter.getGreeterService2(), demoService.getGreeterService2Bean()); + Assertions.assertSame(filter.getMyTestServer(), demoService.getMyTestServer()); } @Configuration diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/BindTest1.java b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/BindTest1.java index dc8593a421..57ff1f5630 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/BindTest1.java +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/BindTest1.java @@ -14,16 +14,13 @@ import com.tencent.trpc.spring.boot.starters.context.configuration.TRpcConfigurationProperties; import com.tencent.trpc.spring.boot.starters.test.SpringBootTestApplication; import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) @SpringBootTest(classes = SpringBootTestApplication.class, webEnvironment = WebEnvironment.NONE) @ActiveProfiles("bind-test1") public class BindTest1 { @@ -35,9 +32,9 @@ public class BindTest1 { @Test @SuppressWarnings("unchecked") public void test() { - Assert.assertEquals(properties.getServer().getApp(), "TestApp"); + Assertions.assertEquals(properties.getServer().getApp(), "TestApp"); List serviceList = (List) properties.getPlugins().getRegistry().get("polaris").get("service"); - Assert.assertNotNull(serviceList); - Assert.assertEquals(serviceList.size(), 1); + Assertions.assertNotNull(serviceList); + Assertions.assertEquals(serviceList.size(), 1); } } diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/BindTest2.java b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/BindTest2.java index 18d3c1645d..02f7d90ba8 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/BindTest2.java +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/BindTest2.java @@ -19,16 +19,13 @@ import com.tencent.trpc.spring.context.configuration.schema.server.IoMode; import com.tencent.trpc.spring.context.configuration.schema.server.ServerServiceSchema; import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) @SpringBootTest(classes = SpringBootTestApplication.class, webEnvironment = WebEnvironment.NONE) @ActiveProfiles("bind-test2") public class BindTest2 { @@ -48,136 +45,136 @@ public void test() { } private void assertGlobal() { - Assert.assertEquals(properties.getGlobal().getNamespace(), "test_namespace"); - Assert.assertEquals(properties.getGlobal().getEnvName(), "test_env_name"); - Assert.assertEquals(properties.getGlobal().getContainerName(), "test_container_name"); - Assert.assertEquals(properties.getGlobal().getEnableSet(), YesOrNo.Y); - Assert.assertEquals(properties.getGlobal().getFullSetName(), "a.b.c"); + Assertions.assertEquals(properties.getGlobal().getNamespace(), "test_namespace"); + Assertions.assertEquals(properties.getGlobal().getEnvName(), "test_env_name"); + Assertions.assertEquals(properties.getGlobal().getContainerName(), "test_container_name"); + Assertions.assertEquals(properties.getGlobal().getEnableSet(), YesOrNo.Y); + Assertions.assertEquals(properties.getGlobal().getFullSetName(), "a.b.c"); } private void assertServer() { - Assert.assertEquals(properties.getServer().getApp(), "QQPIM"); - Assert.assertEquals(properties.getServer().getServer(), "DMServer"); - Assert.assertEquals(properties.getServer().getAdmin().getAdminIp(), "127.0.0.1"); - Assert.assertEquals(properties.getServer().getAdmin().getAdminPort(), Integer.valueOf(8091)); - Assert.assertEquals(properties.getServer().getLocalIp(), "127.0.0.1"); - Assert.assertEquals(properties.getServer().getCloseTimeout(), Long.valueOf(1000)); - Assert.assertEquals(properties.getServer().getWaitTimeout(), Long.valueOf(1100)); - Assert.assertEquals(properties.getServer().getNic(), "eth1"); - Assert.assertEquals(properties.getServer().getRequestTimeout(), Integer.valueOf(2000)); - Assert.assertEquals(properties.getServer().getEnableLinkTimeout(), false); - Assert.assertEquals(properties.getServer().getWorkerPool(), "woker_pool_provider_test"); - Assert.assertEquals(properties.getServer().getFilters(), Lists.newArrayList("additional_server_filter")); + Assertions.assertEquals(properties.getServer().getApp(), "QQPIM"); + Assertions.assertEquals(properties.getServer().getServer(), "DMServer"); + Assertions.assertEquals(properties.getServer().getAdmin().getAdminIp(), "127.0.0.1"); + Assertions.assertEquals(properties.getServer().getAdmin().getAdminPort(), Integer.valueOf(8091)); + Assertions.assertEquals(properties.getServer().getLocalIp(), "127.0.0.1"); + Assertions.assertEquals(properties.getServer().getCloseTimeout(), Long.valueOf(1000)); + Assertions.assertEquals(properties.getServer().getWaitTimeout(), Long.valueOf(1100)); + Assertions.assertEquals(properties.getServer().getNic(), "eth1"); + Assertions.assertEquals(properties.getServer().getRequestTimeout(), Integer.valueOf(2000)); + Assertions.assertEquals(properties.getServer().getEnableLinkTimeout(), false); + Assertions.assertEquals(properties.getServer().getWorkerPool(), "woker_pool_provider_test"); + Assertions.assertEquals(properties.getServer().getFilters(), Lists.newArrayList("additional_server_filter")); } private void assertServerService() { ServerServiceSchema serviceSchema = properties.getServer().getService().get(0); - Assert.assertEquals(serviceSchema.getName(), "trpc.TestApp.TestServer.Greeter"); - Assert.assertEquals(serviceSchema.getVersion(), "v.121"); - Assert.assertEquals(serviceSchema.getGroup(), "g1"); - Assert.assertEquals(serviceSchema.getImpls().get(0), + Assertions.assertEquals(serviceSchema.getName(), "trpc.TestApp.TestServer.Greeter"); + Assertions.assertEquals(serviceSchema.getVersion(), "v.121"); + Assertions.assertEquals(serviceSchema.getGroup(), "g1"); + Assertions.assertEquals(serviceSchema.getImpls().get(0), "com.tencent.trpc.spring.boot.starters.test.GreeterServiceImpl"); - Assert.assertEquals(serviceSchema.getIp(), "127.0.0.1"); - Assert.assertEquals(serviceSchema.getNic(), "eth3"); - Assert.assertEquals(serviceSchema.getPort(), Integer.valueOf(12345)); - Assert.assertEquals(serviceSchema.getNetwork(), "udp"); - Assert.assertEquals(serviceSchema.getProtocol(), "trpc"); - Assert.assertEquals(serviceSchema.getSerialization(), "pb"); - Assert.assertEquals(serviceSchema.getCompressor(), "gzip"); - Assert.assertEquals(serviceSchema.getCompressMinBytes(), Integer.valueOf(10)); - Assert.assertEquals(serviceSchema.getCharset(), "gbk"); - Assert.assertEquals(serviceSchema.getKeepAlive(), false); - Assert.assertEquals(serviceSchema.getMaxConns(), Integer.valueOf(10)); - Assert.assertEquals(serviceSchema.getBacklog(), Integer.valueOf(1111)); - Assert.assertEquals(serviceSchema.getSendBuffer(), Integer.valueOf(10)); - Assert.assertEquals(serviceSchema.getReceiveBuffer(), Integer.valueOf(20)); - Assert.assertEquals(serviceSchema.getPayload(), Integer.valueOf(2222)); - Assert.assertEquals(serviceSchema.getIdleTimeout(), Integer.valueOf(200)); - Assert.assertEquals(serviceSchema.getLazyinit(), false); - Assert.assertEquals(serviceSchema.getIoMode(), IoMode.kqueue); - Assert.assertEquals(serviceSchema.getIoThreadGroupShare(), false); - Assert.assertEquals(serviceSchema.getIoThreads(), Integer.valueOf(20)); - Assert.assertEquals(serviceSchema.getRequestTimeout(), Integer.valueOf(3000)); - Assert.assertEquals(serviceSchema.getWorkerPool(), "woker_pool_provider_test"); - Assert.assertEquals(serviceSchema.getEnableLinkTimeout(), true); - Assert.assertEquals(serviceSchema.getReusePort(), true); - Assert.assertEquals(serviceSchema.getFilters(), Lists.newArrayList("additional_server_filter")); + Assertions.assertEquals(serviceSchema.getIp(), "127.0.0.1"); + Assertions.assertEquals(serviceSchema.getNic(), "eth3"); + Assertions.assertEquals(serviceSchema.getPort(), Integer.valueOf(12345)); + Assertions.assertEquals(serviceSchema.getNetwork(), "udp"); + Assertions.assertEquals(serviceSchema.getProtocol(), "trpc"); + Assertions.assertEquals(serviceSchema.getSerialization(), "pb"); + Assertions.assertEquals(serviceSchema.getCompressor(), "gzip"); + Assertions.assertEquals(serviceSchema.getCompressMinBytes(), Integer.valueOf(10)); + Assertions.assertEquals(serviceSchema.getCharset(), "gbk"); + Assertions.assertEquals(serviceSchema.getKeepAlive(), false); + Assertions.assertEquals(serviceSchema.getMaxConns(), Integer.valueOf(10)); + Assertions.assertEquals(serviceSchema.getBacklog(), Integer.valueOf(1111)); + Assertions.assertEquals(serviceSchema.getSendBuffer(), Integer.valueOf(10)); + Assertions.assertEquals(serviceSchema.getReceiveBuffer(), Integer.valueOf(20)); + Assertions.assertEquals(serviceSchema.getPayload(), Integer.valueOf(2222)); + Assertions.assertEquals(serviceSchema.getIdleTimeout(), Integer.valueOf(200)); + Assertions.assertEquals(serviceSchema.getLazyinit(), false); + Assertions.assertEquals(serviceSchema.getIoMode(), IoMode.kqueue); + Assertions.assertEquals(serviceSchema.getIoThreadGroupShare(), false); + Assertions.assertEquals(serviceSchema.getIoThreads(), Integer.valueOf(20)); + Assertions.assertEquals(serviceSchema.getRequestTimeout(), Integer.valueOf(3000)); + Assertions.assertEquals(serviceSchema.getWorkerPool(), "woker_pool_provider_test"); + Assertions.assertEquals(serviceSchema.getEnableLinkTimeout(), true); + Assertions.assertEquals(serviceSchema.getReusePort(), true); + Assertions.assertEquals(serviceSchema.getFilters(), Lists.newArrayList("additional_server_filter")); } private void assertClient() { - Assert.assertEquals(properties.getClient().getNamespace(), "dev"); - Assert.assertEquals(properties.getClient().getWorkerPool(), "woker_pool_consumer_test"); - Assert.assertEquals(properties.getClient().getRequestTimeout(), Integer.valueOf(2000)); - Assert.assertEquals(properties.getClient().getNetwork(), "udp"); - Assert.assertEquals(properties.getClient().getProtocol(), "trpc"); - Assert.assertEquals(properties.getClient().getSerialization(), "pb"); - Assert.assertEquals(properties.getClient().getCompressor(), "snappy"); - Assert.assertEquals(properties.getClient().getCharset(), "gbk"); - Assert.assertEquals(properties.getClient().getKeepAlive(), false); - Assert.assertEquals(properties.getClient().getMaxConns(), Integer.valueOf(10)); - Assert.assertEquals(properties.getClient().getBacklog(), Integer.valueOf(1111)); - Assert.assertEquals(properties.getClient().getSendBuffer(), Integer.valueOf(10)); - Assert.assertEquals(properties.getClient().getReceiveBuffer(), Integer.valueOf(20)); - Assert.assertEquals(properties.getClient().getIdleTimeout(), Integer.valueOf(200)); - Assert.assertEquals(properties.getClient().getLazyinit(), false); - Assert.assertEquals(properties.getClient().getConnsPerAddr(), Integer.valueOf(5)); - Assert.assertEquals(properties.getClient().getConnTimeout(), Integer.valueOf(2000)); - Assert.assertEquals(properties.getClient().getIoThreadGroupShare(), false); - Assert.assertEquals(properties.getClient().getIoThreads(), Integer.valueOf(20)); - Assert.assertEquals(properties.getClient().getFilters(), Lists.newArrayList("additional_client_filter")); + Assertions.assertEquals(properties.getClient().getNamespace(), "dev"); + Assertions.assertEquals(properties.getClient().getWorkerPool(), "woker_pool_consumer_test"); + Assertions.assertEquals(properties.getClient().getRequestTimeout(), Integer.valueOf(2000)); + Assertions.assertEquals(properties.getClient().getNetwork(), "udp"); + Assertions.assertEquals(properties.getClient().getProtocol(), "trpc"); + Assertions.assertEquals(properties.getClient().getSerialization(), "pb"); + Assertions.assertEquals(properties.getClient().getCompressor(), "snappy"); + Assertions.assertEquals(properties.getClient().getCharset(), "gbk"); + Assertions.assertEquals(properties.getClient().getKeepAlive(), false); + Assertions.assertEquals(properties.getClient().getMaxConns(), Integer.valueOf(10)); + Assertions.assertEquals(properties.getClient().getBacklog(), Integer.valueOf(1111)); + Assertions.assertEquals(properties.getClient().getSendBuffer(), Integer.valueOf(10)); + Assertions.assertEquals(properties.getClient().getReceiveBuffer(), Integer.valueOf(20)); + Assertions.assertEquals(properties.getClient().getIdleTimeout(), Integer.valueOf(200)); + Assertions.assertEquals(properties.getClient().getLazyinit(), false); + Assertions.assertEquals(properties.getClient().getConnsPerAddr(), Integer.valueOf(5)); + Assertions.assertEquals(properties.getClient().getConnTimeout(), Integer.valueOf(2000)); + Assertions.assertEquals(properties.getClient().getIoThreadGroupShare(), false); + Assertions.assertEquals(properties.getClient().getIoThreads(), Integer.valueOf(20)); + Assertions.assertEquals(properties.getClient().getFilters(), Lists.newArrayList("additional_client_filter")); ClientServiceSchema clientServiceSchema = properties.getClient().getService().get(0); - Assert.assertEquals(clientServiceSchema.getName(), "trpc.TestApp.TestServer.Greeter1Naming"); - Assert.assertEquals(clientServiceSchema.getInterface(), + Assertions.assertEquals(clientServiceSchema.getName(), "trpc.TestApp.TestServer.Greeter1Naming"); + Assertions.assertEquals(clientServiceSchema.getInterface(), "com.tencent.trpc.spring.boot.starters.test.GreeterService"); - Assert.assertEquals(clientServiceSchema.getNamingUrl(), "ip://127.0.0.1:12345"); - Assert.assertEquals(clientServiceSchema.getNamespace(), "dev2"); - Assert.assertEquals(clientServiceSchema.getCallee(), "trpc.TestApp.TestServer.GreeterCallee"); - Assert.assertEquals(clientServiceSchema.getCallerServiceName(), "trpc.TestApp.TestServer.GreeterCallee2"); - Assert.assertEquals(clientServiceSchema.getGroup(), "g1"); - Assert.assertEquals(clientServiceSchema.getVersion(), "v1"); - Assert.assertEquals(clientServiceSchema.getCompressor(), "gzip"); - Assert.assertEquals(clientServiceSchema.getCompressMinBytes(), Integer.valueOf(1)); + Assertions.assertEquals(clientServiceSchema.getNamingUrl(), "ip://127.0.0.1:12345"); + Assertions.assertEquals(clientServiceSchema.getNamespace(), "dev2"); + Assertions.assertEquals(clientServiceSchema.getCallee(), "trpc.TestApp.TestServer.GreeterCallee"); + Assertions.assertEquals(clientServiceSchema.getCallerServiceName(), "trpc.TestApp.TestServer.GreeterCallee2"); + Assertions.assertEquals(clientServiceSchema.getGroup(), "g1"); + Assertions.assertEquals(clientServiceSchema.getVersion(), "v1"); + Assertions.assertEquals(clientServiceSchema.getCompressor(), "gzip"); + Assertions.assertEquals(clientServiceSchema.getCompressMinBytes(), Integer.valueOf(1)); } private void assertWorkerPool() { Map> workerPool = properties.getPlugins().getWorkerPool(); - Assert.assertEquals(workerPool.get("woker_pool_provider_test").get("_type"), "thread"); - Assert.assertEquals(workerPool.get("woker_pool_provider_test").get("core_pool_size"), 10000); - Assert.assertEquals(workerPool.get("woker_pool_consumer_test").get("_type"), "thread"); - Assert.assertEquals(workerPool.get("woker_pool_consumer_test").get("core_pool_size"), 10000); + Assertions.assertEquals(workerPool.get("woker_pool_provider_test").get("_type"), "thread"); + Assertions.assertEquals(workerPool.get("woker_pool_provider_test").get("core_pool_size"), 10000); + Assertions.assertEquals(workerPool.get("woker_pool_consumer_test").get("_type"), "thread"); + Assertions.assertEquals(workerPool.get("woker_pool_consumer_test").get("core_pool_size"), 10000); } private void assertRegistry() { Map> registry = properties.getPlugins().getRegistry(); - Assert.assertEquals(registry.get("polaris").get("heartbeat_interval"), 1000); - Assert.assertEquals(registry.get("polaris").get("register_self"), false); + Assertions.assertEquals(registry.get("polaris").get("heartbeat_interval"), 1000); + Assertions.assertEquals(registry.get("polaris").get("register_self"), false); } private void assertSelector() { Map> selector = properties.getPlugins().getSelector(); - Assert.assertEquals(selector.get("polaris").get("mode"), 0); + Assertions.assertEquals(selector.get("polaris").get("mode"), 0); } private void assertRemoteLog() { Map> remoteLog = properties.getPlugins().getRemoteLog(); - Assert.assertEquals(remoteLog.get("atta").get("attaid"), "0a100055063"); - Assert.assertEquals(remoteLog.get("atta").get("token"), "3514966829"); - Assert.assertEquals(remoteLog.get("atta").get("switch"), "open"); + Assertions.assertEquals(remoteLog.get("atta").get("attaid"), "0a100055063"); + Assertions.assertEquals(remoteLog.get("atta").get("token"), "3514966829"); + Assertions.assertEquals(remoteLog.get("atta").get("switch"), "open"); } @SuppressWarnings("unchecked") private void assertTracing() { Map> tracing = properties.getPlugins().getTracing(); - Assert.assertEquals(tracing.get("tjg").get("appid"), "trpc"); - Assert.assertEquals(tracing.get("tjg").get("service_name"), "trpc.${app}.${server}"); - Assert.assertEquals(tracing.get("tjg").get("hostname"), "${container_name}"); - Assert.assertEquals(tracing.get("tjg").get("local_addr"), "${local_ip}"); - Assert.assertEquals(tracing.get("tjg").get("local_port"), 0); + Assertions.assertEquals(tracing.get("tjg").get("appid"), "trpc"); + Assertions.assertEquals(tracing.get("tjg").get("service_name"), "trpc.${app}.${server}"); + Assertions.assertEquals(tracing.get("tjg").get("hostname"), "${container_name}"); + Assertions.assertEquals(tracing.get("tjg").get("local_addr"), "${local_ip}"); + Assertions.assertEquals(tracing.get("tjg").get("local_port"), 0); Map sampler = (Map) tracing.get("tjg").get("sampler"); - Assert.assertEquals(sampler.get("type"), "mix"); + Assertions.assertEquals(sampler.get("type"), "mix"); Map mix = (Map) sampler.get("mix"); - Assert.assertEquals(mix.get("sample_rate"), 1024); - Assert.assertEquals(mix.get("min_speed_rate"), 1); - Assert.assertEquals(mix.get("max_speed_rate"), 10); + Assertions.assertEquals(mix.get("sample_rate"), 1024); + Assertions.assertEquals(mix.get("min_speed_rate"), 1); + Assertions.assertEquals(mix.get("max_speed_rate"), 10); } } diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/CustomizedProfileTest.java b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/CustomizedProfileTest.java index c4f3567584..24099a7ea5 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/CustomizedProfileTest.java +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/context/CustomizedProfileTest.java @@ -13,16 +13,13 @@ import com.tencent.trpc.spring.boot.starters.context.configuration.TRpcConfigurationProperties; import com.tencent.trpc.spring.boot.starters.test.SpringBootTestApplication; -import org.junit.Assert; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -@RunWith(SpringRunner.class) @SpringBootTest(classes = SpringBootTestApplication.class, webEnvironment = WebEnvironment.NONE) @ActiveProfiles("customized-profile") public class CustomizedProfileTest { @@ -32,6 +29,6 @@ public class CustomizedProfileTest { @Test public void test() { - Assert.assertEquals(properties.getServer().getRequestTimeout(), Integer.valueOf(3000)); + Assertions.assertEquals(properties.getServer().getRequestTimeout(), Integer.valueOf(3000)); } } diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/OriginTrackedCompositePropertySourceTest.java b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/OriginTrackedCompositePropertySourceTest.java index eee3ed3fc8..8238c2dde6 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/OriginTrackedCompositePropertySourceTest.java +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/OriginTrackedCompositePropertySourceTest.java @@ -11,8 +11,8 @@ package com.tencent.trpc.spring.boot.starters.env; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class OriginTrackedCompositePropertySourceTest { @@ -20,7 +20,7 @@ public class OriginTrackedCompositePropertySourceTest { public void test() { OriginTrackedCompositePropertySource propertySource = new OriginTrackedCompositePropertySource("test"); - Assert.assertFalse(propertySource.isImmutable()); - Assert.assertNull(propertySource.getOrigin("absentKey")); + Assertions.assertFalse(propertySource.isImmutable()); + Assertions.assertNull(propertySource.getOrigin("absentKey")); } } diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/TRpcConfigurationEnvironmentPostProcessorTest.java b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/TRpcConfigurationEnvironmentPostProcessorTest.java index ea14c979ec..ddd5dbfdbb 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/TRpcConfigurationEnvironmentPostProcessorTest.java +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/TRpcConfigurationEnvironmentPostProcessorTest.java @@ -14,8 +14,8 @@ import com.tencent.trpc.core.common.TRpcSystemProperties; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class TRpcConfigurationEnvironmentPostProcessorTest { @@ -27,12 +27,12 @@ public void testGetCustomPropertySourceLocation() getCustomPropertySourceLocation.setAccessible(Boolean.TRUE); TRpcConfigurationEnvironmentPostProcessor processor = new TRpcConfigurationEnvironmentPostProcessor(); Object configNull = getCustomPropertySourceLocation.invoke(processor); - Assert.assertNull(configNull); + Assertions.assertNull(configNull); TRpcSystemProperties.setProperties(TRpcSystemProperties.CONFIG_PATH, "/aa"); Object config = getCustomPropertySourceLocation.invoke(processor); - Assert.assertEquals(config, "file:///aa"); + Assertions.assertEquals(config, "file:///aa"); TRpcSystemProperties.setProperties(TRpcSystemProperties.CONFIG_PATH, "file:///aa"); Object configFile = getCustomPropertySourceLocation.invoke(processor); - Assert.assertEquals(config, "file:///aa"); + Assertions.assertEquals(config, "file:///aa"); } -} \ No newline at end of file +} diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/TRpcPropertySourceLoaderTest.java b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/TRpcPropertySourceLoaderTest.java index 54bde54ef2..d40aa03d28 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/TRpcPropertySourceLoaderTest.java +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/env/TRpcPropertySourceLoaderTest.java @@ -11,8 +11,8 @@ package com.tencent.trpc.spring.boot.starters.env; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import org.springframework.boot.logging.DeferredLog; import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.DefaultResourceLoader; @@ -35,6 +35,6 @@ public void test() { log.switchTo(TRpcPropertySourceLoaderTest.class); - Assert.assertEquals(environment.getPropertySources().size(), 2); + Assertions.assertEquals(environment.getPropertySources().size(), 2); } } diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/test/AutoInjectTestFilter.java b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/test/AutoInjectTestFilter.java index b59209a221..b7258a118c 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/test/AutoInjectTestFilter.java +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/java/com/tencent/trpc/spring/boot/starters/test/AutoInjectTestFilter.java @@ -16,7 +16,7 @@ import com.tencent.trpc.core.rpc.Request; import com.tencent.trpc.core.rpc.Response; import java.util.concurrent.CompletionStage; -import javax.annotation.Resource; +import jakarta.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/application-bind-test1.yml b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/application-bind-test1.yml index 4a2be8bbc3..aec5252bbc 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/application-bind-test1.yml +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/application-bind-test1.yml @@ -6,9 +6,9 @@ trpc: enable_set: N #是否启用set full_set_name: #set名 server: - app: TestApp #业务的应用名 - server: TestServer #业务的服务名 - local_ip: 127.0.0.1 #本地IP,容器内为容器ip,物理机或虚拟机为本机ip + app: TestApp + server: TestServer + local_ip: 127.0.0.1 worker_pool: woker_pool_provider_test request_timeout: 2000 service: @@ -16,7 +16,7 @@ trpc: impls: - impl: com.tencent.trpc.spring.boot.starters.test.GreeterServiceImpl request_timeout: 100 - port: 12345 + port: 15674 ext-map: k: a: diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/application-bind-test2.yml b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/application-bind-test2.yml index 4a1ce4e48d..ac29fca8d2 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/application-bind-test2.yml +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/application-bind-test2.yml @@ -38,7 +38,7 @@ trpc: - com.tencent.trpc.spring.boot.starters.test.GreeterServiceImpl #service协议接口实现类 ip: 127.0.0.1 nic: eth3 - port: 12345 #port + port: 15673 #port network: udp #tcp/udp protocol: trpc #协议类型 trpc oidb ilive http等 serialization: pb @@ -69,7 +69,6 @@ trpc: worker_pool: woker_pool_consumer_test request_timeout: 2000 nic: eth3 - port: 12345 #port network: udp #tcp/udp protocol: trpc #协议类型 trpc oidb ilive http等 serialization: pb @@ -94,7 +93,7 @@ trpc: service: - name: trpc.TestApp.TestServer.Greeter1Naming interface: com.tencent.trpc.spring.boot.starters.test.GreeterService - naming_url: ip://127.0.0.1:12345 #naming配置,直连 ip://ip:port, 名字服务: polaris://trpc.TestApp.TestServer.Greeter?key=value&key=value l5://mid:cmid cmlb://id + naming_url: ip://127.0.0.1:15673 #naming配置,直连 ip://ip:port, 名字服务: polaris://trpc.TestApp.TestServer.Greeter?key=value&key=value l5://mid:cmid cmlb://id namespace: dev2 callee: trpc.TestApp.TestServer.GreeterCallee caller_service_name: trpc.TestApp.TestServer.GreeterCallee2 diff --git a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/trpc_java.yaml b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/trpc_java.yaml index 9958799306..9a82cf5d5f 100644 --- a/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/trpc_java.yaml +++ b/trpc-spring-boot-starters/trpc-spring-boot-starter/src/test/resources/trpc_java.yaml @@ -18,7 +18,7 @@ server: impls: - impl: com.tencent.trpc.spring.boot.starters.test.GreeterServiceImpl request_timeout: 100 - port: 12345 + port: 18888 client: protocol: trpc @@ -27,15 +27,15 @@ client: service: - name: trpc.TestApp.TestServer.Greeter1Naming interface: com.tencent.trpc.spring.boot.starters.test.GreeterService - naming_url: ip://127.0.0.1:12345 + naming_url: ip://127.0.0.1:18888 network: tcp #tcp/udp - name: trpc.TestApp.TestServer.Greeter2Naming interface: com.tencent.trpc.spring.boot.starters.test.GreeterService - naming_url: ip://127.0.0.1:12345 + naming_url: ip://127.0.0.1:18888 network: tcp - name: myTestServer interface: com.tencent.trpc.spring.boot.starters.test.GreeterService - naming_url: ip://127.0.0.1:12345 + naming_url: ip://127.0.0.1:18888 network: tcp plugins: