Author: ningjiang
Date: Sun Jul 22 20:15:52 2007
New Revision: 558591

URL: http://svn.apache.org/viewvc?view=rev&rev=558591
Log:
[CXF-821] Let CXFservletTransportFactory extense the 
AbstractHTTPTransportFactory 
Added Systest for looking up conduit initiator just by loading the bus with the 
servlet.xml
Added an unit test case for setting implementor bean's properties within the 
jaxws sub elements

Added:
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/servlet.xml
   (with props)
Modified:
    
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
    
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
    
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
    
incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java

Modified: 
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?view=diff&rev=558591&r1=558590&r2=558591
==============================================================================
--- 
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
 (original)
+++ 
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
 Sun Jul 22 20:15:52 2007
@@ -62,7 +62,7 @@
         ep = (EndpointImpl) bean;        
         if (!(ep.getImplementor() instanceof 
org.apache.hello_world_soap_http.GreeterImpl)) {
             fail("can't get the right implementor object");
-        }
+        }        
         assertEquals("http://localhost:8080/simpleWithAddress";, 
                      
ep.getServer().getEndpoint().getEndpointInfo().getAddress());
         
@@ -70,7 +70,12 @@
         assertNotNull(bean);
         
         ep = (EndpointImpl) bean;
-        assertNotNull(ep.getImplementor());
+        if (!(ep.getImplementor() instanceof 
org.apache.hello_world_soap_http.GreeterImpl)) {
+            fail("can't get the right implementor object");
+        }
+        org.apache.hello_world_soap_http.GreeterImpl impl =
+            (org.apache.hello_world_soap_http.GreeterImpl)ep.getImplementor();
+        assertEquals("The property is not injected rightly", impl.getPerfix(), 
"hello");
         assertNotNull(ep.getServer());
         
 

Modified: 
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml?view=diff&rev=558591&r1=558590&r2=558591
==============================================================================
--- 
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
 (original)
+++ 
incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/endpoints.xml
 Sun Jul 22 20:15:52 2007
@@ -46,7 +46,9 @@
   
   <jaxws:endpoint id="inlineImplementor" 
address="http://localhost:8080/simpleWithAddress";>
     <jaxws:implementor>
-      <bean class="org.apache.hello_world_soap_http.GreeterImpl"/>
+      <bean class="org.apache.hello_world_soap_http.GreeterImpl">
+         <property name="perfix" value="hello"/>
+      </bean>   
     </jaxws:implementor>
   </jaxws:endpoint>
   

Modified: 
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java?view=diff&rev=558591&r1=558590&r2=558591
==============================================================================
--- 
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
 (original)
+++ 
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletTransportFactory.java
 Sun Jul 22 20:15:52 2007
@@ -31,11 +31,11 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.transport.AbstractTransportFactory;
 import org.apache.cxf.transport.Destination;
 import org.apache.cxf.transport.DestinationFactory;
+import org.apache.cxf.transport.http.AbstractHTTPTransportFactory;
 
-public class ServletTransportFactory extends AbstractTransportFactory
+public class ServletTransportFactory extends AbstractHTTPTransportFactory
     implements DestinationFactory {
 
     private Bus bus;
@@ -103,4 +103,6 @@
     public Set<String> getDestinationsPaths() {
         return Collections.unmodifiableSet(destinations.keySet());        
     }
+
+    
 }

Modified: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java?view=diff&rev=558591&r1=558590&r2=558591
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
 (original)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/SpringBusFactoryTest.java
 Sun Jul 22 20:15:52 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.systest.bus;
 
+
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactoryManager;
@@ -33,6 +34,7 @@
 import org.apache.cxf.wsdl.WSDLManager;
 import org.junit.Assert;
 import org.junit.Test;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 public class SpringBusFactoryTest extends Assert {
     
@@ -40,55 +42,65 @@
     public void testKnownExtensions() throws BusException {
         Bus bus = new SpringBusFactory().createBus();
         assertNotNull(bus);
-        BindingFactoryManager bfm = 
bus.getExtension(BindingFactoryManager.class);  
-        assertNotNull("No binding factory manager", bfm);
+        
+        checkBindingExtensions(bus);
+        
         DestinationFactoryManager dfm = 
bus.getExtension(DestinationFactoryManager.class);
         assertNotNull("No destination factory manager", dfm);
         ConduitInitiatorManager cim = 
bus.getExtension(ConduitInitiatorManager.class);
         assertNotNull("No conduit initiator manager", cim);
         
-        assertNotNull("No wsdl manager", bus.getExtension(WSDLManager.class));
-        assertNotNull("No phase manager", 
bus.getExtension(PhaseManager.class));
-        assertNotNull("No workqueue manager", 
bus.getExtension(WorkQueueManager.class));
-        assertNotNull("No lifecycle manager", 
bus.getExtension(BusLifeCycleManager.class));
-        assertNotNull("No service registry", 
bus.getExtension(ServerRegistry.class));
+        checkTransportFactories(bus);
+        checkOtherCoreExtensions(bus);
+        //you should include instumentation extenstion to get the 
instrumentation manager 
         assertNotNull("No instrumentation manager", 
bus.getExtension(InstrumentationManager.class));
-        
+    }
+    
+    @Test
+    public void testLoadBusWithServletApplicationContext() throws BusException 
{
+        ClassPathXmlApplicationContext ctx = 
+            new ClassPathXmlApplicationContext(new String[] 
{"/org/apache/cxf/systest/bus/servlet.xml"});
+        Bus bus = new SpringBusFactory(ctx).createBus();
+        checkBindingExtensions(bus);
+        checkHTTPTransportFactories(bus);
+        checkOtherCoreExtensions(bus);
+    }
+    
+    private void checkBindingExtensions(Bus bus) throws BusException {
+        BindingFactoryManager bfm = 
bus.getExtension(BindingFactoryManager.class);  
+        assertNotNull("No binding factory manager", bfm);
+        assertNotNull("binding factory not available", 
+                      
bfm.getBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/";));
         try {
             bfm.getBindingFactory("http://cxf.apache.org/unknown";);
         } catch (BusException ex) {
             // expected
         }
-        assertNotNull("binding factory not available", 
-                      
bfm.getBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/";));
+    }
+    
+    private void checkOtherCoreExtensions(Bus bus) throws BusException {
+        assertNotNull("No wsdl manager", bus.getExtension(WSDLManager.class));
+        assertNotNull("No phase manager", 
bus.getExtension(PhaseManager.class));
+        assertNotNull("No workqueue manager", 
bus.getExtension(WorkQueueManager.class));
+        assertNotNull("No lifecycle manager", 
bus.getExtension(BusLifeCycleManager.class));
+        assertNotNull("No service registry", 
bus.getExtension(ServerRegistry.class));
         
+    }
+    
+    private void checkHTTPTransportFactories(Bus bus) throws BusException {
+        ConduitInitiatorManager cim = 
bus.getExtension(ConduitInitiatorManager.class);
+        assertNotNull("No conduit initiator manager", cim);
         
-        try {
-            cim.getConduitInitiator("http://cxf.apache.org/unknown";);
-        } catch (BusException ex) {
-            // expected
-        }
-        // not sure that we need this - Dan Diephouse
-//        assertNotNull("conduit initiator not available", 
-//                      
cim.getConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/";));
         assertNotNull("conduit initiator not available", 
                       
cim.getConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/http";));
         assertNotNull("conduit initiator not available", 
                       
cim.getConduitInitiator("http://schemas.xmlsoap.org/wsdl/http/";));
         assertNotNull("conduit initiator not available", 
                       
cim.getConduitInitiator("http://cxf.apache.org/transports/http/configuration";));
-        assertNotNull("conduit initiator not available", 
-                      
cim.getConduitInitiator("http://cxf.apache.org/bindings/xformat";));
-        assertNotNull("conduit initiator not available", 
-                      
cim.getConduitInitiator("http://cxf.apache.org/transports/jms";));
-        assertNotNull("conduit initiator not available", 
-                      
cim.getConduitInitiator("http://cxf.apache.org/transports/jms/configuration";));
         
-        try {
-            dfm.getDestinationFactory("http://cxf.apache.org/unknown";);
-        } catch (BusException ex) {
-            // expected
-        }
+        DestinationFactoryManager dfm = 
bus.getExtension(DestinationFactoryManager.class);
+        assertNotNull("No destination factory manager", dfm);
+        
         assertNotNull("destination factory not available", 
                       
dfm.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/";));
         assertNotNull("destination factory not available", 
@@ -97,6 +109,40 @@
                       
dfm.getDestinationFactory("http://schemas.xmlsoap.org/wsdl/http/";));
         assertNotNull("destination factory not available", 
                       
dfm.getDestinationFactory("http://cxf.apache.org/transports/http/configuration";));
+    }
+    
+    private void checkTransportFactories(Bus bus) throws BusException {
+        DestinationFactoryManager dfm = 
bus.getExtension(DestinationFactoryManager.class);
+        assertNotNull("No destination factory manager", dfm);
+        ConduitInitiatorManager cim = 
bus.getExtension(ConduitInitiatorManager.class);
+        assertNotNull("No conduit initiator manager", cim);
+        
+        try {
+            cim.getConduitInitiator("http://cxf.apache.org/unknown";);
+        } catch (BusException ex) {
+            // expected
+        }
+      
+        try {
+            dfm.getDestinationFactory("http://cxf.apache.org/unknown";);
+        } catch (BusException ex) {
+            // expected
+        }       
+        
+        // not sure that we need this - Dan Diephouse
+        //assertNotNull("conduit initiator not available", 
+        //cim.getConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/";));
+         
+        
+        assertNotNull("conduit initiator not available", 
+                      
cim.getConduitInitiator("http://cxf.apache.org/bindings/xformat";));
+        assertNotNull("conduit initiator not available", 
+                      
cim.getConduitInitiator("http://cxf.apache.org/transports/jms";));
+        assertNotNull("conduit initiator not available", 
+                      
cim.getConduitInitiator("http://cxf.apache.org/transports/jms/configuration";));
+        
+        
+
         assertNotNull("destination factory not available", 
                       
dfm.getDestinationFactory("http://cxf.apache.org/bindings/xformat";));
         assertNotNull("destination factory not available", 
@@ -104,6 +150,6 @@
         assertNotNull("destination factory not available", 
                       
dfm.getDestinationFactory("http://cxf.apache.org/transports/jms/configuration";));
         
-        
     }
+    
 }

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/servlet.xml
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/servlet.xml?view=auto&rev=558591
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/servlet.xml
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/servlet.xml
 Sun Jul 22 20:15:52 2007
@@ -0,0 +1,31 @@
+<?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:jaxws="http://cxf.apache.org/jaxws";
+      xsi:schemaLocation="
+http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd";>
+
+  <import resource="classpath*:META-INF/cxf/cxf.xml"/>
+  <import resource="classpath*:META-INF/cxf/cxf-extension-soap.xml"/>  
+  <import resource="classpath*:META-INF/cxf/cxf-servlet.xml"/>
+  
+</beans>
\ No newline at end of file

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

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/bus/servlet.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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

Modified: 
incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java?view=diff&rev=558591&r1=558590&r2=558591
==============================================================================
--- 
incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
 (original)
+++ 
incubator/cxf/trunk/testutils/src/main/java/org/apache/hello_world_soap_http/GreeterImpl.java
 Sun Jul 22 20:15:52 2007
@@ -54,13 +54,22 @@
 
     @Resource
     private WebServiceContext context;
+    
+    private String perfix = "";
 
     private int invocationCount;
 
     public WebServiceContext getContext() {
         return context;
     }
-
+    
+    public void setPerfix(String per) {
+        perfix = per;
+    }    
+    
+    public String getPerfix() {
+        return perfix;
+    }
     public String greetMe(String me) {
         if ("secure".equals(me)) {
             MessageContext ctx = getContext().getMessageContext();
@@ -71,7 +80,7 @@
         }
         
         
-        LOG.info("Invoking greetMe " + me);
+        LOG.info("Invoking greetMe " + perfix + me);
         invocationCount++;
         return "Hello " + me;
     }


Reply via email to