servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r486573 - in /incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java: org/apache/servicemix/jsr181/ test/complex/ test/complex/model/ test/model/
Date Wed, 13 Dec 2006 09:59:30 GMT
Author: gnodet
Date: Wed Dec 13 01:59:29 2006
New Revision: 486573

URL: http://svn.apache.org/viewvc?view=rev&rev=486573
Log:
SM-739: wsdl for pojos exported by jsr181 endpoint is missing complextypes from other namespaces
than the service itself.
Thanks to Christian Schneider and Ken Berthelot

Added:
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexTypeTest.java
  (with props)
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderService.java
  (with props)
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderServiceImpl.java
  (with props)
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/Cart.java
  (with props)
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderConfirmation.java
  (with props)
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderItem.java
  (with props)
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/model/

Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexTypeTest.java?view=auto&rev=486573
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexTypeTest.java
(added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexTypeTest.java
Wed Dec 13 01:59:29 2006
@@ -0,0 +1,174 @@
+/*
+ * 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.servicemix.jsr181;
+
+import java.util.ArrayList;
+import java.util.EventListener;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.InitialContext;
+import javax.wsdl.Definition;
+import javax.wsdl.extensions.schema.Schema;
+import javax.wsdl.factory.WSDLFactory;
+import javax.wsdl.xml.WSDLReader;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.view.DotViewEndpointListener;
+import org.apache.servicemix.jbi.view.DotViewFlowListener;
+import org.apache.servicemix.jsr181.Jsr181Endpoint;
+import org.apache.servicemix.jsr181.Jsr181Component;
+import org.apache.servicemix.jsr181.xfire.JbiProxyFactoryBean;
+import org.w3c.dom.Document;
+
+import test.complex.OrderService;
+import test.complex.OrderServiceImpl;
+import test.complex.model.Cart;
+import test.complex.model.OrderConfirmation;
+import test.complex.model.OrderItem;
+
+import com.ibm.wsdl.Constants;
+
+/**
+ * This test shows creating and calling a service from a pojo.
+ * The Service is using the common example of an order business process
+ * with a shopping cart. As the business method uses complex in and out parameters
+ * it can show the handling of complex types.
+ * 
+ * This test also checks for jira bug http://issues.apache.org/activemq/browse/SM-739
+ * The WSDLFlattener skips complex types that live in another namespace than the service
+ * 
+ * @author Christian Schneider
+ *
+ */
+public class Jsr181ComplexTypeTest extends TestCase {
+	static final String BROKER_SERVER = "wschris";
+	static final int BROKER_PORT = 61216;
+	
+	private static Log logger =  LogFactory.getLog(Jsr181ComponentTest.class);
+    protected JBIContainer container;
+    
+	protected void setUp() throws Exception {
+		container = new JBIContainer();
+		container.setName("ComplexTypeContainer");
+        container.setUseMBeanServer(false);
+        container.setCreateMBeanServer(false);
+        container.setMonitorInstallationDirectory(false);
+        container.setNamingContext(new InitialContext());
+        container.setEmbedded(true);
+        container.setListeners(new EventListener[]{new DotViewFlowListener(), new DotViewEndpointListener()});
+        container.init();
+    }
+	
+	protected void tearDown() throws Exception {
+        if (container != null) {
+            container.shutDown();
+        }
+    }
+	
+    public void testOrder() throws Exception {
+    	BasicConfigurator.configure(new ConsoleAppender());
+		Logger.getRootLogger().setLevel(Level.DEBUG);
+    	container.start();
+    	
+        Jsr181Component component = new Jsr181Component();
+
+        // Create an xfire endpoint for our pojo order service
+        Jsr181Endpoint orderEndpoint = new Jsr181Endpoint();
+        orderEndpoint.setPojo(new OrderServiceImpl());
+        orderEndpoint.setServiceInterface(OrderService.class.getCanonicalName());
+
+        component.setEndpoints(new Jsr181Endpoint[] { orderEndpoint });
+        container.activateComponent(component, "JSR181Component");
+
+        System.out.println(orderEndpoint.getServiceInterface());
+        System.out.println(orderEndpoint.getInterfaceName());
+        System.out.println(orderEndpoint.getEndpoint());
+        
+        // Create interface based proxy
+        JbiProxyFactoryBean pf = new JbiProxyFactoryBean();
+        pf.setContainer(container);
+        pf.setInterfaceName(orderEndpoint.getInterfaceName());
+        pf.setEndpoint(orderEndpoint.getEndpoint());
+        pf.setType(OrderService.class);
+        OrderService orderService = (OrderService) pf.getObject();
+        
+        // Prepare cart for order request
+        Cart cart = new Cart();
+        OrderItem orderItem = new OrderItem();
+        orderItem.setCount(2);
+        orderItem.setItem("Book");
+        cart.getItems().add(orderItem);
+        
+        // Call the service
+		OrderConfirmation orderConfirmation = orderService.order(cart);
+		orderConfirmation = orderService.order(cart);
+		orderConfirmation = orderService.order(cart);
+		
+		// Check that we get the expected order confirmation 
+		assertNotNull(orderConfirmation);
+		cart = orderConfirmation.getCart();
+		assertNotNull(cart);
+		assertEquals(1, cart.getItems().size());
+		orderItem = cart.getItems().get(0);
+		assertEquals(2, orderItem.getCount());
+		assertEquals("Book", orderItem.getItem());
+		
+		// Analyse the WSDL that is generated from the pojo service
+		Document description = orderEndpoint.getDescription();
+		SourceTransformer transformer = new SourceTransformer();
+		System.out.println(transformer.toString(description));
+		WSDLReader reader = WSDLFactory.newInstance().newWSDLReader();
+        reader.setFeature(Constants.FEATURE_VERBOSE, false);
+        Definition definition = reader.readWSDL(null, description);
+        Map namespaces = definition.getNamespaces();
+        
+        String serviceNameSpace = orderEndpoint.getInterfaceName().getNamespaceURI();
+        String modelNameSpace = "http://model.complex.test";
+        
+        // The WSDL should import the namespaces for the service and the model
+        assertTrue("Namespace "+ serviceNameSpace +" present", namespaces.containsValue(serviceNameSpace));
+        assertTrue("Namespace "+ modelNameSpace+" present", namespaces.containsValue(modelNameSpace));
+        
+        Iterator<Schema> schemaIt = definition.getTypes().getExtensibilityElements().iterator();
+
+        List<String> schemaTargetNameSpaceList = new ArrayList<String>();
+        boolean modelFound = false;
+        while (schemaIt.hasNext()) {
+        	Schema schema = schemaIt.next();
+        	String targetNameSpace = schema.getElement().getAttribute("targetNamespace");
+        	schemaTargetNameSpaceList.add(targetNameSpace);
+        }
+        
+        // There should be type definitions for the service and the model namespace
+        assertTrue("Type definitions present for namespace " + serviceNameSpace, schemaTargetNameSpaceList.contains(serviceNameSpace));
+        assertTrue("Type definitions present for namespace " + modelNameSpace, schemaTargetNameSpaceList.contains(modelNameSpace));
+        
+        // The WSDL should be abstract so we should have no bindings
+        assertEquals("Bindings count ", 0, definition.getBindings().size());
+    }
+}

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexTypeTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexTypeTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/org/apache/servicemix/jsr181/Jsr181ComplexTypeTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderService.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderService.java?view=auto&rev=486573
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderService.java
(added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderService.java
Wed Dec 13 01:59:29 2006
@@ -0,0 +1,25 @@
+/*
+ * 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 test.complex;
+
+import test.complex.model.Cart;
+import test.complex.model.OrderConfirmation;
+
+
+public interface OrderService {
+	public OrderConfirmation order(Cart cart);
+}

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderService.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderService.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderServiceImpl.java?view=auto&rev=486573
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderServiceImpl.java
(added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderServiceImpl.java
Wed Dec 13 01:59:29 2006
@@ -0,0 +1,33 @@
+/*
+ * 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 test.complex;
+
+import test.complex.model.Cart;
+import test.complex.model.OrderConfirmation;
+
+
+
+public class OrderServiceImpl implements OrderService {
+
+	public OrderConfirmation order(Cart cart) {
+		OrderConfirmation oc = new OrderConfirmation();
+		oc.setCart(cart);
+		oc.setPriceSum(100);
+		return oc;
+	}
+
+}

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderServiceImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderServiceImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/OrderServiceImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/Cart.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/Cart.java?view=auto&rev=486573
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/Cart.java
(added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/Cart.java
Wed Dec 13 01:59:29 2006
@@ -0,0 +1,32 @@
+/*
+ * 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 test.complex.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Cart {
+	List<OrderItem> items = new ArrayList<OrderItem>();
+
+	public List<OrderItem> getItems() {
+		return items;
+	}
+
+	public void setItems(List<OrderItem> items) {
+		this.items = items;
+	}
+}

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/Cart.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/Cart.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/Cart.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderConfirmation.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderConfirmation.java?view=auto&rev=486573
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderConfirmation.java
(added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderConfirmation.java
Wed Dec 13 01:59:29 2006
@@ -0,0 +1,35 @@
+/*
+ * 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 test.complex.model;
+
+public class OrderConfirmation {
+	Cart cart;
+	double priceSum;
+	
+	public Cart getCart() {
+		return cart;
+	}
+	public void setCart(Cart cart) {
+		this.cart = cart;
+	}
+	public double getPriceSum() {
+		return priceSum;
+	}
+	public void setPriceSum(double priceSum) {
+		this.priceSum = priceSum;
+	}
+}

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderConfirmation.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderConfirmation.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderConfirmation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderItem.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderItem.java?view=auto&rev=486573
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderItem.java
(added)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderItem.java
Wed Dec 13 01:59:29 2006
@@ -0,0 +1,35 @@
+/*
+ * 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 test.complex.model;
+
+public class OrderItem {
+	private String item;
+	private int count;
+	
+	public int getCount() {
+		return count;
+	}
+	public void setCount(int count) {
+		this.count = count;
+	}
+	public String getItem() {
+		return item;
+	}
+	public void setItem(String item) {
+		this.item = item;
+	}
+}

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderItem.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: incubator/servicemix/trunk/deployables/serviceengines/servicemix-jsr181/src/test/java/test/complex/model/OrderItem.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message