|
Apache CXF example source code file (ReflectionServiceFactoryTest.java)
The Apache CXF ReflectionServiceFactoryTest.java source code/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ package org.apache.cxf.service.factory; import java.lang.reflect.Method; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.xml.bind.JAXBException; import javax.xml.namespace.QName; import org.apache.cxf.binding.soap.model.SoapBindingInfo; import org.apache.cxf.binding.soap.model.SoapOperationInfo; import org.apache.cxf.endpoint.Endpoint; import org.apache.cxf.endpoint.Server; import org.apache.cxf.frontend.ServerFactoryBean; import org.apache.cxf.no_body_parts.NoBodyPartsImpl; import org.apache.cxf.service.Service; import org.apache.cxf.service.model.BindingInfo; import org.apache.cxf.service.model.BindingOperationInfo; import org.apache.cxf.service.model.EndpointInfo; import org.apache.cxf.service.model.InterfaceInfo; import org.apache.cxf.service.model.MessageInfo; import org.apache.cxf.service.model.MessagePartInfo; import org.apache.cxf.service.model.OperationInfo; import org.apache.cxf.service.model.ServiceInfo; import org.apache.ws.commons.schema.XmlSchemaElement; import org.junit.Test; public class ReflectionServiceFactoryTest extends AbstractSimpleFrontendTest { private ReflectionServiceFactoryBean serviceFactory; @Test public void testUnwrappedBuild() throws Exception { Service service = createService(false); ServiceInfo si = service.getServiceInfos().get(0); InterfaceInfo intf = si.getInterface(); assertEquals(4, intf.getOperations().size()); String ns = si.getName().getNamespaceURI(); OperationInfo sayHelloOp = intf.getOperation(new QName(ns, "sayHello")); assertNotNull(sayHelloOp); assertEquals("sayHello", sayHelloOp.getInput().getName().getLocalPart()); List<MessagePartInfo> messageParts = sayHelloOp.getInput().getMessageParts(); assertEquals(0, messageParts.size()); // test output messageParts = sayHelloOp.getOutput().getMessageParts(); assertEquals(1, messageParts.size()); assertEquals("sayHelloResponse", sayHelloOp.getOutput().getName().getLocalPart()); MessagePartInfo mpi = messageParts.get(0); assertEquals("return", mpi.getName().getLocalPart()); assertEquals(String.class, mpi.getTypeClass()); OperationInfo op = si.getInterface().getOperation(new QName(ns, "echoWithExchange")); assertEquals(1, op.getInput().getMessageParts().size()); } @Test public void testWrappedBuild() throws Exception { Service service = createService(true); ServiceInfo si = service.getServiceInfos().get(0); InterfaceInfo intf = si.getInterface(); assertEquals(4, intf.getOperations().size()); String ns = si.getName().getNamespaceURI(); OperationInfo sayHelloOp = intf.getOperation(new QName(ns, "sayHello")); assertNotNull(sayHelloOp); assertEquals("sayHello", sayHelloOp.getInput().getName().getLocalPart()); List<MessagePartInfo> messageParts = sayHelloOp.getInput().getMessageParts(); assertEquals(1, messageParts.size()); assertNotNull(messageParts.get(0).getXmlSchema()); // test unwrapping assertTrue(sayHelloOp.isUnwrappedCapable()); OperationInfo unwrappedOp = sayHelloOp.getUnwrappedOperation(); assertEquals("sayHello", unwrappedOp.getInput().getName().getLocalPart()); messageParts = unwrappedOp.getInput().getMessageParts(); assertEquals(0, messageParts.size()); // test output messageParts = sayHelloOp.getOutput().getMessageParts(); assertEquals(1, messageParts.size()); assertEquals("sayHelloResponse", sayHelloOp.getOutput().getName().getLocalPart()); messageParts = unwrappedOp.getOutput().getMessageParts(); assertEquals("sayHelloResponse", unwrappedOp.getOutput().getName().getLocalPart()); assertEquals(1, messageParts.size()); MessagePartInfo mpi = messageParts.get(0); assertEquals("return", mpi.getName().getLocalPart()); assertEquals(String.class, mpi.getTypeClass()); } private Service createService(boolean wrapped) throws JAXBException { serviceFactory = new ReflectionServiceFactoryBean(); serviceFactory.setBus(getBus()); serviceFactory.setServiceClass(HelloService.class); serviceFactory.setWrapped(wrapped); Map<String, Object> props = new HashMap Other Apache CXF examples (source code examples)Here is a short list of links related to this Apache CXF ReflectionServiceFactoryTest.java source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.