cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r530804 [2/2] - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/message/ api/src/main/java/org/apache/cxf/service/model/ api/src/main/java/org/apache/cxf/transport/ api/src/main/java/org/apache/cxf/ws/addressing/ api/src/main/java...
Date Fri, 20 Apr 2007 13:40:15 GMT
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java?view=auto&rev=530804
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java
Fri Apr 20 06:40:11 2007
@@ -0,0 +1,145 @@
+/**
+ * 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.systest.factory_pattern;
+
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.factory_pattern.IsEvenResponse;
+import org.apache.cxf.factory_pattern.Number;
+import org.apache.cxf.factory_pattern.NumberFactory;
+import org.apache.cxf.factory_pattern.NumberFactoryService;
+import org.apache.cxf.factory_pattern.NumberService;
+import org.apache.cxf.jaxws.ServiceImpl;
+import org.apache.cxf.jaxws.support.ServiceDelegateAccessor;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+public class ManualHttpMulitplexClientServerTest extends AbstractBusClientServerTestBase
{
+    
+    public static class Server extends AbstractBusTestServerBase {        
+
+        protected void run() {
+            Object implementor = new ManualNumberFactoryImpl();
+            Endpoint.publish(NumberFactoryImpl.FACTORY_ADDRESS, implementor);           

+        }
+
+        public static void main(String[] args) {
+            try {
+                Server s = new Server();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                System.out.println("done!");
+            }
+        }
+    }
+
+    @BeforeClass
+    public static void startServers() throws Exception {        
+        assertTrue("server did not launch correctly",
+                   launchServer(Server.class));
+    }
+
+    
+    @Test
+    public void testWithManualMultiplexEprCreation() throws Exception {
+    
+        NumberFactoryService service = new NumberFactoryService();
+        NumberFactory nfact = service.getNumberFactoryPort();
+        
+        EndpointReferenceType epr = nfact.create("2");        
+        assertNotNull("reference", epr);
+        
+        // use the epr info only
+        // no wsdl so default generated soap/http binding will be used
+        // address url must come from the calling context
+        //
+        QName serviceName = EndpointReferenceUtils.getServiceName(epr);
+        Service numService = Service.create(serviceName);
+        
+        String portString = EndpointReferenceUtils.getPortName(epr);
+        QName portName = new QName(serviceName.getNamespaceURI(), portString);          
     
+        Number num =  (Number)numService.getPort(portName, Number.class);
+
+        setupContextWithEprAddress(epr, num);
+        
+        IsEvenResponse numResp = num.isEven();
+        assertTrue("2 is even", Boolean.TRUE.equals(numResp.isEven()));
+
+        // try again with the address from another epr
+        epr = nfact.create("3");
+        setupContextWithEprAddress(epr, num);
+        numResp = num.isEven();
+        assertTrue("3 is not even", Boolean.FALSE.equals(numResp.isEven()));
+        
+        // try again with the address from another epr
+        epr = nfact.create("6");
+        setupContextWithEprAddress(epr, num);
+        numResp = num.isEven();
+        assertTrue("6 is even", Boolean.TRUE.equals(numResp.isEven()));
+    }
+    
+    @Test
+    public void testWithGetPortExtensionHttp() throws Exception {
+        
+        NumberFactoryService service = new NumberFactoryService();
+        NumberFactory factory = service.getNumberFactoryPort();
+        EndpointReferenceType numberTwoRef = factory.create("20");
+        assertNotNull("reference", numberTwoRef);
+        
+        // use getPort with epr api on service
+        NumberService numService = new NumberService();
+        ServiceImpl serviceImpl = ServiceDelegateAccessor.get(numService);
+        
+        Number num =  (Number)serviceImpl.getPort(numberTwoRef, Number.class);
+        assertTrue("20 is even", num.isEven().isEven());
+        
+        EndpointReferenceType numberTwentyThreeRef = factory.create("23");
+        num =  (Number)serviceImpl.getPort(numberTwentyThreeRef, Number.class);
+        assertTrue("23 is not even", !num.isEven().isEven());
+    }
+    
+    private void setupContextWithEprAddress(EndpointReferenceType epr, Number num) {
+        
+        String address = EndpointReferenceUtils.getAddress(epr);
+        
+        InvocationHandler handler  = Proxy.getInvocationHandler(num);
+        BindingProvider  bp = null;        
+        if (handler instanceof BindingProvider) {
+            bp = (BindingProvider)handler;    
+            bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, address);
+        }
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualHttpMulitplexClientServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java?view=auto&rev=530804
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java
Fri Apr 20 06:40:11 2007
@@ -0,0 +1,56 @@
+/**
+ * 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.systest.factory_pattern;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+
+@WebService(serviceName = "NumberFactoryService", 
+            portName = "NumberFactoryPort", 
+            endpointInterface = "org.apache.cxf.factory_pattern.NumberFactory", 
+            targetNamespace = "http://cxf.apache.org/factory_pattern")
+public class ManualNumberFactoryImpl extends NumberFactoryImpl {
+
+    public EndpointReferenceType create(String id) {
+        manageNumberServantInitialisation();
+        
+        // manually force id into address context as context appendage
+        EndpointReferenceType epr = EndpointReferenceUtils.duplicate(templateEpr);
+        EndpointReferenceUtils.setAddress(epr, EndpointReferenceUtils.getAddress(epr) + id);
+        return epr;
+    }
+
+    protected void initDefaultServant() {
+        servant = new ManualNumberImpl();
+
+        String wsdlLocation = "testutils/factory_pattern.wsdl";
+        String bindingId = null;
+        EndpointImpl ep = 
+            new EndpointImpl(BusFactory.getDefaultBus(), servant, bindingId, wsdlLocation);
+        ep.setEndpointName(new QName(NUMBER_SERVICE_QNAME.getNamespaceURI(), "NumberPort"));
+        ep.publish();
+        templateEpr = ep.getServer().getDestination().getAddress();
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberImpl.java?view=auto&rev=530804
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberImpl.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberImpl.java
Fri Apr 20 06:40:11 2007
@@ -0,0 +1,52 @@
+/**
+ * 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.systest.factory_pattern;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+@WebService(serviceName = "NumberService",
+            endpointInterface = "org.apache.cxf.factory_pattern.Number", 
+            targetNamespace = "http://cxf.apache.org/factory_pattern")
+            
+public class ManualNumberImpl extends NumberImpl {
+
+    @Resource
+    protected WebServiceContext aContext;
+    
+    protected WebServiceContext getWebSercviceContext() {
+        return aContext;
+    }
+    
+    /**
+     * pull id from manual context appendage
+     */
+    protected String idFromMessageContext(MessageContext mc) {
+
+        String id = null;
+        String path = (String)mc.get(MessageContext.PATH_INFO);
+        if (null != path) {
+            id = path.substring(path.lastIndexOf('/') + 1);
+        }
+        return id;
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/ManualNumberImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java?view=auto&rev=530804
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java
Fri Apr 20 06:40:11 2007
@@ -0,0 +1,131 @@
+/**
+ * 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.systest.factory_pattern;
+
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.cxf.factory_pattern.Number;
+import org.apache.cxf.factory_pattern.NumberFactory;
+import org.apache.cxf.factory_pattern.NumberFactoryService;
+import org.apache.cxf.factory_pattern.NumberService;
+import org.apache.cxf.jaxws.ServiceImpl;
+import org.apache.cxf.jaxws.support.ServiceDelegateAccessor;
+import org.apache.cxf.systest.jms.EmbeddedJMSBrokerLauncher;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+public class MultiplexClientServerTest extends AbstractBusClientServerTestBase {
+    
+    public static class Server extends AbstractBusTestServerBase {        
+
+        protected void run() {
+            Object implementor = new NumberFactoryImpl();
+            Endpoint.publish(NumberFactoryImpl.FACTORY_ADDRESS, implementor);
+        }
+
+        public static void main(String[] args) {
+            try {
+                Server s = new Server();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                System.out.println("done!");
+            }
+        }
+    }
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        // requires ws-a support to propagate reference parameters
+        createStaticBus("org/apache/cxf/systest/ws/addressing/cxf.xml");
+        Map<String, String> props = new HashMap<String, String>();    
+        if (System.getProperty("activemq.store.dir") != null) {
+            props.put("activemq.store.dir", System.getProperty("activemq.store.dir"));
+        }
+        props.put("java.util.logging.config.file", 
+                  System.getProperty("java.util.logging.config.file"));
+        assertTrue("server did not launch correctly", 
+                   launchServer(EmbeddedJMSBrokerLauncher.class, props, null));
+        
+        props.put("cxf.config.file", defaultConfigFileName);
+        assertTrue("server did not launch correctly",
+                   launchServer(Server.class, props, null));
+    }
+
+    
+    @Test
+    public void testWithGetPortExtensionHttp() throws Exception {
+        
+        NumberFactoryService service = new NumberFactoryService();
+        NumberFactory factory = service.getNumberFactoryPort();
+        
+        NumberService numService = new NumberService();
+        ServiceImpl serviceImpl = ServiceDelegateAccessor.get(numService);
+        
+        EndpointReferenceType numberTwoRef = factory.create("20");
+        assertNotNull("reference", numberTwoRef);
+           
+        Number num =  (Number)serviceImpl.getPort(numberTwoRef, Number.class);
+        assertTrue("20 is even", num.isEven().isEven());
+        
+        EndpointReferenceType numberTwentyThreeRef = factory.create("23");
+        num =  (Number)serviceImpl.getPort(numberTwentyThreeRef, Number.class);
+        assertTrue("23 is not even", !num.isEven().isEven());
+    }
+    
+    @Test
+    public void testWithGetPortExtensionOverJMS() throws Exception {
+        
+        NumberFactoryService service = new NumberFactoryService();
+        NumberFactory factory = service.getNumberFactoryPort();
+        
+        NumberService numService = new NumberService();
+
+        // use values >= 30 to create JMS eprs - see NumberFactoryImpl.create
+        
+        // verify it is JMS, 999 for JMS will throw a fault
+        EndpointReferenceType ref = factory.create("999");
+        assertNotNull("reference", ref);
+        ServiceImpl serviceImpl = ServiceDelegateAccessor.get(numService);    
+        Number num =  (Number)serviceImpl.getPort(ref, Number.class); 
+        try {
+            num.isEven().isEven();
+            fail("there should be a fault on val 999");
+        } catch (Exception expected) {
+            assertTrue("match on exception message", expected.getMessage().indexOf("999")
!= -1);
+        }
+        
+        ref = factory.create("37");
+        assertNotNull("reference", ref);
+        num =  (Number)serviceImpl.getPort(ref, Number.class);
+        assertTrue("37 is not even", !num.isEven().isEven());
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexClientServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java?view=auto&rev=530804
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
Fri Apr 20 06:40:11 2007
@@ -0,0 +1,115 @@
+/**
+ * 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.systest.factory_pattern;
+
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.ws.BindingProvider;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+
+import org.apache.cxf.factory_pattern.IsEvenResponse;
+import org.apache.cxf.factory_pattern.Number;
+import org.apache.cxf.factory_pattern.NumberFactory;
+import org.apache.cxf.factory_pattern.NumberFactoryService;
+import org.apache.cxf.factory_pattern.NumberService;
+import org.apache.cxf.jaxws.ServiceImpl;
+import org.apache.cxf.jaxws.support.ServiceDelegateAccessor;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/*
+ * exercise with multiplexWithAddress config rather than ws-a headers
+ */
+public class MultiplexHttpAddressClientServerTest extends AbstractBusClientServerTestBase
{
+    
+    public static class Server extends AbstractBusTestServerBase {        
+
+        protected void run() {
+            Object implementor = new HttpNumberFactoryImpl();
+            Endpoint.publish(NumberFactoryImpl.FACTORY_ADDRESS, implementor);
+        }
+
+        public static void main(String[] args) {
+            try {
+                Server s = new Server();
+                s.start();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                System.exit(-1);
+            } finally {
+                System.out.println("done!");
+            }
+        }
+    }
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        // no need for ws-a, just enable multiplexWithAddress on server
+        Map<String, String> props = new HashMap<String, String>();    
+        props.put("cxf.config.file", "org/apache/cxf/systest/factory_pattern/cxf.xml");
+        assertTrue("server did not launch correctly",
+                   launchServer(Server.class, props, null));
+    }
+
+    
+    @Test
+    public void testWithGetPortExtensionHttp() throws Exception {
+        
+        NumberFactoryService service = new NumberFactoryService();
+        NumberFactory factory = service.getNumberFactoryPort();
+        
+        NumberService numService = new NumberService();
+        ServiceImpl serviceImpl = ServiceDelegateAccessor.get(numService);
+        
+        EndpointReferenceType numberTwoRef = factory.create("20");
+        assertNotNull("reference", numberTwoRef);
+           
+        Number num =  (Number)serviceImpl.getPort(numberTwoRef, Number.class);
+        assertTrue("20 is even", num.isEven().isEven());
+        
+        EndpointReferenceType numberTwentyThreeRef = factory.create("23");
+        num =  (Number)serviceImpl.getPort(numberTwentyThreeRef, Number.class);
+        assertTrue("23 is not even", !num.isEven().isEven());
+    }
+    
+    @Test
+    public void testWithManualMultiplexEprCreation() throws Exception {
+    
+        Service numService = Service.create(NumberFactoryImpl.NUMBER_SERVICE_QNAME);
+        Number num =  (Number)numService.getPort(Number.class);
+        
+        InvocationHandler handler  = Proxy.getInvocationHandler(num);
+        BindingProvider bp = (BindingProvider)handler;    
+        bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, 
+                                   NumberFactoryImpl.NUMBER_SERVANT_ADDRESS_ROOT + "103");
+            
+        IsEvenResponse numResp = num.isEven();
+        assertTrue("103 is not even", Boolean.FALSE.equals(numResp.isEven()));
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/MultiplexHttpAddressClientServerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java?view=auto&rev=530804
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java
Fri Apr 20 06:40:11 2007
@@ -0,0 +1,97 @@
+/**
+ * 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.systest.factory_pattern;
+
+import javax.jws.WebService;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.factory_pattern.NumberFactory;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+
+@WebService(serviceName = "NumberFactoryService", 
+            portName = "NumberFactoryPort", 
+            endpointInterface = "org.apache.cxf.factory_pattern.NumberFactory", 
+            targetNamespace = "http://cxf.apache.org/factory_pattern")
+public class NumberFactoryImpl implements NumberFactory {
+
+    public static final String FACTORY_ADDRESS = 
+        "http://localhost:9006/NumberFactoryService/NumberFactoryPort";
+    public static final String NUMBER_SERVANT_ADDRESS_ROOT = 
+        "http://localhost:9006/NumberService/NumberPort/";
+    public static final String FACTORY_NS = "http://cxf.apache.org/factory_pattern";
+    public static final String NUMBER_SERVICE_NAME = "NumberService";
+    public static final String NUMBER_PORT_NAME = "NumberPort";
+
+    public static final QName NUMBER_SERVICE_QNAME = new QName(FACTORY_NS, NUMBER_SERVICE_NAME);
+    public static final QName NUMBER_PORT_TYPE_QNAME = new QName(FACTORY_NS, NUMBER_PORT_NAME);
+
+    protected EndpointReferenceType templateEpr;
+    protected NumberImpl servant;
+
+    public NumberFactoryImpl() {
+    }
+
+    public EndpointReferenceType create(String id) {
+
+        manageNumberServantInitialisation();
+        int val = Integer.valueOf(id);
+
+        // allow clients to drive test scenarios with val
+        String portName = "NumberPort";
+        if (val >= 30) {
+            // use jms transport
+            portName = "NumberPortJMS";
+        }
+        return  EndpointReferenceUtils.getEndpointReferenceWithId(NUMBER_SERVICE_QNAME, portName,
id,
+                                                                BusFactory.getDefaultBus());
+    }
+
+    protected synchronized EndpointReferenceType manageNumberServantInitialisation() {
+        if (null == templateEpr) {
+            initDefaultServant();
+        }
+        return templateEpr;
+    }
+    
+    protected void initDefaultServant() {
+
+        servant = new NumberImpl();
+        String wsdlLocation = "testutils/factory_pattern.wsdl";
+        String bindingId = null;
+
+        EndpointImpl ep = new EndpointImpl(BusFactory.getDefaultBus(), 
+                                           servant, bindingId, wsdlLocation);
+        ep.setEndpointName(new QName(NUMBER_SERVICE_QNAME.getNamespaceURI(), "NumberPort"));
+        ep.publish();
+        templateEpr = ep.getServer().getDestination().getAddress();
+
+        // jms port
+        ep = new EndpointImpl(BusFactory.getDefaultBus(), servant, bindingId, wsdlLocation);
+        ep.setEndpointName(new QName(NUMBER_SERVICE_QNAME.getNamespaceURI(), "NumberPortJMS"));
+        ep.publish();
+        ep.getServer().getEndpoint().getInInterceptors().add(new LoggingInInterceptor());
+        ep.getServer().getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberFactoryImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberImpl.java?view=auto&rev=530804
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberImpl.java
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberImpl.java
Fri Apr 20 06:40:11 2007
@@ -0,0 +1,95 @@
+/**
+ * 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.systest.factory_pattern;
+
+import javax.annotation.Resource;
+import javax.jws.WebService;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.handler.MessageContext;
+
+import org.apache.cxf.factory_pattern.IsEvenResponse;
+import org.apache.cxf.factory_pattern.ObjectFactory;
+import org.apache.cxf.transport.jms.JMSConstants;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+
+@WebService(serviceName = "NumberService",
+            endpointInterface = "org.apache.cxf.factory_pattern.Number", 
+            targetNamespace = "http://cxf.apache.org/factory_pattern")
+            
+public class NumberImpl implements org.apache.cxf.factory_pattern.Number {
+
+    @Resource
+    protected WebServiceContext wsContext;
+    
+    public IsEvenResponse isEven() {
+
+        String id = idFromWebServiceContext(getWebSercviceContext());
+        
+        int num = stateFromId(id);
+        boolean ret = evalIsEeven(num);
+        return genResponse(ret);
+    }
+
+    protected WebServiceContext getWebSercviceContext() {
+        return wsContext;
+    }
+    
+    protected String idFromWebServiceContext(WebServiceContext wsC) {
+        MessageContext mc = wsC.getMessageContext();
+        return idFromMessageContext(mc);
+    }
+
+    protected String idFromMessageContext(MessageContext mc) {        
+        String id = EndpointReferenceUtils.getEndpointReferenceId(mc);
+        
+        boolean jmsInvoke = null != mc.get(JMSConstants.JMS_REQUEST_MESSAGE);
+        if ("999".equals(id) && jmsInvoke) {
+            // verification that this is indeed JMS
+            throw new RuntimeException("This is indeed JMS, id=" + id);
+        }
+        
+        return id;
+    }
+
+    private IsEvenResponse genResponse(boolean v) {
+        IsEvenResponse resp = new ObjectFactory().createIsEvenResponse();
+        resp.setEven(v);
+        return resp;
+    }
+
+    private boolean evalIsEeven(int num) {
+        boolean isEven = true;
+        if (num != 0 && num % 2 != 0) {
+            isEven = false;
+        }
+        return isEven;
+    }
+
+    private int stateFromId(String id) {
+        int num = 0;
+        if (id != null) {
+            Integer val = Integer.valueOf(id);
+            num = val.intValue();
+        } else {
+            throw new RuntimeException("State is an empty string, cannot determine val");
+        }
+        return num;
+    }
+}

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/NumberImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/cxf.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/cxf.xml?view=auto&rev=530804
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/cxf.xml
(added)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/cxf.xml
Fri Apr 20 06:40:11 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:http="http://cxf.apache.org/transports/http/configuration"
+       xsi:schemaLocation="
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schema/transports/http.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+    <bean name="{http://cxf.apache.org/factory_pattern}NumberPort.http-destination" abstract="true">
+      <property name="multiplexWithAddress" value="true"/>
+    </bean>
+</beans>

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/cxf.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/factory_pattern/cxf.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/testutils/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/pom.xml?view=diff&rev=530804&r1=530803&r2=530804
==============================================================================
--- incubator/cxf/trunk/testutils/pom.xml (original)
+++ incubator/cxf/trunk/testutils/pom.xml Fri Apr 20 06:40:11 2007
@@ -362,10 +362,13 @@
                                 <wsdlOption>
                                     <wsdl>${basedir}/src/main/resources/wsdl/header_rpc_lit.wsdl</wsdl>
                                 </wsdlOption>
-				<wsdlOption>
-		                    <wsdl>${basedir}/src/main/resources/wsdl/any.wsdl</wsdl>
-                		</wsdlOption>
-		            </wsdlOptions>
+                                <wsdlOption>
+    	                            <wsdl>${basedir}/src/main/resources/wsdl/any.wsdl</wsdl>
+                                </wsdlOption>
+                                <wsdlOption>
+                                    <wsdl>${basedir}/src/main/resources/wsdl/factory_pattern.wsdl</wsdl>
+                                </wsdlOption>
+    	                    </wsdlOptions>
                         </configuration>
                         <goals>
                             <goal>wsdl2java</goal>

Added: incubator/cxf/trunk/testutils/src/main/resources/wsdl/factory_pattern.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/factory_pattern.wsdl?view=auto&rev=530804
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/resources/wsdl/factory_pattern.wsdl (added)
+++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/factory_pattern.wsdl Fri Apr 20
06:40:11 2007
@@ -0,0 +1,139 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<wsdl:definitions name="NumberFactoryService"
+	targetNamespace="http://cxf.apache.org/factory_pattern"
+	xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
+	xmlns:wsa="http://www.w3.org/2005/08/addressing"
+    xmlns:jms="http://cxf.apache.org/transports/jms"
+	xmlns:ns1="http://factory_pattern.cxf.apache.org/"
+	xmlns:tns="http://cxf.apache.org/factory_pattern"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:soap="http://schemas.xmlsoap.org/soap/"
+	xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+	<wsdl:types>
+		<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+			attributeFormDefault="unqualified" elementFormDefault="qualified"
+			targetNamespace="http://factory_pattern.cxf.apache.org/">
+			<xsd:import namespace="http://www.w3.org/2005/08/addressing" schemaLocation="/schemas/wsdl/ws-addr.xsd"/>

+			<xsd:element name="create">
+				<xsd:complexType>
+					<xsd:sequence>
+						<xsd:element name="id" nillable="false"
+							type="xsd:string" />
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+			<xsd:element name="createResponse">
+				<xsd:complexType>
+					<xsd:sequence>
+						<xsd:element name="return" nillable="false"
+							type="wsa:EndpointReferenceType" />
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+			<xsd:element name="isEvenResponse">
+				<xsd:complexType>
+					<xsd:sequence>
+						<xsd:element name="even" type="xsd:boolean" />
+					</xsd:sequence>
+				</xsd:complexType>
+			</xsd:element>
+		</xsd:schema>
+	</wsdl:types>
+
+	<wsdl:message name="create">
+		<wsdl:part name="create" element="ns1:create" />
+	</wsdl:message>
+	<wsdl:message name="createResponse">
+		<wsdl:part name="createResponse" element="ns1:createResponse" />
+	</wsdl:message>
+	<wsdl:message name="isEven" />
+	<wsdl:message name="isEvenResponse">
+		<wsdl:part name="isEvenResponse" element="ns1:isEvenResponse" />
+	</wsdl:message>
+
+	<wsdl:portType name="NumberFactory">
+		<wsdl:operation name="create">
+			<wsdl:input message="tns:create" />
+			<wsdl:output message="tns:createResponse" />
+		</wsdl:operation>
+	</wsdl:portType>
+	<wsdl:portType name="Number">
+		<wsdl:operation name="isEven">
+			<wsdl:input message="tns:isEven" />
+			<wsdl:output message="tns:isEvenResponse" />
+		</wsdl:operation>
+	</wsdl:portType>
+
+	<wsdl:binding name="NumberFactoryServiceSoapBinding"
+		type="tns:NumberFactory">
+		<wsdlsoap:binding style="document"
+			transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="create">
+			<wsdlsoap:operation soapAction="" style="document" />
+			<wsdl:input>
+				<wsdlsoap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<wsdlsoap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:binding name="NumberServiceSoapHttpBinding" type="tns:Number">
+		<wsdlsoap:binding style="document"
+			transport="http://schemas.xmlsoap.org/soap/http" />
+		<wsdl:operation name="isEven">
+			<wsdlsoap:operation soapAction="" style="document" />
+			<wsdl:input>
+				<wsdlsoap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<wsdlsoap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:binding name="NumberServiceSoapJmsBinding" type="tns:Number">
+		<wsdlsoap:binding style="document"
+			transport="http://cxf.apache.org/transports/jms" />
+		<wsdl:operation name="isEven">
+			<wsdlsoap:operation soapAction="" style="document" />
+			<wsdl:input>
+				<wsdlsoap:body use="literal" />
+			</wsdl:input>
+			<wsdl:output>
+				<wsdlsoap:body use="literal" />
+			</wsdl:output>
+		</wsdl:operation>
+	</wsdl:binding>
+	<wsdl:service name="NumberFactoryService">
+		<wsdl:port name="NumberFactoryPort"
+			binding="tns:NumberFactoryServiceSoapBinding">
+			<wsdlsoap:address
+				location="http://localhost:9006/NumberFactoryService/NumberFactoryPort" />
+			<wswa:UsingAddressing
+				xmlns:wswa="http://www.w3.org/2005/08/addressing/wsdl" />
+		</wsdl:port>
+	</wsdl:service>
+	<wsdl:service name="NumberService">
+		<wsdl:port name="NumberPort"
+			binding="tns:NumberServiceSoapHttpBinding">
+			<wsdlsoap:address
+				location="http://localhost:9006/NumberService/NumberPort/" />
+			<wswa:UsingAddressing
+				xmlns:wswa="http://www.w3.org/2005/08/addressing/wsdl" />
+		</wsdl:port>
+		<wsdl:port name="NumberPortJMS"
+			binding="tns:NumberServiceSoapJmsBinding">
+			<jms:address destinationStyle="queue"
+				jndiConnectionFactoryName="ConnectionFactory"
+				jndiDestinationName="dynamicQueues/test.cxf.factory_pattern.queue">
+				<jms:JMSNamingProperty
+					name="java.naming.factory.initial"
+					value="org.apache.activemq.jndi.ActiveMQInitialContextFactory" />
+				<jms:JMSNamingProperty name="java.naming.provider.url"
+					value="tcp://localhost:61500" />
+			</jms:address>
+			<wswa:UsingAddressing
+				xmlns:wswa="http://www.w3.org/2005/08/addressing/wsdl" />
+		</wsdl:port>
+	</wsdl:service>
+</wsdl:definitions>

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/factory_pattern.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/testutils/src/main/resources/wsdl/factory_pattern.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message