You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/10/08 18:52:20 UTC

svn commit: r582880 - in /incubator/cxf/branches/2.0.x-fixes: ./ integration/jca/src/main/java/org/apache/cxf/connector/ integration/jca/src/main/java/org/apache/cxf/jca/cxf/ integration/jca/src/test/java/org/apache/cxf/jca/cxf/ systests/src/test/java/...

Author: dkulp
Date: Mon Oct  8 09:52:17 2007
New Revision: 582880

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

........
  r578027 | ningjiang | 2007-09-21 05:12:28 -0400 (Fri, 21 Sep 2007) | 1 line
  
  CXF-1044 ,thanks Jeff
........

Added:
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/connector/CXFConnectionParam.java
      - copied unchanged from r578027, incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/connector/CXFConnectionParam.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/CXFManagedConnectionMetaData.java
      - copied unchanged from r578027, incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/CXFManagedConnectionMetaData.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/Messages.properties
      - copied unchanged from r578027, incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/Messages.properties
Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/connector/CXFConnectionFactory.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/CXFConnectionRequestInfo.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ConnectionFactoryImpl.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ManagedConnectionImpl.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ConnectionFactoryImplTest.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java
    incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionTestBase.java
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Oct  8 09:52:17 2007
@@ -1 +1 @@
-/incubator/cxf/trunk:1-573657,573659-573660,573662-574161,574163-574834,574836-575221,575223-575253,575255-576654,576656-576672,576674-576710,576712-576775,576777-576788,576790-576791,576793-576831,576833-577091,577477,577543,577649,577992
+/incubator/cxf/trunk:1-573657,573659-573660,573662-574161,574163-574834,574836-575221,575223-575253,575255-576654,576656-576672,576674-576710,576712-576775,576777-576788,576790-576791,576793-576831,576833-577091,577477,577543,577649,577992,578027

Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/connector/CXFConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/connector/CXFConnectionFactory.java?rev=582880&r1=582879&r2=582880&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/connector/CXFConnectionFactory.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/connector/CXFConnectionFactory.java Mon Oct  8 09:52:17 2007
@@ -18,9 +18,7 @@
  */
 package org.apache.cxf.connector;
 
-import java.net.URL;
 import javax.resource.ResourceException;
-import javax.xml.namespace.QName;
 
 /**
  * Provides methods to create a {@link Connection} object that represents a Web
@@ -29,68 +27,18 @@
  */
 
 public interface CXFConnectionFactory {
-
-    /**
-     * Creates a client proxy based on the given WSDL information.
-     * 
-     * @param iface The interface class implemented by the returned proxy.
-     * @param wsdlLocation The URL to the WSDL that defines the service.
-     * @param serviceName The QName that identifies the service.
-     * @param portName The port to connect to; services may include multiple
-     *            ports.
-     * @return a proxy object that implements both the given <code>iface</code>
-     *         and the {@link Connection} interface. It represents the Web
-     *         service associated with the specified service and port.
-     * @throws ResourceException If there is an error creating the connection.
-     */
-    Object getConnection(Class iface, URL wsdlLocation, QName serviceName, QName portName)
-        throws ResourceException;
-
+    
     /**
-     * Creates a client proxy based on the given WSDL information. If the
-     * service contains more than one port the first one will be used.
-     * 
-     * @param iface The interface class implemented by the returned proxy.
-     * @param wsdlLocation The URL to the WSDL that defines the service.
-     * @param serviceName The QName that identifies the service.
+     *  Creates a client proxy based on the connection parameter object.
+     * @param param,
      * @return A proxy object that implements both the given <code>iface</code>
      *         and the {@link Connection} interface. It represents the Web
      *         service associated with the specified service.
-     * @throws ResourceException If there is an error creating the connection.
+     * @throws ResourceException
      */
-    Object getConnection(Class iface, URL wsdlLocation, QName serviceName) throws ResourceException;
-
-    /**
-     * Creates a client proxy based on the given WSDL information. The WSDL
-     * location will be obtained from Bus configuration using the
-     * <code>serviceName</code>.
-     * 
-     * @param iface The interface class implemented by the returned proxy.
-     * @param serviceName The QName that identifies the service.
-     * @param portName The port to connect to; services may include multiple
-     *            ports.
-     * @return A proxy object that implements both the given <code>iface</code>
-     *         and the {@link Connection} interface. It represents the Web
-     *         service associated with the specified service and port.
-     * @throws ResourceException If there is an error creating the connection.
-     */
-    Object getConnection(Class iface, QName serviceName, QName portName) throws ResourceException;
-
-    /**
-     * Creates a client proxy based on the given WSDL information. If the
-     * service contains more than one port the first one will be used as no port
-     * name is passed. The WSDL location will be obtained from Bus configuration
-     * using the <code>serviceName</code>.
-     * 
-     * @param iface The interface class implemented by the returned proxy.
-     * @param serviceName The QName that identifies the service..
-     * @return A proxy object that implements both the given <code>iface</code>
-     *         and the {@link Connection} interface. It represents the Web
-     *         service associated with the specified service.
-     * @throws ResourceException If there is an error creating the connection.
-     */
-    Object getConnection(Class iface, QName serviceName) throws ResourceException;
-
+    Object getConnection(CXFConnectionParam param) throws ResourceException;
+    
+    
     /**
      * Returns the underlying {@link Bus} for this connection factory. In some
      * J2EE environments, for example Weblogic, the {@link Bus} and dependent

Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/CXFConnectionRequestInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/CXFConnectionRequestInfo.java?rev=582880&r1=582879&r2=582880&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/CXFConnectionRequestInfo.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/CXFConnectionRequestInfo.java Mon Oct  8 09:52:17 2007
@@ -20,75 +20,22 @@
 
 
 import java.net.URL;
+
 import javax.resource.spi.ConnectionRequestInfo;
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.connector.CXFConnectionParam;
 
-public class CXFConnectionRequestInfo implements ConnectionRequestInfo {
-    private Class iface;
-    private URL wsdlLocation;
-    private QName serviceName;
-    private QName portName;
 
+public class CXFConnectionRequestInfo extends CXFConnectionParam implements ConnectionRequestInfo {
+   
+    public CXFConnectionRequestInfo() {
+        super();
+    }
+    
     public CXFConnectionRequestInfo(Class aIface, URL aWsdlLocation, 
                                        QName aServiceName, QName aPortName) {
-        this.iface = aIface;
-        this.wsdlLocation = aWsdlLocation;
-        this.serviceName = aServiceName;
-        this.portName = aPortName;
-    }
-
-    public Class<?> getInterface() {
-        return iface;
-    }
-
-    public URL getWsdlLocationUrl() {
-        return wsdlLocation;
+        super(aIface, aWsdlLocation, aServiceName, aPortName);
     }
-
-    public QName getServiceQName() {
-        return serviceName;
-    }
-
-    public QName getPortQName() {
-        return portName;
-    }
-
-
-
-    public boolean equals(java.lang.Object other) {
-        boolean ret = this == other; 
-
-        if (!ret && other instanceof CXFConnectionRequestInfo) {
-            CXFConnectionRequestInfo cri = (CXFConnectionRequestInfo)other; 
-
-            ret = areEquals(iface, cri.iface) && areEquals(wsdlLocation, cri.wsdlLocation)
-                   && areEquals(serviceName, cri.serviceName) && areEquals(portName, cri.portName);
-           
-        }
-        return ret;
-    }
-  
-    public int hashCode() {
-        return getInterface().hashCode() + (serviceName != null ? serviceName.hashCode() : 0);
-    }  
-
-    public String toString() {
-        StringBuffer buf = new StringBuffer(256);
-
-        buf.append(iface).append(":").append(portName).append(":").append(serviceName).append("@").append(
-                wsdlLocation);
-
-        return buf.toString();
-    }
-
-
-    private boolean areEquals(Object obj1, Object obj2) {
-        if (obj1 == null) {
-            return obj1 == obj2; 
-        } else {
-            return obj1.equals(obj2);
-        }            
-    }
-   
+    
 }

Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ConnectionFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ConnectionFactoryImpl.java?rev=582880&r1=582879&r2=582880&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ConnectionFactoryImpl.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ConnectionFactoryImpl.java Mon Oct  8 09:52:17 2007
@@ -20,7 +20,7 @@
 
 
 import java.io.Serializable;
-import java.net.URL;
+import java.util.ResourceBundle;
 
 import javax.naming.NamingException;
 import javax.naming.Reference;
@@ -29,15 +29,17 @@
 import javax.resource.spi.ConnectionManager;
 import javax.resource.spi.ManagedConnection;
 import javax.resource.spi.ManagedConnectionFactory;
-import javax.xml.namespace.QName;
-
 
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.connector.CXFConnectionFactory;
+import org.apache.cxf.connector.CXFConnectionParam;
 import org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException;
 
 public class ConnectionFactoryImpl implements CXFConnectionFactory, 
                                               Referenceable, 
                                               Serializable {
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ConnectionFactoryImpl.class);
     private ManagedConnectionFactory managedConnectionFactory;
     private ConnectionManager connectionManager;
     private Reference reference;
@@ -55,35 +57,25 @@
         return reference;
     }
     
-    public Object getConnection(Class iface, URL wsdlLocation, QName serviceName) throws ResourceException {
-        return getConnection(iface, wsdlLocation, serviceName, null);
-    }
-
-    public Object getConnection(Class iface, QName serviceName, QName portName) throws ResourceException {
-        return getConnection(iface, null, serviceName, portName);
-    }
-
-    public Object getConnection(Class iface, QName serviceName) throws ResourceException {
-        return getConnection(iface, null, serviceName, null);
-    }
   
 
     public Object getBus() { 
         return ((ManagedConnectionFactoryImpl)managedConnectionFactory).getBus();
     }
 
-    public Object getConnection(Class iface, URL wsdlLocation, QName serviceName, QName portName)
-        throws ResourceException {
+    public Object getConnection(CXFConnectionParam param) throws ResourceException {
         
-        if (!iface.isInterface()) {
-            throw new ResourceAdapterInternalException(
-                    "The first argument to getConnection must be an Interface",
-                    new IllegalArgumentException(iface.toString() + " is not an Interface."));
+        if (param.getInterface() == null) {
+            throw new ResourceAdapterInternalException(new Message("INTERFACE_IS_NULL", BUNDLE).toString());
         }
         
-        CXFConnectionRequestInfo reqInfo = 
-            new CXFConnectionRequestInfo(iface, wsdlLocation, serviceName, portName);
-
+        if (!param.getInterface().isInterface()) {
+            throw new ResourceAdapterInternalException(new Message("IS_NOT_AN_INTERFACE", 
+                                                                   BUNDLE, param.getInterface()).toString());
+        }
+        
+        CXFConnectionRequestInfo reqInfo = (CXFConnectionRequestInfo) param;
+        
         if (connectionManager == null) {
             // non-managed, null Subject
             ManagedConnection connection = managedConnectionFactory.createManagedConnection(null, reqInfo);
@@ -92,22 +84,7 @@
             return connectionManager.allocateConnection(managedConnectionFactory, reqInfo);
         }
     }
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
 
+}
 

Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ManagedConnectionImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ManagedConnectionImpl.java?rev=582880&r1=582879&r2=582880&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ManagedConnectionImpl.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/ManagedConnectionImpl.java Mon Oct  8 09:52:17 2007
@@ -20,10 +20,9 @@
 
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Proxy;
-import java.net.URL;
-//import java.util.Iterator;
-import java.util.logging.Logger;
+import java.util.ResourceBundle;
 
+import javax.jws.WebService;
 import javax.resource.NotSupportedException;
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionRequestInfo;
@@ -31,14 +30,14 @@
 import javax.resource.spi.ManagedConnectionMetaData;
 import javax.security.auth.Subject;
 import javax.transaction.xa.XAResource;
-//import javax.wsdl.Port;
-import javax.xml.namespace.QName;
-import javax.xml.ws.Service;
 import javax.xml.ws.WebServiceException;
 
 import org.apache.cxf.Bus;
-import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.i18n.Message;
 import org.apache.cxf.connector.Connection;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.jca.core.resourceadapter.AbstractManagedConnectionImpl;
 import org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException;
 import org.apache.cxf.jca.cxf.handlers.InvocationHandlerFactory;
@@ -47,40 +46,38 @@
     extends AbstractManagedConnectionImpl 
     implements CXFManagedConnection, Connection {
 
-    private static final Logger LOG = LogUtils.getL7dLogger(ManagedConnectionImpl.class);    
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(ConnectionFactoryImpl.class);   
 
-    private InvocationHandlerFactory handlerFactory;
-    
+    private InvocationHandlerFactory handlerFactory;    
     private Object cxfService;
     private boolean connectionHandleActive;
 
     public ManagedConnectionImpl(ManagedConnectionFactoryImpl managedFactory, ConnectionRequestInfo crInfo,
                                  Subject subject) throws ResourceException {
         super(managedFactory, crInfo, subject);
-        LOG.fine("ManagedConnection created with hash: " + hashCode() + "." + toString());
     }
 
-    public void associateConnection(Object arg0) throws ResourceException {
+    public void associateConnection(Object connection) throws ResourceException {
         try {           
-            CXFInvocationHandler handler = (CXFInvocationHandler)Proxy.getInvocationHandler((Proxy)arg0);
+            CXFInvocationHandler handler = 
+                    (CXFInvocationHandler)Proxy.getInvocationHandler((Proxy)connection);
             Object managedConnection = handler.getData().getManagedConnection();
 
             if (managedConnection != this) {
                 handler.getData().setManagedConnection(this);
-                ((ManagedConnectionImpl)managedConnection).disassociateConnectionHandle(arg0);
+                ((ManagedConnectionImpl)managedConnection).disassociateConnectionHandle(connection);
 
                 if (getCXFService() == null) { 
                     // Very unlikely as THIS
                     // managed connection is
                     // already involved in a transaction.
-                    cxfService = arg0;
+                    cxfService = connection;
                     connectionHandleActive = true;
                 }
-
             }
         } catch (Exception ex) {         
-            throw new ResourceAdapterInternalException("Error associating handle " + arg0
-                                                       + " with managed connection " + this, ex);
+            throw new ResourceAdapterInternalException(
+                              new Message("ASSOCIATED_ERROR", BUNDLE).toString(), ex);
         }
     }
 
@@ -88,79 +85,90 @@
         return (ManagedConnectionFactoryImpl)theManagedConnectionFactory();
     }
 
-    final Object getCXFService() {
+    public Object getCXFService() {
         return cxfService;
     }
 
-    final void initialiseCXFService(ConnectionRequestInfo crInfo, Subject subject)
+    private void initializeCXFConnection(ConnectionRequestInfo crInfo, Subject subject)
         throws ResourceException {
         this.crinfo = crInfo;
         this.subject = subject;
-
-        cxfService = getCXFServiceFromBus(subject, crInfo);
+        cxfService = getCXFConnection(subject, crInfo);
     }
 
     public Object getConnection(Subject subject, ConnectionRequestInfo crInfo) throws ResourceException {
 
         Object connection = null;
-
+        
         if (getCXFService() == null) {
-            initialiseCXFService(crInfo, subject);
-            connection = getCXFService();
-            
+            initializeCXFConnection(crInfo, subject);
+            connection = getCXFService();            
         } else {
             if (!connectionHandleActive && this.crinfo.equals(crInfo)) {
                 connection = getCXFService();
             } else {
-                connection = getCXFServiceFromBus(subject, crInfo);
+                connection = getCXFConnection(subject, crInfo);
             }
         }
         connectionHandleActive = true;
         return connection;
     }
 
-    public synchronized Object getCXFServiceFromBus(Subject subject, ConnectionRequestInfo crInfo)
+    public synchronized Object getCXFConnection(Subject subject, ConnectionRequestInfo crInfo)
         throws ResourceException {
 
-        CXFConnectionRequestInfo arReqInfo = (CXFConnectionRequestInfo)crInfo;
-        
+        CXFConnectionRequestInfo requestInfo = (CXFConnectionRequestInfo)crInfo;
+        Class<?> serviceInterface = requestInfo.getInterface();
         ClassLoader orig = Thread.currentThread().getContextClassLoader();
-        QName serviceName = arReqInfo.getServiceQName();
-        URL wsdlLocationUrl = arReqInfo.getWsdlLocationUrl();
-        
         try {
-            Object obj = null;
-            Service service = null;
-            if (wsdlLocationUrl == null) {    
-                service = Service.create(serviceName);
+            ClientProxyFactoryBean factoryBean = null;
+            if (isJaxWsServiceInterface(serviceInterface)) {
+                factoryBean = new JaxWsProxyFactoryBean();
             } else {
-                service = Service.create(wsdlLocationUrl, serviceName);
+                factoryBean = new ClientProxyFactoryBean();
             }
-        
-            QName port = arReqInfo.getPortQName();
-            if (port == null) {
-                obj = service.getPort(arReqInfo.getInterface());
-            } else {
-                obj = service.getPort(arReqInfo.getPortQName(), arReqInfo.getInterface());
+            factoryBean.setServiceClass(serviceInterface);
+            if (requestInfo.getServiceName() != null) {
+                factoryBean.getServiceFactory().setServiceName(requestInfo.getServiceName());
+            }
+            if (requestInfo.getPortName() != null) {
+                factoryBean.getServiceFactory().setEndpointName(requestInfo.getPortName());
             }
+            if (requestInfo.getWsdlLocation() != null) {
+                factoryBean.getServiceFactory().setWsdlURL(requestInfo.getWsdlLocation());
+            }
+            if (requestInfo.getAddress() != null) {
+                factoryBean.setAddress(requestInfo.getAddress());
+            }
+            
+            Object obj = factoryBean.create();
             
             setSubject(subject);
             
-            return createConnectionProxy(obj, arReqInfo, subject);
+            return createConnectionProxy(obj, requestInfo, subject);
         } catch (WebServiceException wse) {
-            throw new ResourceAdapterInternalException("Failed to create proxy client for service " 
-                                                       + arReqInfo, wse);
+            throw new ResourceAdapterInternalException(new Message("FAIL_TO_GET_CXF_CONNECTION", 
+                                                                   BUNDLE, requestInfo).toString() , wse);
         } finally {
             Thread.currentThread().setContextClassLoader(orig);
         }
-
- 
     }
 
     public ManagedConnectionMetaData getMetaData() throws ResourceException {
-        throw new NotSupportedException("Not Supported");
+        return new CXFManagedConnectionMetaData();
     }
-
+    
+    
+    private boolean isJaxWsServiceInterface(Class<?> cls) {
+        if (cls == null) {
+            return false;
+        }
+        if (null != cls.getAnnotation(WebService.class)) {
+            return true;
+        }
+        return false;
+    }
+    
     public boolean isBound() {
         return getCXFService() != null;
     }

Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ConnectionFactoryImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ConnectionFactoryImplTest.java?rev=582880&r1=582879&r2=582880&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ConnectionFactoryImplTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ConnectionFactoryImplTest.java Mon Oct  8 09:52:17 2007
@@ -30,41 +30,42 @@
 import javax.resource.spi.ManagedConnectionFactory;
 import javax.xml.namespace.QName;
 
-
-
 import org.easymock.classextension.EasyMock;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
 public class ConnectionFactoryImplTest extends Assert {
+    
     ManagedConnectionFactory mockConnectionFactory;
-
     ConnectionManager mockConnectionManager;
+    CXFConnectionRequestInfo param;
+    ConnectionFactoryImpl cf;
 
     @Before
     public void setUp() throws Exception {
         mockConnectionFactory = EasyMock.createMock(ManagedConnectionFactory.class);
         mockConnectionManager = EasyMock.createMock(ConnectionManager.class);
+        
+        param = new CXFConnectionRequestInfo();
+        param.setInterface(Runnable.class);
+        
+        cf = new ConnectionFactoryImpl(mockConnectionFactory, mockConnectionManager);
     }
 
     @Test
     public void testInstanceOfSerializable() throws Exception {
-        ConnectionFactoryImpl cf = new ConnectionFactoryImpl(mockConnectionFactory,
-                                                             mockConnectionManager);
-        assertTrue("instance of serializable", cf instanceof Serializable);
+        assertTrue("Instance of Serializable", cf instanceof Serializable);
     }
 
     @Test
     public void testInstanceOfReferencable() throws Exception {
-        ConnectionFactoryImpl cf = new ConnectionFactoryImpl(mockConnectionFactory,
-                                                             mockConnectionManager);
-        assertTrue("instance of Referencable", cf instanceof Referenceable);
+        assertTrue("Instance of Referencable", cf instanceof Referenceable);
 
-        assertNull("no ref set", cf.getReference());
+        assertNull("No ref set", cf.getReference());
         Reference ref = EasyMock.createMock(Reference.class);
         cf.setReference(ref);
-        assertEquals("got back what was set", ref, cf.getReference());
+        assertEquals("Got back what was set", ref, cf.getReference());
     }
 
     @Test
@@ -82,12 +83,11 @@
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(mockConnectionManager);
          
-       
-        ConnectionFactoryImpl cf = new ConnectionFactoryImpl((ManagedConnectionFactory)mockConnectionFactory,
-                                                             (ConnectionManager)mockConnectionManager);
-        
-        Object o = cf.getConnection(Runnable.class, new URL("file:/tmp/foo"), new QName(""), new QName(""));
-        assertNull("got the result (the passed in ConnectionRequestInfo) from out mock manager",
+        param.setWsdlLocation(new URL("file:/tmp/foo"));
+        param.setServiceName(new QName(""));
+        param.setPortName(new QName(""));
+        Object o = cf.getConnection(param);
+        assertNull("Got the result (the passed in ConnectionRequestInfo) from out mock manager",
                    o);
         EasyMock.verify(mockConnectionManager); 
     }
@@ -107,15 +107,14 @@
                                                  EasyMock.eq(reqInfo));
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(mockConnectionManager);
-
-        ConnectionFactoryImpl cf = new ConnectionFactoryImpl((ManagedConnectionFactory)mockConnectionFactory,
-                                                             (ConnectionManager)mockConnectionManager);
         
-        Object o = cf.getConnection(Runnable.class, new URL("file:/tmp/foo"), new QName(""));
+        param.setWsdlLocation(new URL("file:/tmp/foo"));
+        param.setServiceName(new QName(""));
+        Object o = cf.getConnection(param);
         
         EasyMock.verify(mockConnectionManager);
         
-        assertNull("got the result (the passed in ConnectionRequestInfo) from out mock manager",
+        assertNull("Got the result (the passed in ConnectionRequestInfo) from out mock manager",
                    o);
         
         
@@ -137,13 +136,12 @@
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(mockConnectionManager);
 
-        ConnectionFactoryImpl cf = new ConnectionFactoryImpl((ManagedConnectionFactory)mockConnectionFactory,
-                                                             (ConnectionManager)mockConnectionManager);
-
-        Object o = cf.getConnection(Runnable.class, new QName(""), new QName(""));
+        param.setServiceName(new QName(""));
+        param.setPortName(new QName(""));
+        Object o = cf.getConnection(param);
         EasyMock.verify(mockConnectionManager);
         
-        assertNull("got the result (the passed in ConnectionRequestInfo) from out mock manager",
+        assertNull("Got the result (the passed in ConnectionRequestInfo) from out mock manager",
                    o);
         
     }
@@ -164,11 +162,10 @@
         EasyMock.expectLastCall().andReturn(null);
         EasyMock.replay(mockConnectionManager);
         
-        ConnectionFactoryImpl cf = new ConnectionFactoryImpl((ManagedConnectionFactory)mockConnectionFactory,
-                                                             (ConnectionManager)mockConnectionManager);
-
-        Object o = cf.getConnection(Runnable.class, new QName(""));
-        assertNull("got the result (the passed in ConnectionRequestInfo) from out mock manager",
+        cf = new ConnectionFactoryImpl(mockConnectionFactory, mockConnectionManager);
+        param.setServiceName(new QName(""));
+        Object o = cf.getConnection(param);
+        assertNull("Got the result (the passed in ConnectionRequestInfo) from out mock manager",
                    o);
         
 
@@ -176,17 +173,27 @@
 
     @Test
     public void testGetConnectionWithNonInterface() throws Exception {
-        ConnectionFactoryImpl cf = new ConnectionFactoryImpl(mockConnectionFactory,
-                                                             mockConnectionManager);
-
         try {
-            cf.getConnection(Object.class, new URL("file:/tmp/foo"), new QName(""), new QName(""));
-            fail("expect exception on use of non interface class");
+            param.setInterface(Object.class);
+            param.setWsdlLocation(new URL("file:/tmp/foo"));
+            param.setServiceName(new QName(""));
+            param.setPortName(new QName(""));
+            cf.getConnection(param);
+            fail("Expect exception on use of non interface class");
         } catch (ResourceException re) {
-            assertTrue("nested ex is invalid arg", re.getCause() instanceof IllegalArgumentException);
+            assertTrue(true);
         }
     }
 
-    
+    @Test
+    public void testGetConnectionWithNoInterface() throws Exception {
+        try {
+            param.setInterface(null);
+            cf.getConnection(param);
+            fail("Should get an exception");
+        } catch (ResourceException re) {
+            assertTrue(true);
+        }
+    }
     
 }

Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java?rev=582880&r1=582879&r2=582880&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionImplTest.java Mon Oct  8 09:52:17 2007
@@ -22,9 +22,9 @@
 import java.lang.reflect.Proxy;
 import java.net.URL;
 
-import javax.resource.NotSupportedException;
 import javax.resource.ResourceException;
 import javax.resource.spi.ConnectionEvent;
+import javax.resource.spi.ManagedConnectionMetaData;
 import javax.resource.spi.ResourceAdapterInternalException;
 import javax.resource.spi.security.PasswordCredential;
 import javax.security.auth.Subject;
@@ -44,29 +44,22 @@
     protected QName serviceName;
     protected QName portName;
 
-    @Test   
+    @Test
     public void testInstanceOfConnection() throws Exception {
-        assertTrue("instance of Connection", mci instanceof Connection);
+        assertTrue("Instance of Connection", mci instanceof Connection);
         ((Connection)mci).close();
     }
 
     @Test
     public void testGetConnectionServiceGetPortThrows() throws Exception {
-        
-        cri = new CXFConnectionRequestInfo(Foo.class, null, serviceName, null);
-        
-        try {
-            //Can not create JAX-WS proxy using pojo
-            mci.getConnection(subj, cri);
-            fail("Did not get expected ResourceAdapterInternalException");         
-           
-        } catch (ResourceAdapterInternalException raie) {
-            //do nothing
-        }
+        cri = new CXFConnectionRequestInfo(Foo.class, null, null, null);
+        cri.setAddress("http://localhost:9000/soap");
+        Object o = mci.getConnection(subj, cri);
+        assertTrue(o instanceof Foo);
     }
 
     
-    @Ignore("need to check the classloader")
+    @Ignore("Need to check the classloader")
     public void testThreadContextClassLoaderIsSet() throws Exception {
         //set the threadContextClassLoader for Bus 
         //TODO njiang classloader things
@@ -76,28 +69,22 @@
     
     @Test
     public void testGetConnectionWithNoWSDLInvokesCreateClientWithTwoParameters() throws Exception {
-
-
         cri = new CXFConnectionRequestInfo(Greeter.class, null, serviceName, portName);
         // need to get wsdl
         Object o = mci.getConnection(subj, cri);
 
-        assertTrue("checking implementation of Connection interface", o instanceof Connection);
-        assertTrue("checking implementation of passed interface", o instanceof Greeter);
+        assertTrue("Checking implementation of Connection interface", o instanceof Connection);
+        assertTrue("Checking implementation of passed interface", o instanceof Greeter);
     }
     
+
     @Test
     public void testGetConnectionWithNoWSDLInvokesCreateClientWithTwoArgs()
         throws Exception {
-
         cri = new CXFConnectionRequestInfo(Greeter.class, null, serviceName, null);
-
         Object o = mci.getConnection(subj, cri);
-        assertTrue("checking implementation of Connection interface", o instanceof Connection);
-        assertTrue("checking implementation of passed interface", o instanceof Greeter);
-        
-     
-
+        assertTrue("Checking implementation of Connection interface", o instanceof Connection);
+        assertTrue("Checking implementation of passed interface", o instanceof Greeter);
     }
 
     @Ignore
@@ -110,32 +97,32 @@
         
         Object o = mci.getConnection(subj, cri);
 
-        assertTrue("returned connect does not implement Connection interface", o instanceof Connection);
-        assertTrue("returned connect does not implement Connection interface", o instanceof Greeter);
+        assertTrue("Returned connection does not implement Connection interface", o instanceof Connection);
+        assertTrue("Returned connection does not implement Connection interface", o instanceof Greeter);
     }
 
+
     @Test
     public void testGetConnectionReturnsConnection() throws ResourceException {
         Object o = mci.getConnection(subj, cri);
-        assertTrue("returned connect does not implement Connection interface", o instanceof Connection);
-        assertTrue("returned connect does not implement Connection interface", o instanceof Greeter);
+        assertTrue("Returned connection does not implement Connection interface", o instanceof Connection);
+        assertTrue("Returned connection does not implement Connection interface", o instanceof Greeter);
     }
 
     private void verifyProxyInterceptors(Object o) {
-
         assertTrue(o instanceof Proxy);
-        
-        assertEquals("fist handler must be a ProxyInvocation Handler", ProxyInvocationHandler.class, 
+        assertEquals("First handler must be a ProxyInvocation Handler", ProxyInvocationHandler.class, 
                      Proxy.getInvocationHandler(o).getClass());
     }
 
+
     @Test
     public void testGetConnectionWithDudSubjectA() throws ResourceException {
         Object o = mci.getConnection(subj, cri);
-
         verifyProxyInterceptors(o);
     }
 
+
     @Test
     public void testGetConnectionWithDudSubjectB() throws ResourceException {
         String user = new String("user");
@@ -143,10 +130,11 @@
         PasswordCredential creds = new PasswordCredential(user, password);
         subj.getPrivateCredentials().add(creds);
         Object o = mci.getConnection(subj, cri);
-
+        
         verifyProxyInterceptors(o);
     }
 
+
     @Test
     public void testGetConnectionWithSubject() throws ResourceException {
         String user = new String("user");
@@ -161,20 +149,18 @@
  
 
     @Test
-    public void testCloseConnection() throws Exception {
-      
-        final Connection conn = (Connection)mci.getConnection(subj, cri);
+    public void testCloseConnection() throws Exception {      
+        Connection conn = (Connection)mci.getConnection(subj, cri);
         EasyMock.reset(mockListener);
         mockListener.connectionClosed(EasyMock.isA(ConnectionEvent.class));
         EasyMock.expectLastCall();
-        EasyMock.replay(mockListener);       
+        EasyMock.replay(mockListener);
         conn.close();
     }
 
+
     @Test
     public void testAssociateConnection() throws Exception {
-
-        // Create the additional ManagedConnectionImpl ..
         
         CXFConnectionRequestInfo cri2 = new CXFConnectionRequestInfo(Greeter.class,
                                                                          new URL("file:/tmp/foo2"),
@@ -185,9 +171,9 @@
 
         Object o = mci.getConnection(subj, cri);
 
-        assertTrue("returned connect does not implement Connection interface", o instanceof Connection);
-        assertTrue("returned connect does not implement Connection interface", o instanceof Greeter);
-        assertTrue("returned connection is not a java.lang.reflect.Proxy instance", o instanceof Proxy);
+        assertTrue("Returned connection does not implement Connection interface", o instanceof Connection);
+        assertTrue("Returned connection does not implement Connection interface", o instanceof Greeter);
+        assertTrue("Returned connection is not a java.lang.reflect.Proxy instance", o instanceof Proxy);
 
         InvocationHandler handler = Proxy.getInvocationHandler(o);
 
@@ -196,45 +182,41 @@
 
         Object assocMci = ((CXFInvocationHandler)handler).getData().getManagedConnection();
 
-        assertTrue("asserting associated ManagedConnection.", mci == assocMci);
-        assertTrue("asserting associated ManagedConnection.", mci2 != assocMci);
+        assertTrue("Asserting associated ManagedConnection.", mci == assocMci);
+        assertTrue("Asserting associated ManagedConnection.", mci2 != assocMci);
 
         mci2.associateConnection(o);
 
         assocMci = ((CXFInvocationHandler)handler).getData().getManagedConnection();
 
-        assertTrue("asserting associated ManagedConnection.", mci2 == assocMci);
-        assertTrue("asserting associated ManagedConnection.", mci != assocMci);
+        assertTrue("Asserting associated ManagedConnection.", mci2 == assocMci);
+        assertTrue("Asserting associated ManagedConnection.", mci != assocMci);
 
     }
 
+
     @Test
     public void testAssociateConnectionThrowsException() throws Throwable {
 
-        
         InvocationHandler ih = EasyMock.createMock(InvocationHandler.class);
                 
         Object dodgyHandle = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] {Foo.class}, ih);
 
         try {
             mci.associateConnection(dodgyHandle);
-            fail("except exception on call with ClassCast Exception");
+            fail("Except exception on call with ClassCast Exception");
         } catch (ResourceAdapterInternalException raie) {
-            assertTrue("asserting ResourceException.",
-                       raie.getMessage().indexOf("Error associating handle") != -1);
-            assertTrue("asserting ResourceException.", raie.getCause() instanceof ClassCastException);
+            assertTrue(true);
         }
 
     }
 
+
     @Test
     public void testGetMetaData() throws Exception {
-        try {
-            mci.getMetaData();
-            fail("expect exception on getMetaData");
-        } catch (NotSupportedException expected) {
-            // do nothing here
-        }
+        ManagedConnectionMetaData data = mci.getMetaData();
+        assertEquals("Checking the EISProductionVersion", "1.1", data.getEISProductVersion());
+        assertEquals("Checking the EISProductName", "WS-based-EIS", data.getEISProductName());
     }
   
 }

Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionTestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionTestBase.java?rev=582880&r1=582879&r2=582880&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionTestBase.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/ManagedConnectionTestBase.java Mon Oct  8 09:52:17 2007
@@ -46,14 +46,11 @@
 
     protected ManagedConnectionImpl mci;
 
-    protected ManagedConnectionFactoryImpl factory = 
-        EasyMock.createMock(ManagedConnectionFactoryImpl.class);
+    protected ManagedConnectionFactoryImpl factory = EasyMock.createMock(ManagedConnectionFactoryImpl.class);
 
     protected Bus bus;
     
-
-    protected ConnectionEventListener mockListener = 
-        EasyMock.createMock(ConnectionEventListener.class);
+    protected ConnectionEventListener mockListener = EasyMock.createMock(ConnectionEventListener.class);
     
     public ManagedConnectionTestBase() {
         
@@ -89,11 +86,9 @@
         
         EasyMock.expectLastCall().andReturn(bus).anyTimes();
         EasyMock.replay(factory);
-        
-        
+                
         mci = new ManagedConnectionImpl(factory, cri, subj);        
-      
-        
+              
         mci.addConnectionEventListener(mockListener);
     }
     

Modified: incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java?rev=582880&r1=582879&r2=582880&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jca/OutBoundConnectionTest.java Mon Oct  8 09:52:17 2007
@@ -19,9 +19,10 @@
 
 package org.apache.cxf.systest.jca;
 
-import java.lang.reflect.UndeclaredThrowableException;
 import java.net.URL;
+
 import javax.resource.spi.ManagedConnection;
+import javax.resource.spi.ManagedConnectionFactory;
 import javax.security.auth.Subject;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Endpoint;
@@ -84,7 +85,7 @@
                                            wsdl,
                                            service.getServiceName(),
                                            portName);
-        ManagedConnectionFactoryImpl managedFactory = new ManagedConnectionFactoryImpl();
+        ManagedConnectionFactory managedFactory = new ManagedConnectionFactoryImpl();
         Subject subject = new Subject();
         ManagedConnection mc = managedFactory.createManagedConnection(subject, cri);        
         Object o = mc.getConnection(subject, cri);
@@ -97,20 +98,35 @@
             fail("The connection object should support Object method");
         }
         
+        verifyResult(o);
+    }
+    
+    
+    @Test
+    public void testGetConnectionFromSEI() throws Exception {
+        CXFConnectionRequestInfo requestInfo = new CXFConnectionRequestInfo();
+        requestInfo.setInterface(Greeter.class);
+        requestInfo.setAddress("http://localhost:9000/SoapContext/SoapPort");
+        
+        ManagedConnectionFactory factory = new ManagedConnectionFactoryImpl();
+        ManagedConnection mc = factory.createManagedConnection(null, requestInfo);
+        Object client = mc.getConnection(null, requestInfo);
+        
+        verifyResult(client);
+    }
+    
+    
+    private void verifyResult(Object o) throws Exception {
+        
         assertTrue("returned connect does not implement Connection interface", o instanceof Connection);
         assertTrue("returned connect does not implement Connection interface", o instanceof Greeter);
    
-        Greeter greeter = (Greeter) o;
-        
-        String response = new String("Bonjour");
-        try {       
-            for (int idx = 0; idx < 5; idx++) {
-                String reply = greeter.sayHi();
-                assertNotNull("no response received from service", reply);
-                assertEquals(response, reply);
-            }            
-        } catch (UndeclaredThrowableException ex) {
-            throw (Exception)ex.getCause();
+        Greeter greeter = (Greeter) o;   
+        String response = new String("Bonjour");      
+        for (int idx = 0; idx < 5; idx++) {
+            String reply = greeter.sayHi();
+            assertNotNull("no response received from service", reply);
+            assertEquals(response, reply);
         }
-    } 
+    }
 }