cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r572850 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/bus/extension/ rt/core/src/main/java/org/apache/cxf/transport/ rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/ rt/databinding/aegis/src/test/java/or...
Date Wed, 05 Sep 2007 01:25:05 GMT
Author: dkulp
Date: Tue Sep  4 18:25:02 2007
New Revision: 572850

URL: http://svn.apache.org/viewvc?rev=572850&view=rev
Log:
fix a bunch of issues using Dispatch clients with an ExtensionManagerBus instead of a spring
bus
enable a bunch of ignored Rest tests

Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/DeferredMap.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManager.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/DualOutServiceTest.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
    incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
    incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/DeferredMap.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/DeferredMap.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/DeferredMap.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/DeferredMap.java
Tue Sep  4 18:25:02 2007
@@ -31,6 +31,11 @@
         
         this.type = type;
     }
+    
+    public void undefer() {
+        em.activateAll();
+    }
+    
 
     @Override
     public V get(Object key) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManager.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManager.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManager.java
Tue Sep  4 18:25:02 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.bus.extension;
 
 public interface ExtensionManager {
+    void activateAll();
     
     void activateViaNS(String namespace);
     

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerBus.java
Tue Sep  4 18:25:02 2007
@@ -117,6 +117,8 @@
             bfm = new BindingFactoryManagerImpl(new DeferredMap<BindingFactory>(em,
BindingFactory.class));
             extensions.put(BindingFactoryManager.class, bfm);
         }
+        
+        this.setExtension(em, ExtensionManager.class);
     }
 
     public ExtensionManagerBus() {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/extension/ExtensionManagerImpl.java
Tue Sep  4 18:25:02 2007
@@ -86,6 +86,12 @@
         extensions.clear();
         deferred.remove(namespaceURI);
     }
+    
+    public synchronized void activateAll() {
+        while (!deferred.isEmpty()) {
+            activateViaNS(deferred.keySet().iterator().next());
+        }
+    }
 
     final void load(String resource) throws IOException {
         Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().getResources(resource);
@@ -106,11 +112,10 @@
     }
 
     final void processExtension(Extension e) {
-
+        
         if (!e.isDeferred()) {
             loadAndRegister(e);
         }
-
         Collection<String> namespaces = e.getNamespaces();
         for (String ns : namespaces) {
             Collection<Extension> extensions = deferred.get(ns);
@@ -177,6 +182,7 @@
     }
 
     public <T> T getExtension(String ns, Class<T> type) {
+        
         Collection<Object> nsExts = namespaced.get(ns);
         if (nsExts != null) {
             for (Object o : nsExts) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/DestinationFactoryManagerImpl.java
Tue Sep  4 18:25:02 2007
@@ -30,6 +30,7 @@
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
+import org.apache.cxf.bus.extension.DeferredMap;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.i18n.Message;
 
@@ -109,6 +110,7 @@
     }
 
     public DestinationFactory getDestinationFactoryForUri(String uri) {
+        //first attempt the ones already registered
         for (DestinationFactory df : destinationFactories.values()) {
             for (String prefix : df.getUriPrefixes()) {
                 if (uri.startsWith(prefix)) {
@@ -116,6 +118,18 @@
                 }
             }
         }
+        //looks like we'll need to undefer everything so we can try again.
+        if (destinationFactories instanceof DeferredMap) {
+            ((DeferredMap)destinationFactories).undefer();
+            for (DestinationFactory df : destinationFactories.values()) {
+                for (String prefix : df.getUriPrefixes()) {
+                    if (uri.startsWith(prefix)) {
+                        return df;
+                    }
+                }
+            }
+        }
+        
         return null;
     }
 

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/array/DuplicateArrayTest.java
Tue Sep  4 18:25:02 2007
@@ -49,7 +49,7 @@
         // Enable the writing of xsi:type attributes
         props.put(AegisDatabinding.WRITE_XSI_TYPE_KEY, Boolean.TRUE);
 
-        serviceFactory.setAddress("local:://DuplicateArrayService");
+        serviceFactory.setAddress("local://DuplicateArrayService");
         serviceFactory.setServiceBean(new DuplicateArrayServiceBean());
         serviceFactory.setServiceClass(DuplicateArrayService.class);
         serviceFactory.setProperties(props);

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/DualOutServiceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/DualOutServiceTest.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/DualOutServiceTest.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/DualOutServiceTest.java
Tue Sep  4 18:25:02 2007
@@ -32,7 +32,7 @@
     public void testWSDL() throws Exception {
         JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
         sf.setServiceClass(DualOutService.class);
-        sf.setAddress("DualOutService");
+        sf.setAddress("local://DualOutService");
         sf.setBus(getBus());
         setupAegis(sf);
         sf.create();

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ServiceImpl.java
Tue Sep  4 18:25:02 2007
@@ -387,12 +387,24 @@
                                             PortInfoImpl portInfo) throws BusException {
         EndpointInfo ei = null;               
         String address = portInfo.getAddress();
+        String bindingID = BindingID.getBindingID(portInfo.getBindingID());
        
         DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
-        DestinationFactory df = dfm.getDestinationFactoryForUri(portInfo.getAddress());
+        try {
+            //the bindingId might be the transportId, just attempt to 
+            //load it to force the factory to load
+            dfm.getDestinationFactory(bindingID);
+        } catch (BusException ex) {
+            //ignore
+        }
+        DestinationFactory df = dfm.getDestinationFactoryForUri(address);
 
-        String transportId = df.getTransportIds().get(0);
-        String bindingID = BindingID.getBindingID(portInfo.getBindingID());
+        String transportId = null;
+        if (df != null && df.getTransportIds() != null && !df.getTransportIds().isEmpty())
{
+            transportId = df.getTransportIds().get(0);
+        } else {
+            transportId = bindingID;
+        }
                 
         Object config = null;
         if (serviceFactory instanceof JaxWsServiceFactoryBean) {

Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
(original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPTransportFactory.java
Tue Sep  4 18:25:02 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.transport.http;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -121,10 +122,15 @@
      * named "activationNamespaces").
      */
     @PostConstruct
-    void registerWithBindingManager() {
+    public void registerWithBindingManager() {
         if (null == bus) {
             return;
         }
+        
+        if (getTransportIds() == null) {
+            setTransportIds(new ArrayList<String>(activationNamespaces));
+        }
+        
         ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
 
         //Note, activationNamespaces can be null

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/rest/RestClientServerBookTest.java
Tue Sep  4 18:25:02 2007
@@ -39,7 +39,6 @@
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 
 
@@ -52,7 +51,6 @@
     }
 
     @Test
-    @Ignore
     public void testGetBookWithXmlRootElement() throws Exception {
         JaxWsProxyFactoryBean sf = new JaxWsProxyFactoryBean();
         sf.setServiceClass(BookService.class);
@@ -134,7 +132,6 @@
     }
     
     @Test
-    @Ignore
     public void testGetBookJSON() throws Exception {
         String endpointAddress =
             "http://localhost:9080/json/books/123"; 
@@ -161,14 +158,14 @@
         
         try {
             int result = httpclient.executeMethod(post);
-            System.out.println("Response status code: " + result);
-            System.out.println("Response body: ");
-            System.out.println(post.getResponseBodyAsString());
+            assertEquals(200, result);
+            //System.out.println("Response status code: " + result);
+            //System.out.println("Response body: ");
+            //System.out.println(post.getResponseBodyAsString());
             
-            //InputStream expected = getClass().getResourceAsStream("resources/expected_add_book_json.txt");
+            InputStream expected = getClass().getResourceAsStream("resources/expected_add_book_json.txt");
             
-            //FIXME: result returned is not correct: {"acme.addBookResponse":"2"}
-            //assertEquals(getStringFromInputStream(expected), post.getResponseBodyAsString());
+            assertEquals(getStringFromInputStream(expected), post.getResponseBodyAsString());
         } finally {
             // Release current connection to the connection pool once you are done
             post.releaseConnection();

Modified: incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java?rev=572850&r1=572849&r2=572850&view=diff
==============================================================================
--- incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java
(original)
+++ incubator/cxf/trunk/testutils/src/main/java/org/apache/cxf/customer/book/BookService.java
Tue Sep  4 18:25:02 2007
@@ -39,11 +39,13 @@
 
     @Get
     @HttpResource(location = "/books/{id}")
+    @WebResult(name = "Book")
     Book getBook(@WebParam(name = "GetBook")
                          GetBook getBook) throws BookNotFoundFault;
 
     @Get
     @HttpResource(location = "/books/another/{id}")
+    @WebResult(name = "Book")
     Book getAnotherBook(@WebParam(name = "GetAnotherBook")
                          GetAnotherBook getAnotherBook) throws BookNotFoundFault;
 
@@ -55,6 +57,7 @@
 
     @Post
     @HttpResource(location = "/books")
+    @WebResult(name = "book")
     long addBook(@WebParam(name = "Book")
                      Book c);
 



Mime
View raw message