?? servicecustomtest.java
字號:
/*Copyright (c) 2007, Dennis M. SosnoskiAll rights reserved.Redistribution and use in source and binary forms, with or without modification,are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of JiBX nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ONANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.*/package org.jibx.ws.wsdl;import java.util.HashMap;import java.util.List;import java.util.Map;import org.jibx.binding.generator.GlobalCustom;/** * Test code for class handling. */public class ServiceCustomTest extends CustomizationTestBase{ public static final String SIMPLE_SERVICE_CLASS = "<custom property-access='false' force-classes='true'>\n" + " <wsdl>\n" + " <service class='org.jibx.ws.wsdl.Service1'/>\n" + " </wsdl>\n" + " <package property-access='true' name='org.jibx.binding'>\n" + " <class name='generator.DataClass1'/>\n" + " </package>\n" + "</custom>"; public static final String CUSTOMIZED_SERVICE_CLASS1 = "<custom property-access='false' force-classes='true'>\n" + " <wsdl service-base='http://localhost:8080/jibxsoap/'>\n" + " <service class='org.jibx.ws.wsdl.Service1'\n" + " includes='getTypedList setTypedList getList setList'\n" + " service-name='MyService' port-name='MyPort'\n" + " binding-name='MyBinding' port-type-name='MyPortType'\n" + " wsdl-namespace='urn:a' namespace='urn:b'>\n" + " <operation method-name='getList' request-message='glreq'\n" + " request-wrapper='glreqwrap' response-message='glrsp'\n" + " response-wrapper='glrspwrap' soap-action='urn:gl'>\n" + " <collection-return\n" + " item-type='org.jibx.binding.generator.DataClass1'/>\n" + " </operation>\n" + " <operation method-name='setList'>\n" + " <collection-parameter name='list' element-name='data-classes'\n" + " item-type='org.jibx.binding.generator.DataClass1'/>\n" + " </operation>\n" + " </service>\n" + " </wsdl>\n" + " <package property-access='true' name='org.jibx.binding'>\n" + " <class name='generator.DataClass1'/>\n" + " </package>\n" + "</custom>"; public void testSimpleServiceClass() throws Exception { GlobalCustom custom = readCustom(SIMPLE_SERVICE_CLASS); List extens = custom.getExtensionChildren(); assertEquals("extension count", 1, extens.size()); Object item = extens.get(0); assertTrue("extension child type", item instanceof WsdlCustom); WsdlCustom wsdl = (WsdlCustom)item; List services = wsdl.getServices(); assertEquals("service count", 1, services.size()); ServiceCustom service = (ServiceCustom)services.get(0); assertEquals("service name", "Service1", service.getServiceName()); assertEquals("service port", "Service1Port", service.getPortName()); assertEquals("service binding", "Service1Binding", service.getBindingName()); assertEquals("service portType", "Service1PortType", service.getPortTypeName()); assertEquals("service wsdl namespace", "http://jibx.org/ws/wsdl/Service1", service.getWsdlNamespace()); assertEquals("service schema namespace", "http://jibx.org/ws/wsdl/Service1", service.getNamespace()); assertNull("service address", service.getServiceAddress()); List operations = service.getOperations(); assertEquals("operation count", 7, operations.size()); Map opmap = new HashMap(); for (int i = 0; i < operations.size(); i++) { OperationCustom op = (OperationCustom)operations.get(i); opmap.put(op.getOperationName(), op); } // getDataClass1 method and operation OperationCustom op = (OperationCustom)opmap.get("getDataClass1"); assertNotNull("getDataClass1 operation", op); assertEquals("getDataClass1 request message", "getDataClass1Message", op.getRequestMessageName()); assertEquals("getDataClass1 request wrapper", "getDataClass1", op.getRequestWrapperName()); assertEquals("getDataClass1 response message", "getDataClass1ResponseMessage", op.getResponseMessageName()); assertEquals("getDataClass1 response wrapper", "getDataClass1Response", op.getResponseWrapperName()); List params = op.getParameters(); assertEquals("getDataClass1 parameters count", 0, params.size()); ValueCustom ret = op.getReturn(); assertEquals("getDataClass1 returned type", "org.jibx.binding.generator.DataClass1", ret.getType()); assertNull("getDataClass1 returned element name", ret.getElementName()); // setDataClass1 method and operation op = (OperationCustom)opmap.get("setDataClass1"); assertNotNull("setDataClass1 operation", op); assertEquals("setDataClass1 request message", "setDataClass1Message", op.getRequestMessageName()); assertEquals("setDataClass1 request wrapper", "setDataClass1", op.getRequestWrapperName()); assertEquals("setDataClass1 response message", "setDataClass1ResponseMessage", op.getResponseMessageName()); assertEquals("setDataClass1 response wrapper", "setDataClass1Response", op.getResponseWrapperName()); params = op.getParameters(); assertEquals("setDataClass1 parameters count", 1, params.size()); ValueCustom param = (ValueCustom)params.get(0); assertEquals("setDataClass1 parameter type", "org.jibx.binding.generator.DataClass1", param.getType()); assertEquals("setDataClass1 returned element name", "data", param.getElementName()); ret = op.getReturn(); assertEquals("setDataClass1 returned type", "void", ret.getType()); assertNull("setDataClass1 returned element name", ret.getElementName()); // changeDataClass1 method and operation op = (OperationCustom)opmap.get("changeDataClass1"); assertNotNull("changeDataClass1 operation", op); assertEquals("changeDataClass1 request message", "changeDataClass1Message", op.getRequestMessageName()); assertEquals("changeDataClass1 request wrapper", "changeDataClass1", op.getRequestWrapperName()); assertEquals("changeDataClass1 response message", "changeDataClass1ResponseMessage", op.getResponseMessageName()); assertEquals("changeDataClass1 response wrapper", "changeDataClass1Response", op.getResponseWrapperName()); params = op.getParameters(); assertEquals("setDataClass1 parameters count", 2, params.size()); param = (ValueCustom)params.get(0); assertEquals("changeDataClass1 parameter type", "int", param.getType()); assertEquals("changeDataClass1 returned element name", "index", param.getElementName()); param = (ValueCustom)params.get(1); assertEquals("changeDataClass1 parameter type", "org.jibx.binding.generator.DataClass1", param.getType()); assertEquals("changeDataClass1 returned element name", "data", param.getElementName()); ret = op.getReturn(); assertEquals("changeDataClass1 returned type", "org.jibx.binding.generator.DataClass1", ret.getType()); assertNull("changeDataClass1 returned element name", ret.getElementName()); // getTypedList method and operation op = (OperationCustom)opmap.get("getTypedList"); assertNotNull("getTypedList operation", op); assertEquals("getTypedList request message", "getTypedListMessage", op.getRequestMessageName()); assertEquals("getTypedList request wrapper", "getTypedList", op.getRequestWrapperName());
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -