[jboss-osgi-commits] JBoss-OSGI SVN: r95636 - in projects/jboss-osgi/trunk: reactor/jta/src/main/java/org/jboss/osgi/jta/internal and 7 other directories.

jboss-osgi-commits at lists.jboss.org jboss-osgi-commits at lists.jboss.org
Tue Oct 27 18:21:53 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-10-27 18:21:52 -0400 (Tue, 27 Oct 2009)
New Revision: 95636

Added:
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionManagerTestCase.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/UserTransactionTestCase.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/tm/
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/tm/TransactionManagerActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/ut/
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/ut/UserTransactionActivator.java
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-tm.bnd
   projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-ut.bnd
Removed:
   projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/transaction/
Modified:
   projects/jboss-osgi/trunk/reactor/jta/pom.xml
   projects/jboss-osgi/trunk/reactor/jta/src/main/java/org/jboss/osgi/jta/internal/TransactionServiceActivator.java
   projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml
Log:
Enable basic JTA tests

Modified: projects/jboss-osgi/trunk/reactor/jta/pom.xml
===================================================================
--- projects/jboss-osgi/trunk/reactor/jta/pom.xml	2009-10-27 21:38:54 UTC (rev 95635)
+++ projects/jboss-osgi/trunk/reactor/jta/pom.xml	2009-10-27 22:21:52 UTC (rev 95636)
@@ -33,7 +33,7 @@
   <!-- Properties -->
   <properties>
     <version.jboss.jta.api>1.0.1.GA</version.jboss.jta.api>
-    <version.jboss.jbossts>4.4.0.GA</version.jboss.jbossts>
+    <version.jboss.jbossts>4.6.1.GA</version.jboss.jbossts>
   </properties>
   
   <!-- Dependencies -->
@@ -49,7 +49,7 @@
     </dependency>
     <dependency>
       <groupId>jboss.jbossts</groupId>
-      <artifactId>jbossjta</artifactId>
+      <artifactId>jbossjts</artifactId>
       <version>${version.jboss.jbossts}</version>
     </dependency>
     <dependency>
@@ -103,23 +103,29 @@
               javax.naming.spi, 
               javax.xml.parsers, 
               org.apache.commons.logging, 
-              org.apache.log4j, 
               org.jboss.osgi.spi.capability, 
               org.osgi.framework, 
               org.w3c.dom,
               
-              <!-- exclude -->
-              !javax.resource.spi*,
-              !javax.sql,
-              !javax.swing*,
-              !oracle.jdbc.xa*,
-              !oracle.sql,
-              !org.apache.xml.serialize,
+              <!-- excludes -->
+              !com.arjuna.ArjunaOTS, 
+              !com.arjuna.ats.internal*,
+              !javax.resource.spi, 
+              !javax.resource.spi.work, 
+              !javax.sql, 
+              !javax.swing, 
+              !javax.swing.tree, 
+              !oracle.jdbc.xa, 
+              !oracle.jdbc.xa.client, 
+              !oracle.sql, 
+              !org.apache.log4j, 
+              !org.apache.xml.serialize, 
+              !org.omg.*, 
             </Import-Package>
             <Embed-Transitive>true</Embed-Transitive>
             <Embed-Dependency>
               jboss-transaction-api;inline=false,
-              jbossjta;inline=false,
+              jbossjts;inline=false,
               jbossts-common;inline=false,
             </Embed-Dependency>
             <_exportcontents>

Modified: projects/jboss-osgi/trunk/reactor/jta/src/main/java/org/jboss/osgi/jta/internal/TransactionServiceActivator.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/jta/src/main/java/org/jboss/osgi/jta/internal/TransactionServiceActivator.java	2009-10-27 21:38:54 UTC (rev 95635)
+++ projects/jboss-osgi/trunk/reactor/jta/src/main/java/org/jboss/osgi/jta/internal/TransactionServiceActivator.java	2009-10-27 22:21:52 UTC (rev 95636)
@@ -43,13 +43,23 @@
    
    public void start(BundleContext context)
    {
-      // Register the TransactionManager service
-      TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
-      transactionManagerReg = context.registerService(TransactionManager.class.getName(), tm, null);
-      
-      // Register the UserTransaction service   
-      UserTransaction ut = com.arjuna.ats.jta.UserTransaction.userTransaction();
-      userTransactionReg = context.registerService(UserTransaction.class.getName(), ut, null);
+      ClassLoader ctxLoader = Thread.currentThread().getContextClassLoader();
+      try
+      {
+         Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
+         
+         // Register the TransactionManager service
+         TransactionManager tm = com.arjuna.ats.jta.TransactionManager.transactionManager();
+         transactionManagerReg = context.registerService(TransactionManager.class.getName(), tm, null);
+         
+         // Register the UserTransaction service   
+         UserTransaction ut = com.arjuna.ats.jta.UserTransaction.userTransaction();
+         userTransactionReg = context.registerService(UserTransaction.class.getName(), ut, null);
+      }
+      finally
+      {
+         Thread.currentThread().setContextClassLoader(ctxLoader);
+      }
    }
 
    public void stop(BundleContext context)

Modified: projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml	2009-10-27 21:38:54 UTC (rev 95635)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml	2009-10-27 22:21:52 UTC (rev 95636)
@@ -57,6 +57,10 @@
 
     <!-- jndi -->
     <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-jndi.jar" files="${tests.resources.dir}/jndi/example-jndi.bnd" />
+    
+    <!-- jta -->
+    <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-jta-tm.jar" files="${tests.resources.dir}/jta/example-jta-tm.bnd" />
+    <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-jta-ut.jar" files="${tests.resources.dir}/jta/example-jta-ut.bnd" />
 
     <!-- mcservice -->
     <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-mcservice-bundleA.jar" files="${tests.resources.dir}/mcservice/example-mcservice-bundleA.bnd" />

Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionManagerTestCase.java (from rev 95620, projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/transaction/TransactionTestCase.java)
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionManagerTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionManagerTestCase.java	2009-10-27 22:21:52 UTC (rev 95636)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.osgi.example.jta;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+
+import org.jboss.osgi.husky.HuskyCapability;
+import org.jboss.osgi.jta.TransactionCapability;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiTestHelper;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ * An example of OSGi JTA.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Oct-2009
+ */
+public class TransactionManagerTestCase
+{
+   private OSGiRuntime runtime;
+
+   @Before
+   public void setUp() throws Exception
+   {
+      runtime = new OSGiTestHelper().getDefaultRuntime();
+      runtime.addCapability(new HuskyCapability());
+      runtime.addCapability(new TransactionCapability());
+   }
+
+   @After
+   public void tearDown() throws Exception
+   {
+      runtime.shutdown();
+      runtime = null;
+   }
+
+   @Test
+   public void testTransactionManager() throws Exception
+   {
+      OSGiBundle bundle = runtime.installBundle("example-jta-tm.jar");
+      assertEquals(Bundle.INSTALLED, bundle.getState());
+      
+      bundle.start();
+      assertEquals(Bundle.ACTIVE, bundle.getState());
+   }
+}
\ No newline at end of file

Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/UserTransactionTestCase.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/UserTransactionTestCase.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/UserTransactionTestCase.java	2009-10-27 22:21:52 UTC (rev 95636)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.osgi.example.jta;
+
+//$Id$
+
+import static org.junit.Assert.*;
+
+import org.jboss.osgi.husky.HuskyCapability;
+import org.jboss.osgi.jta.TransactionCapability;
+import org.jboss.osgi.testing.OSGiBundle;
+import org.jboss.osgi.testing.OSGiRuntime;
+import org.jboss.osgi.testing.OSGiTestHelper;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.framework.Bundle;
+
+/**
+ * An example of OSGi JTA.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Oct-2009
+ */
+public class UserTransactionTestCase
+{
+   private OSGiRuntime runtime;
+
+   @Before
+   public void setUp() throws Exception
+   {
+      runtime = new OSGiTestHelper().getDefaultRuntime();
+      runtime.addCapability(new HuskyCapability());
+      runtime.addCapability(new TransactionCapability());
+   }
+
+   @After
+   public void tearDown() throws Exception
+   {
+      runtime.shutdown();
+      runtime = null;
+   }
+
+   @Test
+   public void testUserTransaction() throws Exception
+   {
+      OSGiBundle bundle = runtime.installBundle("example-jta-ut.jar");
+      assertEquals(Bundle.INSTALLED, bundle.getState());
+      
+      bundle.start();
+      assertEquals(Bundle.ACTIVE, bundle.getState());
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/UserTransactionTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/tm/TransactionManagerActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/tm/TransactionManagerActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/tm/TransactionManagerActivator.java	2009-10-27 22:21:52 UTC (rev 95636)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.osgi.example.jta.tm;
+
+//$Id$
+
+import static org.junit.Assert.assertNotNull;
+
+import javax.transaction.TransactionManager;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * An example of OSGi JTA.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Oct-2009
+ */
+public class TransactionManagerActivator implements BundleActivator
+{
+   public void start(BundleContext context) throws Exception
+   {
+      ServiceReference sref = context.getServiceReference(TransactionManager.class.getName());
+      assertNotNull("TransactionManager service not null", sref);
+      
+      TransactionManager tm = (TransactionManager)context.getService(sref);
+      assertNotNull("TransactionManager not null", tm);
+   }
+
+   public void stop(BundleContext context) throws Exception
+   {
+   }
+ }
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/tm/TransactionManagerActivator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/ut/UserTransactionActivator.java
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/ut/UserTransactionActivator.java	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/ut/UserTransactionActivator.java	2009-10-27 22:21:52 UTC (rev 95636)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.test.osgi.example.jta.ut;
+
+//$Id$
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * An example of OSGi JTA.
+ * 
+ * @author thomas.diesler at jboss.com
+ * @since 23-Oct-2009
+ */
+public class UserTransactionActivator implements BundleActivator
+{
+   public void start(BundleContext context) throws Exception
+   {
+      ServiceReference sref = context.getServiceReference(UserTransaction.class.getName());
+      assertNotNull("UserTransaction service not null", sref);
+      
+      UserTransaction tx = (UserTransaction)context.getService(sref);
+      assertNotNull("UserTransaction not null", tx);
+      
+//      tx.begin();
+//      try
+//      {
+//         doStuff();
+//         tx.commit();
+//      }
+//      catch (Exception e)
+//      {
+//         tx.setRollbackOnly();
+//      }
+//      assertEquals(Status.STATUS_COMMITTED, tx.getStatus());
+   }
+
+   public void stop(BundleContext context) throws Exception
+   {
+   }
+
+   private void doStuff()
+   {
+      // do stuff transactional
+   }
+}
\ No newline at end of file


Property changes on: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/ut/UserTransactionActivator.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-tm.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-tm.bnd	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-tm.bnd	2009-10-27 22:21:52 UTC (rev 95636)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/example-jta-tm.jar src/test/resources/jta/example-jta-tm.bnd
+
+Bundle-SymbolicName: example-jta-tm
+Bundle-Activator: org.jboss.test.osgi.example.jta.tm.TransactionManagerActivator
+Private-Package: org.jboss.test.osgi.example.jta.tm
+Import-Package: javax.transaction, org.junit, org.osgi.framework 

Added: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-ut.bnd
===================================================================
--- projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-ut.bnd	                        (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-ut.bnd	2009-10-27 22:21:52 UTC (rev 95636)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/example-jta-ut.jar src/test/resources/jta/example-jta-ut.bnd
+
+Bundle-SymbolicName: example-jta-ut
+Bundle-Activator: org.jboss.test.osgi.example.jta.ut.UserTransactionActivator
+Private-Package: org.jboss.test.osgi.example.jta.ut
+Import-Package: javax.transaction, org.junit, org.osgi.framework 



More information about the jboss-osgi-commits mailing list