com.alibaba.dubbo.config.api.User Java Examples
The following examples show how to use
com.alibaba.dubbo.config.api.User.
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: DemoServiceImpl_LongWaiting.java From dubbo3 with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #2
Source File: GenericServiceTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testGenericSerializationJava() throws Exception { ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); DemoServiceImpl ref = new DemoServiceImpl(); service.setRef(ref); service.export(); try { ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?scope=remote"); reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA); GenericService genericService = reference.get(); try { String name = "kimi"; ByteArrayOutputStream bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(name); byte[] arg = bos.toByteArray(); Object obj = genericService.$invoke("sayName", new String[]{String.class.getName()}, new Object[]{arg}); Assert.assertTrue(obj instanceof byte[]); byte[] result = (byte[]) obj; Assert.assertEquals(ref.sayName(name), ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").deserialize(null, new ByteArrayInputStream(result)).readObject().toString()); // getUsers List<User> users = new ArrayList<User>(); User user = new User(); user.setName(name); users.add(user); bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(users); obj = genericService.$invoke("getUsers", new String[]{List.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); result = (byte[]) obj; Assert.assertEquals(users, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream(result)) .readObject()); // echo(int) bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class).getExtension("nativejava") .serialize(null, bos).writeObject(Integer.MAX_VALUE); obj = genericService.$invoke("echo", new String[]{int.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); Assert.assertEquals(Integer.MAX_VALUE, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream((byte[]) obj)) .readObject()); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #3
Source File: GenericServiceTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testGenericServiceException() { ServiceConfig<GenericService> service = new ServiceConfig<GenericService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); service.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { if ("sayName".equals(method)) { return "Generic " + args[0]; } if ("throwDemoException".equals(method)) { throw new GenericException(DemoException.class.getName(), "Generic"); } if ("getUsers".equals(method)) { return args[0]; } return null; } }); service.export(); try { ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?generic=true"); DemoService demoService = reference.get(); try { // say name Assert.assertEquals("Generic Haha", demoService.sayName("Haha")); // get users List<User> users = new ArrayList<User>(); users.add(new User("Aaa")); users = demoService.getUsers(users); Assert.assertEquals("Aaa", users.get(0).getName()); // throw demo exception try { demoService.throwDemoException(); Assert.fail(); } catch (DemoException e) { Assert.assertEquals("Generic", e.getMessage()); } } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #4
Source File: UnserializableBoxDemoServiceImpl.java From dubbox with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #5
Source File: DemoServiceImpl_LongWaiting.java From dubbox with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #6
Source File: DemoServiceImpl.java From dubbox with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #7
Source File: GenericServiceTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testGenericSerializationJava() throws Exception { ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); DemoServiceImpl ref = new DemoServiceImpl(); service.setRef(ref); service.export(); try { ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?scope=remote"); reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA); GenericService genericService = reference.get(); try { String name = "kimi"; ByteArrayOutputStream bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(name); byte[] arg = bos.toByteArray(); Object obj = genericService.$invoke("sayName", new String[]{String.class.getName()}, new Object[]{arg}); Assert.assertTrue(obj instanceof byte[]); byte[] result = (byte[]) obj; Assert.assertEquals(ref.sayName(name), ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").deserialize(null, new ByteArrayInputStream(result)).readObject().toString()); // getUsers List<User> users = new ArrayList<User>(); User user = new User(); user.setName(name); users.add(user); bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(users); obj = genericService.$invoke("getUsers", new String[]{List.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); result = (byte[]) obj; Assert.assertEquals(users, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream(result)) .readObject()); // echo(int) bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class).getExtension("nativejava") .serialize(null, bos).writeObject(Integer.MAX_VALUE); obj = genericService.$invoke("echo", new String[]{int.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); Assert.assertEquals(Integer.MAX_VALUE, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream((byte[]) obj)) .readObject()); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #8
Source File: GenericServiceTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testGenericServiceException() { ServiceConfig<GenericService> service = new ServiceConfig<GenericService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); service.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { if ("sayName".equals(method)) { return "Generic " + args[0]; } if ("throwDemoException".equals(method)) { throw new GenericException(DemoException.class.getName(), "Generic"); } if ("getUsers".equals(method)) { return args[0]; } return null; } }); service.export(); try { ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?generic=true"); DemoService demoService = reference.get(); try { // say name Assert.assertEquals("Generic Haha", demoService.sayName("Haha")); // get users List<User> users = new ArrayList<User>(); users.add(new User("Aaa")); users = demoService.getUsers(users); Assert.assertEquals("Aaa", users.get(0).getName()); // throw demo exception try { demoService.throwDemoException(); Assert.fail(); } catch (DemoException e) { Assert.assertEquals("Generic", e.getMessage()); } } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #9
Source File: UnserializableBoxDemoServiceImpl.java From dubbox with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #10
Source File: DemoServiceImpl_LongWaiting.java From dubbox with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #11
Source File: DemoServiceImpl.java From dubbox with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #12
Source File: GenericServiceTest.java From dubbo3 with Apache License 2.0 | 4 votes |
@Test public void testGenericSerializationJava() throws Exception { ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); DemoServiceImpl ref = new DemoServiceImpl(); service.setRef(ref); service.export(); try { ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?scope=remote"); reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA); GenericService genericService = reference.get(); try { String name = "kimi"; ByteArrayOutputStream bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(name); byte[] arg = bos.toByteArray(); Object obj = genericService.$invoke("sayName", new String[]{String.class.getName()}, new Object[]{arg}); Assert.assertTrue(obj instanceof byte[]); byte[] result = (byte[]) obj; Assert.assertEquals(ref.sayName(name), ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").deserialize(null, new ByteArrayInputStream(result)).readObject().toString()); // getUsers List<User> users = new ArrayList<User>(); User user = new User(); user.setName(name); users.add(user); bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(users); obj = genericService.$invoke("getUsers", new String[]{List.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); result = (byte[]) obj; Assert.assertEquals(users, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream(result)) .readObject()); // echo(int) bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class).getExtension("nativejava") .serialize(null, bos).writeObject(Integer.MAX_VALUE); obj = genericService.$invoke("echo", new String[]{int.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); Assert.assertEquals(Integer.MAX_VALUE, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream((byte[]) obj)) .readObject()); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #13
Source File: GenericServiceTest.java From dubbo3 with Apache License 2.0 | 4 votes |
@Test public void testGenericServiceException() { ServiceConfig<GenericService> service = new ServiceConfig<GenericService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); service.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { if ("sayName".equals(method)) { return "Generic " + args[0]; } if ("throwDemoException".equals(method)) { throw new GenericException(DemoException.class.getName(), "Generic"); } if ("getUsers".equals(method)) { return args[0]; } return null; } }); service.export(); try { ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?generic=true"); DemoService demoService = reference.get(); try { // say name Assert.assertEquals("Generic Haha", demoService.sayName("Haha")); // get users List<User> users = new ArrayList<User>(); users.add(new User("Aaa")); users = demoService.getUsers(users); Assert.assertEquals("Aaa", users.get(0).getName()); // throw demo exception try { demoService.throwDemoException(); Assert.fail(); } catch (DemoException e) { Assert.assertEquals("Generic", e.getMessage()); } } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #14
Source File: UnserializableBoxDemoServiceImpl.java From dubbo3 with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #15
Source File: DemoServiceImpl.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #16
Source File: DemoServiceImpl.java From dubbo3 with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #17
Source File: GenericServiceTest.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
@Test public void testGenericSerializationJava() throws Exception { ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); DemoServiceImpl ref = new DemoServiceImpl(); service.setRef(ref); service.export(); try { ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?scope=remote"); reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA); GenericService genericService = reference.get(); try { String name = "kimi"; ByteArrayOutputStream bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(name); byte[] arg = bos.toByteArray(); Object obj = genericService.$invoke("sayName", new String[]{String.class.getName()}, new Object[]{arg}); Assert.assertTrue(obj instanceof byte[]); byte[] result = (byte[]) obj; Assert.assertEquals(ref.sayName(name), ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").deserialize(null, new ByteArrayInputStream(result)).readObject().toString()); // getUsers List<User> users = new ArrayList<User>(); User user = new User(); user.setName(name); users.add(user); bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(users); obj = genericService.$invoke("getUsers", new String[]{List.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); result = (byte[]) obj; Assert.assertEquals(users, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream(result)) .readObject()); // echo(int) bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class).getExtension("nativejava") .serialize(null, bos).writeObject(Integer.MAX_VALUE); obj = genericService.$invoke("echo", new String[]{int.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); Assert.assertEquals(Integer.MAX_VALUE, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream((byte[]) obj)) .readObject()); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #18
Source File: GenericServiceTest.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
@Test public void testGenericServiceException() { ServiceConfig<GenericService> service = new ServiceConfig<GenericService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); service.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { if ("sayName".equals(method)) { return "Generic " + args[0]; } if ("throwDemoException".equals(method)) { throw new GenericException(DemoException.class.getName(), "Generic"); } if ("getUsers".equals(method)) { return args[0]; } return null; } }); service.export(); try { ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?generic=true"); DemoService demoService = reference.get(); try { // say name Assert.assertEquals("Generic Haha", demoService.sayName("Haha")); // get users List<User> users = new ArrayList<User>(); users.add(new User("Aaa")); users = demoService.getUsers(users); Assert.assertEquals("Aaa", users.get(0).getName()); // throw demo exception try { demoService.throwDemoException(); Assert.fail(); } catch (DemoException e) { Assert.assertEquals("Generic", e.getMessage()); } } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #19
Source File: UnserializableBoxDemoServiceImpl.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #20
Source File: DemoServiceImpl_LongWaiting.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #21
Source File: DemoServiceImpl.java From dubbox-hystrix with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #22
Source File: GenericServiceTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testGenericSerializationJava() throws Exception { ServiceConfig<DemoService> service = new ServiceConfig<DemoService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); DemoServiceImpl ref = new DemoServiceImpl(); service.setRef(ref); service.export(); try { ReferenceConfig<GenericService> reference = new ReferenceConfig<GenericService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?scope=remote"); reference.setGeneric(Constants.GENERIC_SERIALIZATION_NATIVE_JAVA); GenericService genericService = reference.get(); try { String name = "kimi"; ByteArrayOutputStream bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(name); byte[] arg = bos.toByteArray(); Object obj = genericService.$invoke("sayName", new String[]{String.class.getName()}, new Object[]{arg}); Assert.assertTrue(obj instanceof byte[]); byte[] result = (byte[]) obj; Assert.assertEquals(ref.sayName(name), ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").deserialize(null, new ByteArrayInputStream(result)).readObject().toString()); // getUsers List<User> users = new ArrayList<User>(); User user = new User(); user.setName(name); users.add(user); bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava").serialize(null, bos).writeObject(users); obj = genericService.$invoke("getUsers", new String[]{List.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); result = (byte[]) obj; Assert.assertEquals(users, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream(result)) .readObject()); // echo(int) bos = new ByteArrayOutputStream(512); ExtensionLoader.getExtensionLoader(Serialization.class).getExtension("nativejava") .serialize(null, bos).writeObject(Integer.MAX_VALUE); obj = genericService.$invoke("echo", new String[]{int.class.getName()}, new Object[]{bos.toByteArray()}); Assert.assertTrue(obj instanceof byte[]); Assert.assertEquals(Integer.MAX_VALUE, ExtensionLoader.getExtensionLoader(Serialization.class) .getExtension("nativejava") .deserialize(null, new ByteArrayInputStream((byte[]) obj)) .readObject()); } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #23
Source File: GenericServiceTest.java From dubbox with Apache License 2.0 | 4 votes |
@Test public void testGenericServiceException() { ServiceConfig<GenericService> service = new ServiceConfig<GenericService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); service.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { if ("sayName".equals(method)) { return "Generic " + args[0]; } if ("throwDemoException".equals(method)) { throw new GenericException(DemoException.class.getName(), "Generic"); } if ("getUsers".equals(method)) { return args[0]; } return null; } }); service.export(); try { ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?generic=true"); DemoService demoService = reference.get(); try { // say name Assert.assertEquals("Generic Haha", demoService.sayName("Haha")); // get users List<User> users = new ArrayList<User>(); users.add(new User("Aaa")); users = demoService.getUsers(users); Assert.assertEquals("Aaa", users.get(0).getName()); // throw demo exception try { demoService.throwDemoException(); Assert.fail(); } catch (DemoException e) { Assert.assertEquals("Generic", e.getMessage()); } } finally { reference.destroy(); } } finally { service.unexport(); } }
Example #24
Source File: UnserializableBoxDemoServiceImpl.java From dubbox with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #25
Source File: DemoServiceImpl_LongWaiting.java From dubbox with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #26
Source File: DemoServiceImpl.java From dubbox with Apache License 2.0 | 4 votes |
public List<User> getUsers(List<User> users) { return users; }
Example #27
Source File: GenericServiceTest.java From dubbo-2.6.5 with Apache License 2.0 | 4 votes |
@Test public void testGenericServiceException() { ServiceConfig<GenericService> service = new ServiceConfig<GenericService>(); service.setApplication(new ApplicationConfig("generic-provider")); service.setRegistry(new RegistryConfig("N/A")); service.setProtocol(new ProtocolConfig("dubbo", 29581)); service.setInterface(DemoService.class.getName()); service.setRef(new GenericService() { public Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException { if ("sayName".equals(method)) { return "Generic " + args[0]; } if ("throwDemoException".equals(method)) { throw new GenericException(DemoException.class.getName(), "Generic"); } if ("getUsers".equals(method)) { return args[0]; } return null; } }); service.export(); try { ReferenceConfig<DemoService> reference = new ReferenceConfig<DemoService>(); reference.setApplication(new ApplicationConfig("generic-consumer")); reference.setInterface(DemoService.class); reference.setUrl("dubbo://127.0.0.1:29581?generic=true&timeout=3000"); DemoService demoService = reference.get(); try { // say name Assert.assertEquals("Generic Haha", demoService.sayName("Haha")); // get users List<User> users = new ArrayList<User>(); users.add(new User("Aaa")); users = demoService.getUsers(users); Assert.assertEquals("Aaa", users.get(0).getName()); // throw demo exception try { demoService.throwDemoException(); Assert.fail(); } catch (DemoException e) { Assert.assertEquals("Generic", e.getMessage()); } } finally { reference.destroy(); } } finally { service.unexport(); } }