[jboss-cvs] JBossAS SVN: r109727 - in projects/jboss-jca/trunk/core/src: test/java/org/jboss/jca/core/connectionmanager and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Dec 6 11:12:48 EST 2010


Author: jesper.pedersen
Date: 2010-12-06 11:12:47 -0500 (Mon, 06 Dec 2010)
New Revision: 109727

Added:
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/SerializableTestCase.java
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/package.html
   projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java
Modified:
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
Log:
[JBJCA-477] Connection manager not completely serializable (Part 1)

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java	2010-12-06 14:19:31 UTC (rev 109726)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/AbstractConnectionManager.java	2010-12-06 16:12:47 UTC (rev 109727)
@@ -69,13 +69,13 @@
    private static final String SECURITY_MGR_PATH = "java:/jaas/";
    
    /** The pool */
-   private Pool pool;
+   private transient Pool pool;
    
    /** Security domain jndi name */
    private String securityDomainJndiName;
    
    /** SubjectFactory */
-   private SubjectFactory subjectFactory;
+   private transient SubjectFactory subjectFactory;
    
    /** Number of retry to allocate connection */
    private int allocationRetry;
@@ -87,7 +87,7 @@
    private AtomicBoolean shutdown = new AtomicBoolean(false);
    
    /** Cached connection manager */
-   private CachedConnectionManager cachedConnectionManager;
+   private transient CachedConnectionManager cachedConnectionManager;
    
    /** Jndi name */
    private String jndiName;

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/SerializableTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/SerializableTestCase.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/SerializableTestCase.java	2010-12-06 16:12:47 UTC (rev 109727)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.core.connectionmanager.notx;
+
+import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.connectionmanager.ConnectionManagerFactory;
+import org.jboss.jca.core.connectionmanager.common.MockManagedConnectionFactory;
+import org.jboss.jca.core.connectionmanager.pool.api.Pool;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+import static org.junit.Assert.*;
+
+/**
+ * Serializable test of the transaction connection manager
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a> 
+ */
+public class SerializableTestCase
+{
+   /**
+    * testSerializable.
+    * @throws Throwable for exception
+    */
+   @Test
+   public void testSerializable() throws Throwable
+   {
+      ManagedConnectionFactory mcf = new MockManagedConnectionFactory();
+      PoolConfiguration pc = new PoolConfiguration();      
+      PoolFactory pf = new PoolFactory();      
+      
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      
+      ConnectionManagerFactory cmf = new ConnectionManagerFactory();
+
+      ConnectionManager connectionManager = cmf.createNonTransactional(TransactionSupportLevel.NoTransaction,
+                                                                       pool,
+                                                                       null, null);
+      assertNotNull(connectionManager);
+      
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+      oos.writeObject(connectionManager);
+   }
+   
+   /**
+    * Lifecycle start, before the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @BeforeClass
+   public static void beforeClass() throws Throwable
+   {
+   }
+   
+   /**
+    * Lifecycle stop, after the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @AfterClass
+   public static void afterClass() throws Throwable
+   {
+   }   
+}

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/package.html
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/package.html	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/notx/package.html	2010-12-06 16:12:47 UTC (rev 109727)
@@ -0,0 +1,3 @@
+<body>
+Test cases for the non transactional connection manager.
+</body>

Added: projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java
===================================================================
--- projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/test/java/org/jboss/jca/core/connectionmanager/tx/SerializableTestCase.java	2010-12-06 16:12:47 UTC (rev 109727)
@@ -0,0 +1,130 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.core.connectionmanager.tx;
+
+import org.jboss.jca.core.api.connectionmanager.ConnectionManager;
+import org.jboss.jca.core.connectionmanager.ConnectionManagerFactory;
+import org.jboss.jca.core.connectionmanager.common.MockManagedConnectionFactory;
+import org.jboss.jca.core.connectionmanager.pool.api.Pool;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolConfiguration;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolFactory;
+import org.jboss.jca.core.connectionmanager.pool.api.PoolStrategy;
+import org.jboss.jca.embedded.Embedded;
+import org.jboss.jca.embedded.EmbeddedFactory;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.resource.spi.TransactionSupport.TransactionSupportLevel;
+import javax.transaction.TransactionManager;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+import static org.junit.Assert.*;
+
+/**
+ * Serializable test of the transaction connection manager
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a> 
+ */
+public class SerializableTestCase
+{
+   /**Embedded JCA*/
+   private static Embedded embedded = null;
+   
+   /**
+    * testSerializable.
+    * @throws Throwable for exception
+    */
+   @Test
+   public void testSerializable() throws Throwable
+   {
+      TransactionManager tm = embedded.lookup("RealTransactionManager", TransactionManager.class);
+      assertNotNull(tm);
+      
+      ManagedConnectionFactory mcf = new MockManagedConnectionFactory();
+      PoolConfiguration pc = new PoolConfiguration();      
+      PoolFactory pf = new PoolFactory();      
+      
+      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, true);
+      
+      ConnectionManagerFactory cmf = new ConnectionManagerFactory();
+      ConnectionManager connectionManager = cmf.createTransactional(TransactionSupportLevel.XATransaction,
+                                                                    pool,
+                                                                    null, null,
+                                                                    tm, 
+                                                                    Boolean.FALSE, null, null, null, null);
+      assertNotNull(connectionManager);
+      
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+      oos.writeObject(connectionManager);
+   }
+   
+   /**
+    * Lifecycle start, before the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @BeforeClass
+   public static void beforeClass() throws Throwable
+   {
+      // Create and set an embedded JCA instance
+      embedded = EmbeddedFactory.create(false);
+
+      // Startup
+      embedded.startup();
+
+      // Deploy Naming and Transaction
+      URL naming = SerializableTestCase.class.getClassLoader().getResource("naming.xml");
+      URL transaction = SerializableTestCase.class.getClassLoader().getResource("transaction.xml");
+
+      embedded.deploy(naming);
+      embedded.deploy(transaction);
+   }
+   
+   /**
+    * Lifecycle stop, after the suite is executed
+    * @throws Throwable throwable exception 
+    */
+   @AfterClass
+   public static void afterClass() throws Throwable
+   {
+      // Undeploy Transaction and Naming
+      URL naming = SerializableTestCase.class.getClassLoader().getResource("naming.xml");
+      URL transaction = SerializableTestCase.class.getClassLoader().getResource("transaction.xml");
+
+      embedded.undeploy(transaction);
+      embedded.undeploy(naming);
+
+      // Shutdown embedded
+      embedded.shutdown();
+
+      // Set embedded to null
+      embedded = null;
+   }   
+   
+}



More information about the jboss-cvs-commits mailing list