[jboss-cvs] JBossAS SVN: r95708 - in projects/jboss-osgi/trunk: testsuite/example/scripts and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 28 17:23:56 EDT 2009
Author: thomas.diesler at jboss.com
Date: 2009-10-28 17:23:55 -0400 (Wed, 28 Oct 2009)
New Revision: 95708
Added:
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionTestCase.java
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/bundle/
projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/bundle/TransactionActivator.java
projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta.bnd
Removed:
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/ut/
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
Modified:
projects/jboss-osgi/trunk/reactor/jta/src/main/java/org/jboss/osgi/jta/TransactionCapability.java
projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml
Log:
Complete the JTA example
Modified: projects/jboss-osgi/trunk/reactor/jta/src/main/java/org/jboss/osgi/jta/TransactionCapability.java
===================================================================
--- projects/jboss-osgi/trunk/reactor/jta/src/main/java/org/jboss/osgi/jta/TransactionCapability.java 2009-10-28 21:10:38 UTC (rev 95707)
+++ projects/jboss-osgi/trunk/reactor/jta/src/main/java/org/jboss/osgi/jta/TransactionCapability.java 2009-10-28 21:23:55 UTC (rev 95708)
@@ -27,6 +27,8 @@
import org.jboss.osgi.spi.capability.Capability;
+import com.arjuna.ats.arjuna.common.Environment;
+
/**
* Adds the Transaction capability to the {@link OSGiRuntime}
* under test.
@@ -44,6 +46,8 @@
{
super(TransactionManager.class.getName());
+ addSystemProperty(Environment.OBJECTSTORE_DIR, "target/ObjectStore");
+
addBundle("bundles/jboss-osgi-jta.jar");
}
}
\ No newline at end of file
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-28 21:10:38 UTC (rev 95707)
+++ projects/jboss-osgi/trunk/testsuite/example/scripts/antrun-test-jars.xml 2009-10-28 21:23:55 UTC (rev 95708)
@@ -59,8 +59,7 @@
<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" />
+ <bnd classpath="${tests.classes.dir}" output="${tests.output.dir}/test-libs/example-jta.jar" files="${tests.resources.dir}/jta/example-jta.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" />
Deleted: 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/TransactionManagerTestCase.java 2009-10-28 21:10:38 UTC (rev 95707)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionManagerTestCase.java 2009-10-28 21:23:55 UTC (rev 95708)
@@ -1,72 +0,0 @@
-/*
- * 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
Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionTestCase.java (from rev 95685, 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/TransactionTestCase.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/TransactionTestCase.java 2009-10-28 21:23:55 UTC (rev 95708)
@@ -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 TransactionTestCase
+{
+ 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.jar");
+ assertEquals(Bundle.INSTALLED, bundle.getState());
+
+ bundle.start();
+ assertEquals(Bundle.ACTIVE, bundle.getState());
+ }
+}
\ No newline at end of file
Deleted: 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 2009-10-28 21:10:38 UTC (rev 95707)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/UserTransactionTestCase.java 2009-10-28 21:23:55 UTC (rev 95708)
@@ -1,72 +0,0 @@
-/*
- * 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
Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/bundle/TransactionActivator.java (from rev 95699, 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/bundle/TransactionActivator.java (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/java/org/jboss/test/osgi/example/jta/bundle/TransactionActivator.java 2009-10-28 21:23:55 UTC (rev 95708)
@@ -0,0 +1,119 @@
+/*
+ * 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.bundle;
+
+//$Id$
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+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 TransactionActivator implements BundleActivator
+{
+ public void start(BundleContext context) throws Exception
+ {
+ ServiceReference sref = context.getServiceReference(UserTransaction.class.getName());
+ assertNotNull("UserTransaction service not null", sref);
+
+ UserTransaction userTx = (UserTransaction)context.getService(sref);
+ assertNotNull("UserTransaction not null", userTx);
+
+ Transactional txObj = new Transactional();
+
+ userTx.begin();
+ try
+ {
+ txObj.register(context);
+
+ txObj.setMessage("Hello World");
+ assertNull("Uncommited message null", txObj.getMessage());
+
+ userTx.commit();
+ }
+ catch (Exception e)
+ {
+ userTx.setRollbackOnly();
+ }
+
+ assertEquals("Hello World", txObj.getMessage());
+ }
+
+ public void stop(BundleContext context) throws Exception
+ {
+ }
+
+ class Transactional implements Synchronization
+ {
+ private String volatileMessage;
+ private String message;
+
+ public void beforeCompletion()
+ {
+ }
+
+ public void afterCompletion(int status)
+ {
+ if (status == Status.STATUS_COMMITTED)
+ message = volatileMessage;
+ }
+
+ public String getMessage()
+ {
+ return message;
+ }
+
+ public void setMessage(String message)
+ {
+ this.volatileMessage = message;
+ }
+
+ void register(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);
+
+ Transaction tx = tm.getTransaction();
+ assertNotNull("Transaction not null", tx);
+
+ tx.registerSynchronization(this);
+ }
+ }
+}
\ No newline at end of file
Deleted: 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 2009-10-28 21:10:38 UTC (rev 95707)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-tm.bnd 2009-10-28 21:23:55 UTC (rev 95708)
@@ -1,6 +0,0 @@
-# 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
Deleted: 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 2009-10-28 21:10:38 UTC (rev 95707)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta-ut.bnd 2009-10-28 21:23:55 UTC (rev 95708)
@@ -1,6 +0,0 @@
-# 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
Copied: projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta.bnd (from rev 95685, 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.bnd (rev 0)
+++ projects/jboss-osgi/trunk/testsuite/example/src/test/resources/jta/example-jta.bnd 2009-10-28 21:23:55 UTC (rev 95708)
@@ -0,0 +1,6 @@
+# bnd build -classpath target/test-classes -output target/test-libs/example-jta.jar src/test/resources/jta/example-jta.bnd
+
+Bundle-SymbolicName: example-jta
+Bundle-Activator: org.jboss.test.osgi.example.jta.bundle.TransactionActivator
+Private-Package: org.jboss.test.osgi.example.jta.bundle
+Import-Package: javax.transaction, org.junit, org.osgi.framework
More information about the jboss-cvs-commits
mailing list