⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 annotationservicefactorytest.java

📁 Xfire文件 用于开发web service 的一个开源工具 很好用的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        webAnnotations.hasWebResultAnnotation(echoMethod);        webAnnotationsControl.setDefaultReturnValue(false);        echoMethod = EchoService.class.getMethod("echo", new Class[]{String.class});        WebMethodAnnotation wma = new WebMethodAnnotation();        wma.setAction("test");        webAnnotations.getWebMethodAnnotation(echoMethod);        webAnnotationsControl.setDefaultReturnValue(wma);                webAnnotations.hasWebParamAnnotation(echoMethod, 0);        webAnnotationsControl.setDefaultReturnValue(false);        webAnnotations.hasOnewayAnnotation(echoMethod);        webAnnotationsControl.setDefaultReturnValue(false);        webAnnotations.hasWebResultAnnotation(echoMethod);        webAnnotationsControl.setDefaultReturnValue(false);                webAnnotations.getServiceProperties(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(new Properties());                webAnnotations.getInHandlers(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(Collections.EMPTY_LIST);                webAnnotations.getOutHandlers(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(Collections.EMPTY_LIST);                webAnnotations.getFaultHandlers(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(Collections.EMPTY_LIST);        webAnnotationsControl.replay();        Service endpoint = annotationServiceFactory.create(EchoServiceImpl.class);        ServiceInfo service = endpoint.getServiceInfo();        assertEquals(new QName("http://xfire.codehaus.org/EchoService", "Echo"), endpoint.getName());        assertEquals(new QName("http://xfire.codehaus.org/EchoService", "EchoPortType"),                      service.getPortType());        QName portName = (QName) endpoint.getProperty(ObjectServiceFactory.PORT_NAME);        assertNotNull(portName);        assertEquals("EchoPort", portName.getLocalPart());                webAnnotationsControl.verify();    }    public void testParameterNameAnnotation()            throws SecurityException, NoSuchMethodException    {        webAnnotations.hasSOAPBindingAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setReturnValue(false);        webAnnotations.hasWebServiceAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setReturnValue(true);        webAnnotations.hasHandlerChainAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(false);                WebServiceAnnotation implAnnotation = new WebServiceAnnotation();        implAnnotation.setServiceName("Echo");        implAnnotation.setTargetNamespace("http://xfire.codehaus.org/EchoService");        webAnnotations.getWebServiceAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setReturnValue(implAnnotation);        webAnnotations.getWebServiceAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setReturnValue(implAnnotation);        setupEchoMock();                Method asyncMethod = EchoServiceImpl.class.getMethod("async", new Class[0]);        webAnnotations.hasWebMethodAnnotation(asyncMethod);        webAnnotationsControl.setDefaultReturnValue(false);        webAnnotations.getServiceProperties(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(new Properties());                webAnnotations.getInHandlers(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(Collections.EMPTY_LIST);                webAnnotations.getOutHandlers(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(Collections.EMPTY_LIST);                webAnnotations.getFaultHandlers(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(Collections.EMPTY_LIST);                webAnnotationsControl.replay();        Service endpoint = annotationServiceFactory.create(EchoServiceImpl.class);        ServiceInfo service = endpoint.getServiceInfo();        assertEquals(new QName("http://xfire.codehaus.org/EchoService", "Echo"), endpoint.getName());        final OperationInfo operation = service.getOperation("echo");        assertNotNull(operation);        Collection parts = operation.getInputMessage().getMessageParts();        assertEquals(1, parts.size());        assertEquals("input", ((MessagePartInfo) parts.iterator().next()).getName().getLocalPart());        webAnnotationsControl.verify();    }    public void testSOAPBindingAnnotation()            throws Exception    {        webAnnotations.hasSOAPBindingAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setReturnValue(true);        webAnnotations.hasHandlerChainAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(false);                SOAPBindingAnnotation soapBinding = new SOAPBindingAnnotation();        soapBinding.setUse(SOAPBindingAnnotation.USE_LITERAL);        webAnnotations.getSOAPBindingAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setReturnValue(soapBinding);        webAnnotations.hasWebServiceAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setReturnValue(true);        WebServiceAnnotation webservice = new WebServiceAnnotation();        webservice.setServiceName("EchoService");        webservice.setTargetNamespace("http://xfire.codehaus.org/EchoService");        webAnnotations.getWebServiceAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setReturnValue(webservice);        webAnnotations.getWebServiceAnnotation(EchoServiceImpl.class);        webAnnotationsControl.setReturnValue(webservice);        setupEchoMock();        Method asyncMethod = EchoServiceImpl.class.getMethod("async", new Class[0]);        webAnnotations.hasWebMethodAnnotation(asyncMethod);        webAnnotationsControl.setDefaultReturnValue(false);                webAnnotations.getServiceProperties(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(new Properties());                webAnnotations.getInHandlers(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(Collections.EMPTY_LIST);                webAnnotations.getOutHandlers(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(Collections.EMPTY_LIST);                webAnnotations.getFaultHandlers(EchoServiceImpl.class);        webAnnotationsControl.setDefaultReturnValue(Collections.EMPTY_LIST);                webAnnotationsControl.replay();        Service service = annotationServiceFactory.create(EchoServiceImpl.class);        AbstractSoapBinding binding = (AbstractSoapBinding) service.getBindings().iterator().next();                OperationInfo op = service.getServiceInfo().getOperation("echo");        assertNotNull(op);        assertEquals(SoapConstants.USE_LITERAL, binding.getUse());                webAnnotationsControl.verify();    }    private void setupEchoMock()        throws NoSuchMethodException    {        Method echoMethod = EchoServiceImpl.class.getMethod("echo", new Class[]{String.class});        webAnnotations.hasWebMethodAnnotation(echoMethod);        webAnnotationsControl.setReturnValue(true);        WebMethodAnnotation wma = new WebMethodAnnotation();        wma.setAction("test");        webAnnotations.getWebMethodAnnotation(echoMethod);        webAnnotationsControl.setDefaultReturnValue(wma);                webAnnotations.hasOnewayAnnotation(echoMethod);        webAnnotationsControl.setDefaultReturnValue(false);        webAnnotations.hasWebParamAnnotation(echoMethod, 0);        webAnnotationsControl.setDefaultReturnValue(true);        WebParamAnnotation paramAnnotation = new WebParamAnnotation();        paramAnnotation.setName("input");        webAnnotations.getWebParamAnnotation(echoMethod, 0);        webAnnotationsControl.setDefaultReturnValue(paramAnnotation);        webAnnotations.hasWebResultAnnotation(echoMethod);        webAnnotationsControl.setDefaultReturnValue(false);                     }        public void testDefaultConstructor()     {        AnnotationServiceFactory factory = new AnnotationServiceFactory();        assertTrue(factory.getAnnotations() instanceof CommonsWebAttributes);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -