cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r684398 - in /cxf/branches/2.0.x-fixes: ./ rt/core/src/main/java/org/apache/cxf/transport/ rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ systests/src/test/java/org/apache/cxf/systest/servlet/
Date Sun, 10 Aug 2008 02:37:53 GMT
Author: ningjiang
Date: Sat Aug  9 19:37:52 2008
New Revision: 684398

URL: http://svn.apache.org/viewvc?rev=684398&view=rev
Log:
Merged revisions 684397 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r684397 | ningjiang | 2008-08-10 10:14:42 +0800 (Sun, 10 Aug 2008) | 1 line
  
  CXF-1741 Fixed the NPE when publish the code first service in NoSpringServlet
........

Modified:
    cxf/branches/2.0.x-fixes/   (props changed)
    cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java
    cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java
    cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java
    cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java

Propchange: cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java?rev=684398&r1=684397&r2=684398&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java
Sat Aug  9 19:37:52 2008
@@ -59,19 +59,19 @@
     public void setBus(Bus b) {
         bus = b;
     }
-    
+
     @PostConstruct
     public void register() {
         if (null != bus) {
             bus.setExtension(this, DestinationFactoryManager.class);
         }
     }
-    
+
 
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.apache.cxf.bus.DestinationFactoryManager#registerDestinationFactory(java.lang.String,
      *      org.apache.cxf.transports.DestinationFactory)
      */
@@ -81,7 +81,7 @@
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.apache.cxf.bus.DestinationFactoryManager#deregisterDestinationFactory(java.lang.String)
      */
     public void deregisterDestinationFactory(String namespace) {
@@ -90,14 +90,14 @@
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see org.apache.cxf.bus.DestinationFactoryManager#DestinationFactory(java.lang.String)
      */
     /**
      * Returns the conduit initiator for the given namespace, constructing it
      * (and storing in the cache for future reference) if necessary, using its
      * list of factory classname to namespace mappings.
-     * 
+     *
      * @param namespace the namespace.
      */
     public DestinationFactory getDestinationFactory(String namespace) throws BusException
{
@@ -114,6 +114,10 @@
     }
 
     public DestinationFactory getDestinationFactoryForUri(String uri) {
+        //If the uri is related path or has no protocol prefix , we will set it to be http
+        if (uri.startsWith("/") || uri.indexOf(":") < 0) {
+            uri = "http://" + uri;
+        }
         //first attempt the ones already registered
         for (Map.Entry<String, DestinationFactory> df : destinationFactories.entrySet())
{
             for (String prefix : df.getValue().getUriPrefixes()) {
@@ -133,7 +137,7 @@
                 }
             }
         }
-        
+
         return null;
     }
 

Modified: cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java?rev=684398&r1=684397&r2=684398&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java
(original)
+++ cxf/branches/2.0.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletContextResourceResolver.java
Sat Aug  9 19:37:52 2008
@@ -37,11 +37,11 @@
 public class ServletContextResourceResolver implements ResourceResolver {
     ServletContext servletContext;
     Map<String, URL> urlMap = new ConcurrentHashMap<String, URL>();
-    
+
     public ServletContextResourceResolver(ServletContext sc) {
         servletContext = sc;
     }
-    
+
 
     public final InputStream getAsStream(final String string) {
         if (urlMap.containsKey(string)) {
@@ -55,19 +55,21 @@
     }
 
     public final <T> T resolve(final String entryName, final Class<T> clz) {
-        
+
         Object obj = null;
         try {
-            InitialContext ic = new InitialContext();
-            obj = ic.lookup(entryName);
+            if (entryName != null) {
+                InitialContext ic = new InitialContext();
+                obj = ic.lookup(entryName);
+            }
         } catch (NamingException e) {
             //do nothing
         }
-        
+
         if (obj != null && clz.isInstance(obj)) {
             return clz.cast(obj);
         }
-        
+
         if (clz.isAssignableFrom(URL.class)) {
             if (urlMap.containsKey(entryName)) {
                 return clz.cast(urlMap.get(entryName));
@@ -92,7 +94,7 @@
             }
         } else if (clz.isAssignableFrom(InputStream.class)) {
             return clz.cast(getAsStream(entryName));
-        }        
+        }
         return null;
     }
 }

Modified: cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java?rev=684398&r1=684397&r2=684398&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java
(original)
+++ cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletClientTest.java
Sat Aug  9 19:37:52 2008
@@ -26,6 +26,8 @@
 import com.meterware.httpunit.WebLink;
 import com.meterware.httpunit.WebResponse;
 
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.apache.cxf.systest.jaxws.Hello;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.SOAPService;
@@ -41,11 +43,11 @@
     public static void startServers() throws Exception {
         assertTrue("server did not launch correctly", launchServer(NoSpringServletServer.class));
     }
-    
+
     @Test
     public void testBasicConnection() throws Exception {
         SOAPService service = new SOAPService(new URL(serviceURL + "Greeter?wsdl"));
-        Greeter greeter = service.getPort(portName, Greeter.class);        
+        Greeter greeter = service.getPort(portName, Greeter.class);
         try {
             String reply = greeter.greetMe("test");
             assertNotNull("no response received from service", reply);
@@ -57,14 +59,25 @@
             throw (Exception)ex.getCause();
         }
     }
-    
+
+    @Test
+    public void testHelloService() throws Exception {
+        JaxWsProxyFactoryBean cpfb = new JaxWsProxyFactoryBean();
+        String address = serviceURL + "Hello";
+        cpfb.setServiceClass(Hello.class);
+        cpfb.setAddress(address);
+        Hello hello = (Hello) cpfb.create();
+        String reply = hello.sayHi(" Willem");
+        assertEquals("Get the wrongreply ", reply, "get Willem");
+    }
+
     @Test
     public void testGetServiceList() throws Exception {
         WebConversation client = new WebConversation();
         WebResponse res = client.getResponse(serviceURL);
         WebLink[] links = res.getLinks();
-        assertEquals("There should get two links for the service", 1, links.length);
-        assertEquals(serviceURL + "Greeter?wsdl", links[0].getURLString()); 
+        assertEquals("There should get two links for the service", 2, links.length);
+        assertEquals(serviceURL + "Greeter?wsdl", links[0].getURLString());
         assertEquals("text/html", res.getContentType());
     }
 }

Modified: cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java?rev=684398&r1=684397&r2=684398&view=diff
==============================================================================
--- cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java
(original)
+++ cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/servlet/NoSpringServletServer.java
Sat Aug  9 19:37:52 2008
@@ -22,10 +22,10 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.systest.jaxws.HelloImpl;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
 import org.apache.hello_world_soap_http.GreeterImpl;
-
 import org.mortbay.jetty.Server;
 import org.mortbay.jetty.handler.ContextHandlerCollection;
 import org.mortbay.jetty.servlet.Context;
@@ -42,22 +42,25 @@
             httpServer = new Server(9000);
             ContextHandlerCollection contexts = new ContextHandlerCollection();
             httpServer.setHandler(contexts);
-            
+
             Context root = new Context(contexts, "/", Context.SESSIONS);
-            
+
             CXFNonSpringServlet cxf = new CXFNonSpringServlet();
             ServletHolder servlet = new ServletHolder(cxf);
             servlet.setName("soap");
             servlet.setForcedPath("soap");
             root.addServlet(servlet, "/soap/*");
-            
+
             httpServer.start();
-            
+
             Bus bus = cxf.getBus();
             setBus(bus);
             BusFactory.setDefaultBus(bus);
             GreeterImpl impl = new GreeterImpl();
             Endpoint.publish("/Greeter", impl);
+            HelloImpl helloImpl = new HelloImpl();
+            Endpoint.publish("/Hello", helloImpl);
+
         } catch (Exception e) {
             throw new RuntimeException(e);
         } finally {
@@ -69,13 +72,13 @@
             }
         }
     }
-    
+
     public void tearDown() throws Exception {
         if (httpServer != null) {
             httpServer.stop();
-        }    
+        }
     }
-    
+
     public static void main(String[] args) {
         try {
             NoSpringServletServer s = new NoSpringServletServer();



Mime
View raw message