diff --git a/pom.xml b/pom.xml index 58487cc..c40721f 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ ${revision} - 2.7.8 + 3.1.10 1.8 1.8 1.8 @@ -31,7 +31,7 @@ 1.8 UTF-8 - 2.7.8 + 3.1.10 3.0 4.1.4 3.0 @@ -119,10 +119,10 @@ dubbo-registry-zookeeper - - org.apache.dubbo - dubbo-registry-redis - + + + + @@ -130,30 +130,31 @@ dubbo-serialization-hessian2 - - org.apache.dubbo - dubbo-serialization-fst - - - - org.apache.dubbo - dubbo-serialization-kryo - + + + + + + + + + org.apache.dubbo - dubbo-serialization-fastjson + dubbo-serialization-fastjson2 + - - org.apache.dubbo - dubbo-serialization-gson - - - - org.apache.dubbo - dubbo-serialization-avro - + + + + + + + + + diff --git a/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/gui/DubboSampleGui.java b/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/gui/DubboSampleGui.java index cfd54f3..c5580f9 100644 --- a/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/gui/DubboSampleGui.java +++ b/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/gui/DubboSampleGui.java @@ -108,7 +108,7 @@ public void modifyTestElement(TestElement element) { */ @Override public String getStaticLabel() { - return "Dubbo Sample"; + return "Dubbo Sampler"; } /** diff --git a/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/DubboSample.java b/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/DubboSample.java index e2c8936..5ae67d3 100644 --- a/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/DubboSample.java +++ b/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/DubboSample.java @@ -25,7 +25,7 @@ import org.apache.dubbo.config.ConfigCenterConfig; import org.apache.dubbo.config.ReferenceConfig; import org.apache.dubbo.config.RegistryConfig; -import org.apache.dubbo.config.utils.ReferenceConfigCache; +import org.apache.dubbo.config.utils.SimpleReferenceCache; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.RpcException; import org.apache.dubbo.rpc.service.GenericService; @@ -269,7 +269,7 @@ private Object callDubbo(SampleResult res) { } // The registry's address is to generate the ReferenceConfigCache key - ReferenceConfigCache cache = ReferenceConfigCache.getCache(Constants.getAddress(this)); + SimpleReferenceCache cache = SimpleReferenceCache.getCache(Constants.getAddress(this)); GenericService genericService = (GenericService) cache.get(reference); if (genericService == null) { setResponseError(res, ErrorCode.GENERIC_SERVICE_IS_NULL); diff --git a/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/ProviderService.java b/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/ProviderService.java index 23865cc..1493c91 100644 --- a/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/ProviderService.java +++ b/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/ProviderService.java @@ -21,7 +21,7 @@ import org.apache.dubbo.common.URL; import org.apache.dubbo.config.ReferenceConfig; import org.apache.dubbo.config.RegistryConfig; -import org.apache.dubbo.config.utils.ReferenceConfigCache; +import org.apache.dubbo.config.utils.SimpleReferenceCache; import org.apache.dubbo.registry.RegistryService; import org.apache.jorphan.logging.LoggingManager; import org.apache.log.Logger; @@ -102,7 +102,7 @@ private List executeRegistry(String protocol, String address, String gro } reference.setInterface("org.apache.dubbo.registry.RegistryService"); try { - ReferenceConfigCache cache = ReferenceConfigCache.getCache(address + "_" + group); + SimpleReferenceCache cache = SimpleReferenceCache.getCache(address + "_" + group); RegistryService registryService = (RegistryService) cache.get(reference); if (registryService == null) { throw new RuntimeException("Can't get the interface list, please check if the address is wrong!"); diff --git a/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/RegistryServerSync.java b/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/RegistryServerSync.java index 9e35c53..ae895ac 100644 --- a/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/RegistryServerSync.java +++ b/src/main/java/io/github/ningyu/jmeter/plugin/dubbo/sample/RegistryServerSync.java @@ -58,6 +58,7 @@ public static RegistryServerSync get(String key) { // + Constants.CONSUMERS_CATEGORY + "," // + Constants.ROUTERS_CATEGORY + "," // + Constants.CONFIGURATORS_CATEGORY, +// CommonConstants.INTERFACE_KEY, "com.pupu.depot.api.apply.IReplenishApplyDetailApi", CommonConstants.ENABLED_KEY, CommonConstants.ANY_VALUE, CommonConstants.CHECK_KEY, String.valueOf(false)); diff --git a/src/test/java/io/github/ningyu/jmeter/plugin/test/GenericServiceTest.java b/src/test/java/io/github/ningyu/jmeter/plugin/test/GenericServiceTest.java index 466f4ef..b24b48e 100644 --- a/src/test/java/io/github/ningyu/jmeter/plugin/test/GenericServiceTest.java +++ b/src/test/java/io/github/ningyu/jmeter/plugin/test/GenericServiceTest.java @@ -1,5 +1,7 @@ package io.github.ningyu.jmeter.plugin.test; +import io.github.ningyu.jmeter.plugin.bean.EnumA; +import io.github.ningyu.jmeter.plugin.bean.EnumB; import io.github.ningyu.jmeter.plugin.dubbo.sample.MethodArgument; import io.github.ningyu.jmeter.plugin.util.ClassUtils; import io.github.ningyu.jmeter.plugin.util.Constants; @@ -10,6 +12,7 @@ import org.apache.dubbo.config.RegistryConfig; import org.apache.dubbo.rpc.RpcContext; import org.apache.dubbo.rpc.service.GenericService; +import org.junit.Assert; import org.junit.Test; import java.util.ArrayList; @@ -21,14 +24,14 @@ public void test() { ApplicationConfig application = new ApplicationConfig(); application.setName("api-generic-consumer"); ReferenceConfig reference = new ReferenceConfig<>(); - reference.setUrl("dubbo://192.168.56.1:20880/org.apache.dubbo.samples.basic.api.DemoService"); + reference.setUrl("dubbo://192.168.9.182:28077/com.pupu.account.api.ITemperatureRecordingApi"); reference.setVersion("1.0.0"); reference.setTimeout(2000); reference.setGeneric(true); reference.setApplication(application); - reference.setInterface("com.jiuyescm.account.api.IUserService"); + reference.setInterface("com.pupu.account.api.ITemperatureRecordingApi"); GenericService genericService = reference.get(); - Object obj = genericService.$invoke("getUserById", new String[]{Long.class.getName()}, new Long[]{1L}); + Object obj = genericService.$invoke("countByAdminUser", new String[]{String.class.getName()}, new String[]{"118303"}); String json = JsonUtils.toJson(obj); System.out.println(json); } @@ -38,15 +41,15 @@ public void testAttachment() { ApplicationConfig application = new ApplicationConfig(); application.setName("api-generic-consumer"); ReferenceConfig reference = new ReferenceConfig<>(); - reference.setUrl("dubbo://192.168.56.1:20880/org.apache.dubbo.samples.basic.api.DemoService"); + reference.setUrl("dubbo://192.168.9.182:28077/com.pupu.account.api.ITemperatureRecordingApi"); reference.setVersion("1.0.0"); reference.setTimeout(2000); reference.setGeneric(true); reference.setApplication(application); - reference.setInterface("com.jiuyescm.account.api.IUserService"); + reference.setInterface("com.pupu.account.api.ITemperatureRecordingApi"); GenericService genericService = reference.get(); RpcContext.getContext().setAttachment("test.ningyu","this is attachmentValue"); - Object obj = genericService.$invoke("sayHello", new String[]{String.class.getName()}, new String[]{"ningyu"}); + Object obj = genericService.$invoke("countByAdminUser", new String[]{String.class.getName()}, new String[]{"118303"}); String json = JsonUtils.toJson(obj); System.out.println(json); } @@ -61,11 +64,15 @@ public void testZk() { reference.setGroup(""); RegistryConfig registry = new RegistryConfig(); registry.setProtocol(Constants.REGISTRY_ZOOKEEPER); - registry.setAddress("192.168.0.44:2181,192.168.0.44:2182,192.168.0.44:2183"); + registry.setAddress("qa-config.zookeeper.service.consul"); + registry.setPort(2181); +// registry.setAddress("192.168.0.44:2181,192.168.0.44:2182,192.168.0.44:2183"); registry.setTimeout(10000); reference.setRegistry(registry); ConfigCenterConfig cc = new ConfigCenterConfig(); - cc.setAddress("192.168.0.44:2181,192.168.0.44:2182,192.168.0.44:2183"); +// cc.setAddress("192.168.0.44:2181,192.168.0.44:2182,192.168.0.44:2183"); + cc.setAddress("qa-config.zookeeper.service.consul:2181"); + cc.setProtocol(Constants.REGISTRY_ZOOKEEPER); cc.setTimeout(Long.valueOf("10000")); cc.setGroup(""); @@ -74,9 +81,9 @@ public void testZk() { reference.setTimeout(2000); reference.setGeneric(true); reference.setApplication(application); - reference.setInterface("com.jiuyescm.account.api.IUserService"); + reference.setInterface("com.pupu.account.api.ITemperatureRecordingApi"); GenericService genericService = reference.get(); - Object obj = genericService.$invoke("getUserById", new String[]{Long.class.getName()}, new Long[]{1L}); + Object obj = genericService.$invoke("countByAdminUser", new String[]{String.class.getName()}, new String[]{"118303"}); String json = JsonUtils.toJson(obj); System.out.println(json); } @@ -86,19 +93,21 @@ public void testZk() { public void testEnumA() { List paramterTypeList = new ArrayList<>(); List parameterValuesList = new ArrayList<>(); - MethodArgument arg = new MethodArgument("io.github.ningyu.jmeter.plugin.EnumA1", "WECHAT"); + MethodArgument arg = new MethodArgument("io.github.ningyu.jmeter.plugin.bean.EnumA", "WECHAT"); ClassUtils.parseParameter(paramterTypeList, parameterValuesList, arg); System.out.println(paramterTypeList.toString()); System.out.println(parameterValuesList.toString()); + Assert.assertEquals(EnumA.WECHAT, parameterValuesList.get(0)); } @Test public void testEnumB() { List paramterTypeList = new ArrayList<>(); List parameterValuesList = new ArrayList<>(); - MethodArgument arg = new MethodArgument("io.github.ningyu.jmeter.plugin.EnumB1", "PASSED"); + MethodArgument arg = new MethodArgument("io.github.ningyu.jmeter.plugin.bean.EnumB", "PASSED"); ClassUtils.parseParameter(paramterTypeList, parameterValuesList, arg); System.out.println(paramterTypeList.toString()); System.out.println(parameterValuesList.toString()); + Assert.assertEquals(EnumB.PASSED, parameterValuesList.get(0)); } } diff --git a/src/test/java/io/github/ningyu/jmeter/plugin/test/ProviderServiceTest.java b/src/test/java/io/github/ningyu/jmeter/plugin/test/ProviderServiceTest.java new file mode 100644 index 0000000..fd6ad58 --- /dev/null +++ b/src/test/java/io/github/ningyu/jmeter/plugin/test/ProviderServiceTest.java @@ -0,0 +1,21 @@ +package io.github.ningyu.jmeter.plugin.test; + +import io.github.ningyu.jmeter.plugin.dubbo.sample.ProviderService; +import org.junit.Test; + +import java.util.List; + +/** + * @Author: Jason Wu + * @Date: 2023/9/18 + * @Description: + */ +public class ProviderServiceTest { + +// @Test + public void testGetProviders() { + ProviderService providerService = new ProviderService(); + List result = providerService.getProviders("zookeeper", "qa-config.zookeeper.service.consul:2181", ""); + result.forEach(s->{}); + } +}