org.apache.dubbo.common.constants.CommonConstants Java Examples
The following examples show how to use
org.apache.dubbo.common.constants.CommonConstants.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DubboSofaTracerFilter.java From sofa-tracer with Apache License 2.0 | 6 votes |
private void appendRpcClientSpanTags(Invoker<?> invoker, SofaTracerSpan sofaTracerSpan) { if (sofaTracerSpan == null) { return; } RpcContext rpcContext = RpcContext.getContext(); Map<String, String> tagsStr = sofaTracerSpan.getTagsWithStr(); tagsStr.put(Tags.SPAN_KIND.getKey(), spanKind(rpcContext)); String protocol = rpcContext.getUrl().getProtocol(); tagsStr.put(CommonSpanTags.PROTOCOL, protocol == null ? BLANK : protocol); String service = invoker.getInterface().getName(); tagsStr.put(CommonSpanTags.SERVICE, service == null ? BLANK : service); String methodName = rpcContext.getMethodName(); tagsStr.put(CommonSpanTags.METHOD, methodName == null ? BLANK : methodName); tagsStr.put(CommonSpanTags.CURRENT_THREAD_NAME, Thread.currentThread().getName()); String app = rpcContext.getUrl().getParameter(CommonConstants.APPLICATION_KEY); tagsStr.put(CommonSpanTags.LOCAL_APP, app == null ? BLANK : app); tagsStr.put(CommonSpanTags.REMOTE_HOST, rpcContext.getRemoteHost()); tagsStr.put(CommonSpanTags.REMOTE_PORT, String.valueOf(rpcContext.getRemotePort())); tagsStr.put(CommonSpanTags.LOCAL_HOST, rpcContext.getLocalHost()); }
Example #2
Source File: TestServer.java From brave with Apache License 2.0 | 6 votes |
TestServer(Propagation.Factory propagationFactory, ApplicationConfig application) { extractor = propagationFactory.get().extractor(Map::get); linkLocalIp = Platform.get().linkLocalIp(); if (linkLocalIp != null) { // avoid dubbo's logic which might pick docker ip System.setProperty(CommonConstants.DUBBO_IP_TO_BIND, linkLocalIp); System.setProperty(Constants.DUBBO_IP_TO_REGISTRY, linkLocalIp); } service = new ServiceConfig<>(); service.setApplication(application); service.setRegistry(new RegistryConfig(RegistryConfig.NO_AVAILABLE)); service.setProtocol(new ProtocolConfig("dubbo", PickUnusedPort.get())); service.setInterface(GreeterService.class); service.setRef((method, parameterTypes, args) -> { requestQueue.add(extractor.extract(RpcContext.getContext().getAttachments())); return args[0]; }); }
Example #3
Source File: DubboUtilsTest.java From Sentinel with Apache License 2.0 | 6 votes |
@Test public void testGetInterfaceName() { URL url = URL.valueOf("dubbo://127.0.0.1:2181") .addParameter(CommonConstants.VERSION_KEY, "1.0.0") .addParameter(CommonConstants.GROUP_KEY, "grp1") .addParameter(CommonConstants.INTERFACE_KEY, DemoService.class.getName()); Invoker invoker = mock(Invoker.class); when(invoker.getUrl()).thenReturn(url); when(invoker.getInterface()).thenReturn(DemoService.class); SentinelConfig.setConfig(DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "false"); assertEquals("com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService", DubboUtils.getInterfaceName(invoker)); SentinelConfig.setConfig(DUBBO_INTERFACE_GROUP_VERSION_ENABLED, "true"); assertEquals("com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:1.0.0:grp1", DubboUtils.getInterfaceName(invoker)); }
Example #4
Source File: DubboUtilsTest.java From Sentinel with Apache License 2.0 | 6 votes |
@Test public void testGetResourceNameWithGroupAndVersion() throws NoSuchMethodException { Invoker invoker = mock(Invoker.class); URL url = URL.valueOf("dubbo://127.0.0.1:2181") .addParameter(CommonConstants.VERSION_KEY, "1.0.0") .addParameter(CommonConstants.GROUP_KEY, "grp1") .addParameter(CommonConstants.INTERFACE_KEY, DemoService.class.getName()); when(invoker.getUrl()).thenReturn(url); when(invoker.getInterface()).thenReturn(DemoService.class); Invocation invocation = mock(Invocation.class); Method method = DemoService.class.getDeclaredMethod("sayHello", String.class, int.class); when(invocation.getMethodName()).thenReturn(method.getName()); when(invocation.getParameterTypes()).thenReturn(method.getParameterTypes()); String resourceNameUseGroupAndVersion = DubboUtils.getResourceName(invoker, invocation, true); assertEquals("com.alibaba.csp.sentinel.adapter.dubbo.provider.DemoService:1.0.0:grp1:sayHello(java.lang.String,int)", resourceNameUseGroupAndVersion); }
Example #5
Source File: DubboSofaTracerFilter.java From sofa-tracer with Apache License 2.0 | 6 votes |
/** * set rpc server span tags * @param invoker * @param sofaTracerSpan */ private void appendRpcServerSpanTags(Invoker<?> invoker, SofaTracerSpan sofaTracerSpan) { if (sofaTracerSpan == null) { return; } RpcContext rpcContext = RpcContext.getContext(); Map<String, String> tagsStr = sofaTracerSpan.getTagsWithStr(); tagsStr.put(Tags.SPAN_KIND.getKey(), spanKind(rpcContext)); String service = invoker.getInterface().getName(); tagsStr.put(CommonSpanTags.SERVICE, service == null ? BLANK : service); String methodName = rpcContext.getMethodName(); tagsStr.put(CommonSpanTags.METHOD, methodName == null ? BLANK : methodName); String app = rpcContext.getUrl().getParameter(CommonConstants.APPLICATION_KEY); tagsStr.put(CommonSpanTags.REMOTE_HOST, rpcContext.getRemoteHost()); tagsStr.put(CommonSpanTags.LOCAL_APP, app == null ? BLANK : app); tagsStr.put(CommonSpanTags.CURRENT_THREAD_NAME, Thread.currentThread().getName()); String protocol = rpcContext.getUrl().getProtocol(); tagsStr.put(CommonSpanTags.PROTOCOL, protocol == null ? BLANK : protocol); tagsStr.put(CommonSpanTags.LOCAL_HOST, rpcContext.getRemoteHost()); tagsStr.put(CommonSpanTags.LOCAL_PORT, String.valueOf(rpcContext.getRemotePort())); }
Example #6
Source File: DubboAppContextFilter.java From Sentinel with Apache License 2.0 | 5 votes |
@Override public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { String application = invoker.getUrl().getParameter(CommonConstants.APPLICATION_KEY); if (application != null) { RpcContext.getContext().setAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, application); } return invoker.invoke(invocation); }
Example #7
Source File: MetadataLocalPropertiesConsumer.java From dubbo-samples with Apache License 2.0 | 5 votes |
private static void printServiceData() throws Exception { Thread.sleep(3000); System.out.println("*********************************************************"); System.out.println("service metadata:"); System.out.println(ZkUtil.getMetadata("/dubbo", DemoService.class.getName(), CommonConstants.CONSUMER_SIDE, "metadatareport-local-properties-consumer")); System.out.println("*********************************************************"); }
Example #8
Source File: MetadataLocalPropertiesProvider.java From dubbo-samples with Apache License 2.0 | 5 votes |
private static void printServiceData() throws Exception { Thread.sleep(3000); System.out.println("*********************************************************"); System.out.println("service metadata:"); System.out.println(ZkUtil.getMetadata("/dubbo", DemoService.class.getName(), CommonConstants.PROVIDER_SIDE, "metadatareport-local-properties-provider2")); System.out.println("*********************************************************"); }
Example #9
Source File: MetadataLocalXmlProvider.java From dubbo-samples with Apache License 2.0 | 5 votes |
private static void printServiceData() throws Exception { Thread.sleep(3000); System.out.println("*********************************************************"); System.out.println("service metadata:"); System.out.println(ZkUtil.getMetadata("/dubbo3", DemoService.class.getName(), CommonConstants.PROVIDER_SIDE, "metadatareport-local-xml-provider2")); System.out.println("*********************************************************"); }
Example #10
Source File: MetadataLocalXmlConsumer.java From dubbo-samples with Apache License 2.0 | 5 votes |
private static void printServiceData() throws Exception { Thread.sleep(3000); System.out.println("*********************************************************"); System.out.println("service metadata:"); System.out.println(ZkUtil.getMetadata("/dubbo3", DemoService.class.getName(), CommonConstants.CONSUMER_SIDE, "metadatareport-local-xml-consumer2")); System.out.println("*********************************************************"); }
Example #11
Source File: MetadataConfigcenterProvider.java From dubbo-samples with Apache License 2.0 | 5 votes |
private static void printServiceData() throws Exception { Thread.sleep(3000); System.out.println("*********************************************************"); System.out.println("service metadata:"); System.out.println(ZKTools.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.1", "d-test", CommonConstants.PROVIDER_SIDE, "metadatareport-configcenter-provider")); System.out.println("*********************************************************"); }
Example #12
Source File: MetadataConfigcenterConsumer.java From dubbo-samples with Apache License 2.0 | 5 votes |
private static void printServiceData() throws Exception { Thread.sleep(3000); System.out.println("*********************************************************"); System.out.println("service metadata:"); System.out.println(ZKTools.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.1", "d-test", CommonConstants.CONSUMER_SIDE, "metadatareport-configcenter-consumer")); System.out.println("*********************************************************"); }
Example #13
Source File: MetadataLocalAnnotationConsumer.java From dubbo-samples with Apache License 2.0 | 5 votes |
private static void printServiceData() throws Exception { Thread.sleep(3000); System.out.println("*********************************************************"); System.out.println("service metadata:"); System.out.println(ZkUtil.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.8", "d-test", CommonConstants.CONSUMER_SIDE, "metadatareport-local-annotation-consumer")); System.out.println("*********************************************************"); }
Example #14
Source File: MetadataLocalAnnotationProvider.java From dubbo-samples with Apache License 2.0 | 5 votes |
private static void printServiceData() throws Exception { Thread.sleep(3000); System.out.println("*********************************************************"); System.out.println("service metadata:"); System.out.println(ZkUtil.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.8", "d-test", CommonConstants.PROVIDER_SIDE, "metadatareport-local-annotaion-provider")); System.out.println("*********************************************************"); }
Example #15
Source File: DubboTestUtil.java From Sentinel with Apache License 2.0 | 5 votes |
public static URL getDefaultTestURL() { URL url = URL.valueOf("dubbo://127.0.0.1:2181") .addParameter(CommonConstants.VERSION_KEY, "1.0.0") .addParameter(CommonConstants.GROUP_KEY, "grp1") .addParameter(CommonConstants.INTERFACE_KEY, DEFAULT_TEST_SERVICE.getName()); return url; }
Example #16
Source File: SentinelDubboProviderFilterTest.java From Sentinel with Apache License 2.0 | 5 votes |
@Test public void testInvoke() { final String originApplication = "consumerA"; URL url = DubboTestUtil.getDefaultTestURL(); url = url.addParameter(CommonConstants.SIDE_KEY, CommonConstants.PROVIDER_SIDE); Invoker invoker = DubboTestUtil.getMockInvoker(url, DemoService.class); Invocation invocation = DubboTestUtil.getMockInvocation(DemoService.class.getMethods()[0]); when(invocation.getAttachment(DubboUtils.SENTINEL_DUBBO_APPLICATION_KEY, "")) .thenReturn(originApplication); final Result result = mock(Result.class); when(result.hasException()).thenReturn(false); when(result.getException()).thenReturn(new Exception()); when(invoker.invoke(invocation)).thenAnswer(invocationOnMock -> { verifyInvocationStructure(originApplication, invoker, invocation); return result; }); filter.invoke(invoker, invocation); verify(invoker).invoke(invocation); Context context = ContextUtil.getContext(); assertNull(context); }
Example #17
Source File: MetadataIT.java From dubbo-samples with Apache License 2.0 | 4 votes |
/** * <pre> * { * "side": "consumer", * "application": "metadatareport-local-annotation-consumer", * "release": "2.7.2", * "methods": "sayHello", * "lazy": "false", * "sticky": "false", * "dubbo": "2.0.2", * "interface": "org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService", * "version": "1.1.8", * "revision": "1.1.8", * "group": "d-test" * } * </pre> */ @Test public void testConsumerMetadata() throws Exception { String result = ZkUtil.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.8", "d-test", CommonConstants.CONSUMER_SIDE, "metadatareport-local-annotation-consumer"); Gson gson = new Gson(); Map<String, String> map = gson.fromJson(result, Map.class); Assert.assertEquals("consumer", map.get("side")); Assert.assertEquals("metadatareport-local-annotation-consumer", map.get("application")); Assert.assertEquals("sayHello", map.get("methods")); Assert.assertNull(map.get("lazy")); Assert.assertEquals("false", map.get("sticky")); Assert.assertEquals("1.1.8", map.get("version")); Assert.assertEquals("d-test", map.get("group")); Assert.assertEquals(AnnotationService.class.getName(), map.get("interface")); }
Example #18
Source File: MetadataIT.java From dubbo-samples with Apache License 2.0 | 4 votes |
/** * <pre> * { * "side": "consumer", * "release": "2.7.2", * "methods": "sayHello", * "lazy": "false", * "dubbo": "2.0.2", * "interface": "org.apache.dubbo.samples.metadatareport.configcenter.api.AnnotationService", * "version": "1.1.1", * "timeout": "6666", * "revision": "1.1.1", * "application": "metadatareport-configcenter-consumer", * "sticky": "false", * "group": "d-test" * } * </pre> */ @Test public void testConsumerMetadata() throws Exception { String result = ZKTools.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.1", "d-test", CommonConstants.CONSUMER_SIDE, "metadatareport-configcenter-consumer"); Gson gson = new Gson(); Map<String, String> map = gson.fromJson(result, Map.class); Assert.assertEquals("consumer", map.get("side")); Assert.assertEquals("metadatareport-configcenter-consumer", map.get("application")); Assert.assertEquals("sayHello", map.get("methods")); Assert.assertNull(map.get("lazy")); Assert.assertEquals("false", map.get("sticky")); Assert.assertEquals("1.1.1", map.get("version")); Assert.assertEquals("d-test", map.get("group")); Assert.assertEquals("6666", map.get("timeout")); Assert.assertEquals(AnnotationService.class.getName(), map.get("interface")); }
Example #19
Source File: MetadataIT.java From dubbo-samples with Apache License 2.0 | 4 votes |
/** * <pre> * { * "parameters": { * "side": "provider", * "release": "2.7.2", * "methods": "sayHello", * "deprecated": "false", * "dubbo": "2.0.2", * "interface": "org.apache.dubbo.samples.metadatareport.local.xml.api.DemoService", * "generic": "false", * "application": "metadatareport-local-xml-provider2", * "dynamic": "true", * "register": null, * "bean.name": "org.apache.dubbo.samples.metadatareport.local.xml.api.DemoService", * "anyhost": "true" * }, * "canonicalName": "org.apache.dubbo.samples.metadatareport.local.xml.api.DemoService", * "codeSource": "file:/dubbo/incubator-dubbo-samples/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-xml/target/classes/", * "methods": [ * { * "name": "sayHello", * "parameterTypes": [ * "java.lang.String" * ], * "returnType": "java.lang.String" * } * ], * "types": [ * { * "type": "char" * }, * { * "type": "int" * }, * { * "type": "java.lang.String", * "properties": { * "value": { * "type": "char[]" * }, * "hash": { * "type": "int" * } * } * } * ] * } * </pre> */ @Test public void testProviderMetadata() throws Exception { String result = ZkUtil.getMetadata("/dubbo3", DemoService.class.getName(), CommonConstants.PROVIDER_SIDE, "metadatareport-local-xml-provider2"); Gson gson = new Gson(); FullServiceDefinition definition = gson.fromJson(result, FullServiceDefinition.class); Map<String, String> parameters = definition.getParameters(); Assert.assertEquals("provider", parameters.get("side")); Assert.assertEquals("sayHello", parameters.get("methods")); Assert.assertEquals(DemoService.class.getCanonicalName(), parameters.get("interface")); Assert.assertEquals("false", parameters.get("generic")); Assert.assertEquals("metadatareport-local-xml-provider2", parameters.get("application")); Assert.assertEquals("true", parameters.get("dynamic")); Assert.assertEquals("true", parameters.get("anyhost")); Assert.assertEquals(DemoService.class.getCanonicalName(), definition.getCanonicalName()); List<MethodDefinition> methods = definition.getMethods(); Assert.assertEquals(1, methods.size()); MethodDefinition method = methods.get(0); Assert.assertEquals("sayHello", method.getName()); String[] parameterTypes = method.getParameterTypes(); Assert.assertEquals(1, parameterTypes.length); Assert.assertEquals("java.lang.String", parameterTypes[0]); Assert.assertEquals("java.lang.String", method.getReturnType()); }
Example #20
Source File: MetadataIT.java From dubbo-samples with Apache License 2.0 | 4 votes |
/** * <pre> * { * "parameters": { * "side": "provider", * "release": "2.7.2", * "methods": "sayHello", * "deprecated": "false", * "dubbo": "2.0.2", * "interface": "org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService", * "generic": "false", * "async": "true", * "application": "metadatareport-local-properties-provider2", * "dynamic": "true", * "register": null, * "bean.name": "org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService", * "anyhost": "true" * }, * "canonicalName": "org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService", * "codeSource": "file:/github/dubbo/incubator-dubbo-samples/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/target/classes/", * "methods": [ * { * "name": "sayHello", * "parameterTypes": [ * "java.lang.String" * ], * "returnType": "java.lang.String" * } * ], * "types": [ * { * "type": "char" * }, * { * "type": "int" * }, * { * "type": "java.lang.String", * "properties": { * "value": { * "type": "char[]" * }, * "hash": { * "type": "int" * } * } * } * ] * } * </pre> */ @Test public void testProviderMetadata() throws Exception { String result = ZkUtil.getMetadata("/dubbo", DemoService.class.getName(), CommonConstants.PROVIDER_SIDE, "metadatareport-local-properties-provider2"); Gson gson = new Gson(); FullServiceDefinition definition = gson.fromJson(result, FullServiceDefinition.class); Map<String, String> parameters = definition.getParameters(); Assert.assertEquals("provider", parameters.get("side")); Assert.assertEquals("sayHello", parameters.get("methods")); Assert.assertEquals(DemoService.class.getCanonicalName(), parameters.get("interface")); Assert.assertEquals("false", parameters.get("generic")); Assert.assertEquals("metadatareport-local-properties-provider2", parameters.get("application")); Assert.assertEquals("true", parameters.get("dynamic")); Assert.assertEquals("true", parameters.get("anyhost")); Assert.assertEquals(DemoService.class.getCanonicalName(), definition.getCanonicalName()); List<MethodDefinition> methods = definition.getMethods(); Assert.assertEquals(1, methods.size()); MethodDefinition method = methods.get(0); Assert.assertEquals("sayHello", method.getName()); String[] parameterTypes = method.getParameterTypes(); Assert.assertEquals(1, parameterTypes.length); Assert.assertEquals("java.lang.String", parameterTypes[0]); Assert.assertEquals("java.lang.String", method.getReturnType()); }
Example #21
Source File: MetadataIT.java From dubbo-samples with Apache License 2.0 | 3 votes |
/** * <pre> * { * "parameters": { * "side": "provider", * "release": "2.7.2", * "methods": "sayHello", * "deprecated": "false", * "dubbo": "2.0.2", * "threads": "100", * "interface": "org.apache.dubbo.samples.metadatareport.configcenter.api.AnnotationService", * "threadpool": "fixed", * "version": "1.1.1", * "timeout": "5000", * "generic": "false", * "revision": "1.1.1", * "application": "metadatareport-configcenter-provider", * "dynamic": "true", * "register": null, * "bean.name": "ServiceBean:org.apache.dubbo.samples.metadatareport.configcenter.api.AnnotationService:1.1.1:d-test", * "group": "d-test", * "anyhost": "true" * }, * "canonicalName": "org.apache.dubbo.samples.metadatareport.configcenter.api.AnnotationService", * "codeSource": "file:/github/dubbo/incubator-dubbo-samples/dubbo-samples-metadata-report/dubbo-samples-metadata-report-configcenter/target/classes/", * "methods": [ * { * "name": "sayHello", * "parameterTypes": [ * "java.lang.String" * ], * "returnType": "java.lang.String" * } * ], * "types": [ * { * "type": "int" * }, * { * "type": "char" * }, * { * "type": "java.lang.String", * "properties": { * "value": { * "type": "char[]" * }, * "hash": { * "type": "int" * } * } * } * ] * } * </pre> */ @Test public void testProviderMetadata() throws Exception { String result = ZKTools.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.1", "d-test", CommonConstants.PROVIDER_SIDE, "metadatareport-configcenter-provider"); Gson gson = new Gson(); FullServiceDefinition definition = gson.fromJson(result, FullServiceDefinition.class); Map<String, String> parameters = definition.getParameters(); Assert.assertEquals("provider", parameters.get("side")); Assert.assertEquals("sayHello", parameters.get("methods")); Assert.assertEquals("5000", parameters.get("timeout")); Assert.assertEquals("1.1.1", parameters.get("version")); Assert.assertEquals("d-test", parameters.get("group")); Assert.assertEquals("100", parameters.get("threads")); Assert.assertEquals("fixed", parameters.get("threadpool")); Assert.assertEquals(AnnotationService.class.getCanonicalName(), parameters.get("interface")); Assert.assertEquals("false", parameters.get("generic")); Assert.assertEquals("metadatareport-configcenter-provider", parameters.get("application")); Assert.assertEquals("true", parameters.get("dynamic")); Assert.assertEquals("true", parameters.get("anyhost")); Assert.assertEquals(AnnotationService.class.getCanonicalName(), definition.getCanonicalName()); List<MethodDefinition> methods = definition.getMethods(); Assert.assertEquals(1, methods.size()); MethodDefinition method = methods.get(0); Assert.assertEquals("sayHello", method.getName()); String[] parameterTypes = method.getParameterTypes(); Assert.assertEquals(1, parameterTypes.length); Assert.assertEquals("java.lang.String", parameterTypes[0]); Assert.assertEquals("java.lang.String", method.getReturnType()); }
Example #22
Source File: MetadataIT.java From dubbo-samples with Apache License 2.0 | 3 votes |
/** * <pre> * { * "parameters": { * "side": "provider", * "release": "2.7.2", * "methods": "sayHello", * "deprecated": "false", * "dubbo": "2.0.2", * "interface": "org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService", * "version": "1.1.8", * "timeout": "1000", * "generic": "false", * "revision": "1.1.8", * "application": "metadatareport-local-annotaion-provider", * "dynamic": "true", * "register": null, * "bean.name": "ServiceBean:org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService:1.1.8:d-test", * "group": "d-test", * "anyhost": "true" * }, * "canonicalName": "org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService", * "codeSource": "file:/github/dubbo/incubator-dubbo-samples/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/target/classes/", * "methods": [ * { * "name": "sayHello", * "parameterTypes": [ * "java.lang.String" * ], * "returnType": "java.lang.String" * } * ], * "types": [ * { * "type": "char" * }, * { * "type": "int" * }, * { * "type": "java.lang.String", * "properties": { * "value": { * "type": "char[]" * }, * "hash": { * "type": "int" * } * } * } * ] * } * </pre> */ @Test public void testProviderMetadata() throws Exception { String result = ZkUtil.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.8", "d-test", CommonConstants.PROVIDER_SIDE, "metadatareport-local-annotaion-provider"); Gson gson = new Gson(); FullServiceDefinition definition = gson.fromJson(result, FullServiceDefinition.class); Map<String, String> parameters = definition.getParameters(); Assert.assertEquals("provider", parameters.get("side")); Assert.assertEquals("sayHello", parameters.get("methods")); Assert.assertEquals("1000", parameters.get("timeout")); Assert.assertEquals("1.1.8", parameters.get("version")); Assert.assertEquals("d-test", parameters.get("group")); Assert.assertEquals(AnnotationService.class.getCanonicalName(), parameters.get("interface")); Assert.assertEquals("false", parameters.get("generic")); Assert.assertEquals("metadatareport-local-annotaion-provider", parameters.get("application")); Assert.assertEquals("true", parameters.get("dynamic")); Assert.assertEquals("true", parameters.get("anyhost")); Assert.assertEquals(AnnotationService.class.getCanonicalName(), definition.getCanonicalName()); List<MethodDefinition> methods = definition.getMethods(); Assert.assertEquals(1, methods.size()); MethodDefinition method = methods.get(0); Assert.assertEquals("sayHello", method.getName()); String[] parameterTypes = method.getParameterTypes(); Assert.assertEquals(1, parameterTypes.length); Assert.assertEquals("java.lang.String", parameterTypes[0]); Assert.assertEquals("java.lang.String", method.getReturnType()); }
Example #23
Source File: MetadataIT.java From dubbo-samples with Apache License 2.0 | 3 votes |
/** * <pre> * { * "side": "consumer", * "application": "metadatareport-local-xml-consumer2", * "release": "2.7.2", * "methods": "sayHello", * "lazy": "false", * "sticky": "false", * "dubbo": "2.0.2", * "interface": "org.apache.dubbo.samples.metadatareport.local.xml.api.DemoService" * } * </pre> */ @Test public void testConsumerMetadata() throws Exception { String result = ZkUtil.getMetadata("/dubbo3", DemoService.class.getName(), CommonConstants.CONSUMER_SIDE, "metadatareport-local-xml-consumer2"); Gson gson = new Gson(); Map<String, String> map = gson.fromJson(result, Map.class); Assert.assertEquals("consumer", map.get("side")); Assert.assertEquals("metadatareport-local-xml-consumer2", map.get("application")); Assert.assertEquals("sayHello", map.get("methods")); Assert.assertNull(map.get("lazy")); Assert.assertEquals("false", map.get("sticky")); Assert.assertEquals(DemoService.class.getName(), map.get("interface")); }
Example #24
Source File: MetadataIT.java From dubbo-samples with Apache License 2.0 | 3 votes |
/** * <pre> * { * "side": "consumer", * "application": "metadatareport-local-properties-consumer", * "release": "2.7.2", * "methods": "sayHello", * "lazy": "false", * "sticky": "false", * "dubbo": "2.0.2", * "interface": "org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService" * } * </pre> */ @Test public void testConsumerMetadata() throws Exception { String result = ZkUtil.getMetadata("/dubbo", DemoService.class.getName(), CommonConstants.CONSUMER_SIDE, "metadatareport-local-properties-consumer"); Gson gson = new Gson(); Map<String, String> map = gson.fromJson(result, Map.class); Assert.assertEquals("consumer", map.get("side")); Assert.assertEquals("metadatareport-local-properties-consumer", map.get("application")); Assert.assertEquals("sayHello", map.get("methods")); Assert.assertNull(map.get("lazy")); Assert.assertEquals("false", map.get("sticky")); Assert.assertEquals(DemoService.class.getName(), map.get("interface")); }