Package com.alibaba.dubbo.config.api

Examples of com.alibaba.dubbo.config.api.User


            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();
View Full Code Here


                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",
View Full Code Here

            reference.setApplication(new ApplicationConfig("bean-consumer"));
            reference.setInterface(DemoService.class);
            reference.setUrl("dubbo://127.0.0.1:29581?scope=remote");
            reference.setGeneric(Constants.GENERIC_SERIALIZATION_BEAN);
            GenericService genericService = reference.get();
            User user = new User();
            user.setName("zhangsan");
            List<User> users = new ArrayList<User>();
            users.add(user);
            Object result = genericService.$invoke("getUsers", new String[]{ReflectUtils.getName(List.class)}, new Object[]{JavaBeanSerializeUtil.serialize(users, JavaBeanAccessor.METHOD)});
            Assert.assertTrue(result instanceof JavaBeanDescriptor);
            JavaBeanDescriptor descriptor = (JavaBeanDescriptor) result;
            Assert.assertTrue(descriptor.isCollectionType());
            Assert.assertEquals(1, descriptor.propertySize());
            descriptor = (JavaBeanDescriptor) descriptor.getProperty(0);
            Assert.assertTrue(descriptor.isBeanType());
            Assert.assertEquals(user.getName(), ((JavaBeanDescriptor) descriptor.getProperty("name")).getPrimitiveProperty());
        } finally {
            if (reference != null) {
                reference.destroy();
            }
            service.unexport();
View Full Code Here

            ref = new ReferenceConfig<DemoService>();
            ref.setApplication(new ApplicationConfig("bean-consumer"));
            ref.setInterface(DemoService.class);
            ref.setUrl("dubbo://127.0.0.1:29581?scope=remote&generic=bean");
            DemoService demoService = ref.get();
            User user = new User();
            user.setName("zhangsan");
            List<User> users = new ArrayList<User>();
            users.add(user);
            List<User> result = demoService.getUsers(users);
            Assert.assertEquals(users.size(), result.size());
            Assert.assertEquals(user.getName(), result.get(0).getName());

            GenericParameter gp = (GenericParameter)reference.get();
            Assert.assertEquals("getUsers", gp.method);
            Assert.assertEquals(1, gp.parameterTypes.length);
            Assert.assertEquals(ReflectUtils.getName(List.class), gp.parameterTypes[0]);
            Assert.assertEquals(1, gp.arguments.length);
            Assert.assertTrue(gp.arguments[0] instanceof JavaBeanDescriptor);
            JavaBeanDescriptor descriptor = (JavaBeanDescriptor)gp.arguments[0];
            Assert.assertTrue(descriptor.isCollectionType());
            Assert.assertEquals(ArrayList.class.getName(), descriptor.getClassName());
            Assert.assertEquals(1, descriptor.propertySize());
            descriptor = (JavaBeanDescriptor)descriptor.getProperty(0);
            Assert.assertTrue(descriptor.isBeanType());
            Assert.assertEquals(User.class.getName(), descriptor.getClassName());
            Assert.assertEquals(user.getName(), ((JavaBeanDescriptor)descriptor.getProperty("name")).getPrimitiveProperty());
            Assert.assertNull(demoService.sayName("zhangsan"));
        } finally {
            if (ref != null) {
                ref.destroy();
            }
View Full Code Here

TOP

Related Classes of com.alibaba.dubbo.config.api.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.