You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2009/04/30 10:11:53 UTC

svn commit: r770109 - in /felix/sandbox/clement/ipojo-utils/transaction: org.apache.felix.ipojo.transaction.test/ org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/ org.apache.felix.ipojo.transaction.test/src...

Author: clement
Date: Thu Apr 30 08:11:53 2009
New Revision: 770109

URL: http://svn.apache.org/viewvc?rev=770109&view=rev
Log:
Add REQUIRESNEW test on the transaction support.

Added:
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java   (with props)
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java   (with props)
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/foo.xml   (with props)
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/mandatory.xml   (with props)
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/never.xml   (with props)
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/notsupported.xml   (with props)
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requires.xml   (with props)
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requiresnew.xml   (with props)
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/supported.xml   (with props)
Removed:
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/foo.xml
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/mandatory.xml
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/never.xml
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/notsupported.xml
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/required.xml
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequired.java
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/supported.xml
Modified:
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionHandler.java
    felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionnalMethod.java

Modified: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java?rev=770109&r1=770108&r2=770109&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java (original)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java Thu Apr 30 08:11:53 2009
@@ -27,7 +27,6 @@
 import org.junit.After;
 import org.junit.Assert;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Inject;
@@ -50,6 +49,10 @@
     
     private IPOJOHelper ipojo;
     
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
@@ -64,7 +67,8 @@
     
     @Configuration
     public static Option[] configure() {    
-        
+        ROOT.mkdirs();
+
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
@@ -82,7 +86,7 @@
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
-                .build( new BundleAsiPOJO(new File("FooImpl.jar"), new File("foo.xml"))  ).toExternalForm();
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
         
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
@@ -91,7 +95,7 @@
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
-            .build( new BundleAsiPOJO(new File("required.jar"), new File("required.xml"))  ).toExternalForm();
+            .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml"))  ).toExternalForm();
     
         
         Option[] opt =  options(
@@ -116,7 +120,6 @@
     }
     
     @Test
-    @Ignore
     public void install() throws NotSupportedException, SystemException, IllegalStateException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         Bundle[] bundles = context.getBundles();
         for (Bundle b : bundles) {
@@ -140,7 +143,7 @@
         
         // Create an install of the components
         ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
-        ComponentInstance under = ipojo.createComponentInstance("required-ok");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
         
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());

Modified: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java?rev=770109&r1=770108&r2=770109&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java (original)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java Thu Apr 30 08:11:53 2009
@@ -49,6 +49,10 @@
     
     private IPOJOHelper ipojo;
     
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
@@ -63,6 +67,8 @@
     
     @Configuration
     public static Option[] configure() {    
+        ROOT.mkdirs();
+
         
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
@@ -82,7 +88,7 @@
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
-                .build( new BundleAsiPOJO(new File("FooImpl.jar"), new File("foo.xml"))  ).toExternalForm();
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
         
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
@@ -91,7 +97,7 @@
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
-            .build( new BundleAsiPOJO(new File("required.jar"), new File("required.xml"))  ).toExternalForm();
+            .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml"))  ).toExternalForm();
     
         
         Option[] opt =  options(
@@ -121,7 +127,7 @@
     @Test
     public void testInvalidation() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
         final ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
-        ComponentInstance under = ipojo.createComponentInstance("required-ok");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
         
         Assert.assertEquals(ComponentInstance.VALID, prov.getState());
         Assert.assertEquals(ComponentInstance.VALID, under.getState());

Modified: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java?rev=770109&r1=770108&r2=770109&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java (original)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java Thu Apr 30 08:11:53 2009
@@ -49,6 +49,10 @@
     
     private IPOJOHelper ipojo;
     
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
     @Before
     public void init() {
         osgi = new OSGiHelper(context);
@@ -63,7 +67,8 @@
     
     @Configuration
     public static Option[] configure() {    
-        
+        ROOT.mkdirs();
+
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
@@ -82,7 +87,7 @@
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
-                .build( new BundleAsiPOJO(new File("FooImpl.jar"), new File("foo.xml"))  ).toExternalForm();
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
         
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
@@ -91,7 +96,7 @@
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Mandatory Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
-            .build( new BundleAsiPOJO(new File("mandatory.jar"), new File("mandatory.xml"))  ).toExternalForm();
+            .build( new BundleAsiPOJO(new File(ROOT, "mandatory.jar"), new File(TEST, "mandatory.xml"))  ).toExternalForm();
     
         
         Option[] opt =  options(

Modified: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java?rev=770109&r1=770108&r2=770109&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java (original)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java Thu Apr 30 08:11:53 2009
@@ -48,6 +48,9 @@
     private OSGiHelper osgi;
     
     private IPOJOHelper ipojo;
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
     
     @Before
     public void init() {
@@ -63,7 +66,8 @@
     
     @Configuration
     public static Option[] configure() {    
-        
+        ROOT.mkdirs();
+
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
@@ -82,7 +86,7 @@
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
-                .build( new BundleAsiPOJO(new File("FooImpl.jar"), new File("foo.xml"))  ).toExternalForm();
+                .build( new BundleAsiPOJO(new File(ROOT,"FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
         
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
@@ -91,7 +95,7 @@
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Mandatory Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
-            .build( new BundleAsiPOJO(new File("never.jar"), new File("never.xml"))  ).toExternalForm();
+            .build( new BundleAsiPOJO(new File(ROOT, "never.jar"), new File(TEST, "never.xml"))  ).toExternalForm();
     
         
         Option[] opt =  options(

Modified: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java?rev=770109&r1=770108&r2=770109&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java (original)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java Thu Apr 30 08:11:53 2009
@@ -48,6 +48,9 @@
     private OSGiHelper osgi;
     
     private IPOJOHelper ipojo;
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
     
     @Before
     public void init() {
@@ -63,7 +66,8 @@
     
     @Configuration
     public static Option[] configure() {    
-        
+        ROOT.mkdirs();
+
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
@@ -82,7 +86,7 @@
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
-                .build( new BundleAsiPOJO(new File("FooImpl.jar"), new File("foo.xml"))  ).toExternalForm();
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
         
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
@@ -91,7 +95,7 @@
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
-            .build( new BundleAsiPOJO(new File("notsupported.jar"), new File("notsupported.xml"))  ).toExternalForm();
+            .build( new BundleAsiPOJO(new File(ROOT, "notsupported.jar"), new File(TEST, "notsupported.xml"))  ).toExternalForm();
     
         
         Option[] opt =  options(

Added: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java?rev=770109&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java (added)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java Thu Apr 30 08:11:53 2009
@@ -0,0 +1,441 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestRequires {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                .set(Constants.IMPORT_PACKAGE, "javax.transaction")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    
+    @Test
+    public void testOkOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingGood();
+    }
+    
+    @Test
+    public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        t.commit();
+    }
+    
+    @Test(expected=NullPointerException.class)
+    public void testExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad();
+    }
+    
+    @Test(expected=RollbackException.class)
+    public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        t.commit(); // Throw a rollback exception.
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionRB() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        t.rollback();
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+    }
+    
+    @Test
+    public void testOkOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingGood();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testOkInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastCommitted());
+    }
+    
+    @Test(expected=NullPointerException.class)
+    public void testExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad();
+        
+        Assert.assertNotNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(1, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("NullPointerException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof NullPointerException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_MARKED_ROLLBACK, t.getStatus());
+        
+        try {
+            t.commit(); // Throw a rollback exception.
+        } catch (RollbackException e) {
+            // Expected
+        } catch (Throwable e) {
+            Assert.fail(e.getMessage()); // Unexpected
+        }
+        
+        Assert.assertNotNull(cs.getLastRolledBack());
+        Assert.assertNull(cs.getLastCommitted());
+        Assert.assertEquals(0, cs.getNumberOfCommit());
+        Assert.assertEquals(1, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastRolledBack());
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransactionWithCallback() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+
+        cs.doSomethingBad2();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransactionWithCallback() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requires-cb");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertSame(t2, t);
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+        
+        Assert.assertNull(cs.getLastRolledBack());
+        Assert.assertNotNull(cs.getLastCommitted());
+        Assert.assertEquals(1, cs.getNumberOfCommit());
+        Assert.assertEquals(0, cs.getNumberOfRollback());
+        
+        Assert.assertSame(t, cs.getLastCommitted());
+    }
+    
+
+    
+}

Propchange: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java?rev=770109&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java (added)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java Thu Apr 30 08:11:53 2009
@@ -0,0 +1,254 @@
+package org.apache.felix.ipojo.transaction.test;
+
+import static org.ops4j.pax.exam.CoreOptions.bundle;
+import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
+import static org.ops4j.pax.exam.CoreOptions.provision;
+import static org.ops4j.pax.exam.MavenUtils.asInProject;
+import static org.ops4j.pax.tinybundles.core.TinyBundles.with;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.pax.exam.target.BundleAsiPOJO;
+import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
+import org.apache.felix.ipojo.transaction.test.component.FooImpl;
+import org.apache.felix.ipojo.transaction.test.service.CheckService;
+import org.apache.felix.ipojo.transaction.test.service.Foo;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Inject;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.ops4j.pax.tinybundles.core.TinyBundles;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceReference;
+
+@RunWith( JUnit4TestRunner.class )
+public class TestRequiresNew {
+    
+    @Inject
+    private BundleContext context;
+    
+    private OSGiHelper osgi;
+    
+    private IPOJOHelper ipojo;
+    
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
+    
+    @Before
+    public void init() {
+        osgi = new OSGiHelper(context);
+        ipojo = new IPOJOHelper(context);
+    }
+    
+    @After
+    public void stop() {
+        ipojo.dispose();
+        osgi.dispose();
+    }
+    
+    @Configuration
+    public static Option[] configure() {    
+        ROOT.mkdirs();
+
+        URL service = TinyBundles.newBundle()
+            .addClass(CheckService.class)
+            .addClass(Foo.class)
+           .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+                .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                .set(Constants.IMPORT_PACKAGE, "javax.transaction")
+                )
+            .build( TinyBundles.asURL());
+            
+        String fooimpl = TinyBundles.newBundle()
+            .addClass(FooImpl.class)
+            .prepare( 
+                    with()
+                    .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+                    .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+                )
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
+        
+        String test = TinyBundles.newBundle()
+        .addClass(FooDelegator.class)
+        .prepare( 
+                with()
+                .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
+                .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+            )
+            .build( new BundleAsiPOJO(new File(ROOT, "requiresnew.jar"), new File(TEST, "requiresnew.xml"))  ).toExternalForm();
+    
+        
+        Option[] opt =  options(
+ 
+                provision(
+                        mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.transaction").version(asInProject()),
+                        mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
+                        mavenBundle()
+                        .groupId( "org.ops4j.pax.tinybundles" )
+                        .artifactId( "pax-tinybundles-core" )
+                        .version( "0.5.0-SNAPSHOT" ),
+                        bundle(service.toExternalForm()),
+                        bundle(fooimpl),
+                        bundle(test)
+                    )
+                )
+
+                ;
+        return opt;
+    }
+    
+    
+    @Test
+    public void testOkOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingGood(); // Ok
+    }
+    
+    @Test
+    public void testOkInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        cs.doSomethingGood();
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertNotSame(t2, t); // Two different transactions
+        // Check that t2 is commited => no transaction
+        Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
+        t.commit();
+    }
+    
+    @Test
+    public void testExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        try {
+            ((CheckService) osgi.getServiceObject(ref)).doSomethingBad(); // throws an exception on rollback
+            Assert.fail("Exception expected on rollback");
+        } catch (IllegalStateException e) {
+            // Ok.
+        } catch (Exception  e) {
+            Assert.fail("IllegalStateException expected on rollback");
+        }
+    }
+    
+    @Test
+    public void testExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad();
+            Assert.fail("IllegalStateException expected");  // throws an exception on rollback
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof IllegalStateException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertNotSame(t2, t);
+        // Check that t2 is rolledback
+        Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+    }
+    
+    @Test(expected=UnsupportedOperationException.class)
+    public void testExpectedExceptionOutsideTransaction() {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+
+        ((CheckService) osgi.getServiceObject(ref)).doSomethingBad2();
+    }
+    
+    @Test
+    public void testExpectedExceptionInsideTransaction() throws NotSupportedException, SystemException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+        ComponentInstance prov = ipojo.createComponentInstance("org.apache.felix.ipojo.transaction.test.component.FooImpl");
+        ComponentInstance under = ipojo.createComponentInstance("requiresnew-ok");
+        
+        Assert.assertEquals(ComponentInstance.VALID, prov.getState());
+        Assert.assertEquals(ComponentInstance.VALID, under.getState());
+        
+        ServiceReference ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+        Assert.assertNotNull(ref);
+        
+        CheckService cs = (CheckService) osgi.getServiceObject(ref);
+        TransactionManager tm = (TransactionManager) osgi.getServiceObject(TransactionManager.class.getName(), null);
+        tm.begin();
+        Transaction t = tm.getTransaction();
+        try {
+            cs.doSomethingBad2();
+            Assert.fail("UnsupportedOperationException expected");
+        } catch(Exception e) {
+            Assert.assertTrue(e instanceof UnsupportedOperationException);
+        }
+        Transaction t2 = cs.getCurrentTransaction();
+        Assert.assertNotSame(t2, t);
+        Assert.assertEquals(Status.STATUS_NO_TRANSACTION, t2.getStatus());
+        Assert.assertEquals(Status.STATUS_ACTIVE, t.getStatus());
+        
+        t.commit();
+    }
+}

Propchange: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java?rev=770109&r1=770108&r2=770109&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java (original)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java Thu Apr 30 08:11:53 2009
@@ -48,6 +48,9 @@
     private OSGiHelper osgi;
     
     private IPOJOHelper ipojo;
+    public static final File ROOT = new File("target/tmp");
+    public static final File TEST = new File("src/test/resources");
+
     
     @Before
     public void init() {
@@ -63,7 +66,8 @@
     
     @Configuration
     public static Option[] configure() {    
-        
+        ROOT.mkdirs();
+
         URL service = TinyBundles.newBundle()
             .addClass(CheckService.class)
             .addClass(Foo.class)
@@ -82,7 +86,7 @@
                     .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
                     .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
                 )
-                .build( new BundleAsiPOJO(new File("FooImpl.jar"), new File("foo.xml"))  ).toExternalForm();
+                .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml"))  ).toExternalForm();
         
         String test = TinyBundles.newBundle()
         .addClass(FooDelegator.class)
@@ -91,7 +95,7 @@
                 .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
                 .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
             )
-            .build( new BundleAsiPOJO(new File("supported.jar"), new File("supported.xml"))  ).toExternalForm();
+            .build( new BundleAsiPOJO(new File(ROOT, "supported.jar"), new File(TEST, "supported.xml"))  ).toExternalForm();
     
         
         Option[] opt =  options(

Modified: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java?rev=770109&r1=770108&r2=770109&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java (original)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/java/org/apache/felix/ipojo/transaction/test/component/FooDelegator.java Thu Apr 30 08:11:53 2009
@@ -19,6 +19,9 @@
     
     Transaction lastRolledback;
     
+    Transaction current;
+
+    
     public void onCommit(String method) {
         commit ++;
     }
@@ -28,25 +31,28 @@
     }
 
     public void doSomethingBad() throws NullPointerException {
+        current = transaction;
         foo.doSomethingBad();
     }
 
     public void doSomethingBad2() throws UnsupportedOperationException {
+       current = transaction;
        foo.doSomethingBad2();
 
     }
 
     public void doSomethingGood() {
+        current = transaction;
         foo.doSomethingGood();
-        System.out.println("==========> " + transaction);
     }
 
     public void doSomethingLong() {
+       current = transaction;
        foo.doSomethingLong();
     }
 
     public Transaction getCurrentTransaction() {
-       return transaction;
+       return current;
     }
 
     public int getNumberOfCommit() {

Added: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/foo.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/foo.xml?rev=770109&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/foo.xml (added)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/foo.xml Thu Apr 30 08:11:53 2009
@@ -0,0 +1,5 @@
+<ipojo>
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooImpl">
+		<provides/>
+	</component>
+</ipojo>
\ No newline at end of file

Propchange: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/foo.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/mandatory.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/mandatory.xml?rev=770109&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/mandatory.xml (added)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/mandatory.xml Thu Apr 30 08:11:53 2009
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="mandatory-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="mandatory"/>
+			<transactionnal method="getCurrentTransaction" propagation="mandatory"/>
+			<transactionnal method="doSomethingBad" propagation="mandatory"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="mandatory"/>
+			<transactionnal method="doSomethingLong" propagation="mandatory"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="mandatory-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="mandatory"/>
+			<transactionnal method="getCurrentTransaction" propagation="mandatory"/>
+			<transactionnal method="doSomethingBad" propagation="mandatory"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="mandatory"/>
+			<transactionnal method="doSomethingLong" propagation="mandatory"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file

Propchange: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/mandatory.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/never.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/never.xml?rev=770109&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/never.xml (added)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/never.xml Thu Apr 30 08:11:53 2009
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="never-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="never"/>
+			<transactionnal method="getCurrentTransaction" propagation="never"/>
+			<transactionnal method="doSomethingBad" propagation="never"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="never"/>
+			<transactionnal method="doSomethingLong" propagation="never"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="never-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="never"/>
+			<transactionnal method="getCurrentTransaction" propagation="never"/>
+			<transactionnal method="doSomethingBad" propagation="never"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="never"/>
+			<transactionnal method="doSomethingLong" propagation="never"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file

Propchange: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/never.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/notsupported.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/notsupported.xml?rev=770109&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/notsupported.xml (added)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/notsupported.xml Thu Apr 30 08:11:53 2009
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="notsupported-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="notsupported"/>
+			<transactionnal method="getCurrentTransaction" propagation="notsupported"/>
+			<transactionnal method="doSomethingBad" propagation="notsupported"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="notsupported"/>
+			<transactionnal method="doSomethingLong" propagation="notsupported"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="notsupported-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="notsupported"/>
+			<transactionnal method="getCurrentTransaction" propagation="notsupported"/>
+			<transactionnal method="doSomethingBad" propagation="notsupported"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="notsupported"/>
+			<transactionnal method="doSomethingLong" propagation="notsupported"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file

Propchange: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/notsupported.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requires.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requires.xml?rev=770109&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requires.xml (added)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requires.xml Thu Apr 30 08:11:53 2009
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requires-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood"/>
+			<transactionnal method="getCurrentTransaction"/>
+			<transactionnal method="doSomethingBad"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException"/>
+			<transactionnal method="doSomethingLong"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requires-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood"/>
+			<transactionnal method="getCurrentTransaction"/>
+			<transactionnal method="doSomethingBad"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException"/>
+			<transactionnal method="doSomethingLong"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file

Propchange: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requires.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requiresnew.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requiresnew.xml?rev=770109&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requiresnew.xml (added)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requiresnew.xml Thu Apr 30 08:11:53 2009
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requiresnew-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="requiresnew"/>
+			<transactionnal method="getCurrentTransaction" propagation="requiresnew"/>
+			<transactionnal method="doSomethingBad" propagation="requiresnew" exceptiononrollback="true"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="requiresnew"/>
+			<transactionnal method="doSomethingLong" propagation="requiresnew"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="requiresnew-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="requiresnew"/>
+			<transactionnal method="getCurrentTransaction" propagation="requiresnew"/>
+			<transactionnal method="doSomethingBad" propagation="requiresnew"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="requiresnew"/>
+			<transactionnal method="doSomethingLong" propagation="requiresnew"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file

Propchange: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/requiresnew.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/supported.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/supported.xml?rev=770109&view=auto
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/supported.xml (added)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/supported.xml Thu Apr 30 08:11:53 2009
@@ -0,0 +1,25 @@
+<ipojo xmlns:tr="org.apache.felix.ipojo.transaction">
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="supported-ok">
+		<provides/>
+		<requires field="foo"/>
+		<tr:transaction field="transaction">
+			<transactionnal method="doSomethingGood" propagation="supported"/>
+			<transactionnal method="getCurrentTransaction" propagation="supported"/>
+			<transactionnal method="doSomethingBad" propagation="supported"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="supported"/>
+			<transactionnal method="doSomethingLong" propagation="supported"/>
+		</tr:transaction>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.transaction.test.component.FooDelegator" name="supported-cb">
+		<provides/>
+		<requires field="foo" />
+		<tr:transaction field="transaction" onCommit="onCommit" onRollback="onRollback">
+			<transactionnal method="doSomethingGood" propagation="supported"/>
+			<transactionnal method="getCurrentTransaction" propagation="supported"/>
+			<transactionnal method="doSomethingBad" propagation="supported"/>
+			<transactionnal method="doSomethingBad2" norollbackfor="java.lang.UnsupportedOperationException" propagation="supported"/>
+			<transactionnal method="doSomethingLong" propagation="supported"/>
+		</tr:transaction>
+	</component>
+</ipojo>
\ No newline at end of file

Propchange: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction.test/src/test/resources/supported.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionHandler.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionHandler.java?rev=770109&r1=770108&r2=770109&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionHandler.java (original)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionHandler.java Thu Apr 30 08:11:53 2009
@@ -169,8 +169,7 @@
     }
 
     public void stop() {
-        // TODO Auto-generated method stub
-
+        // Nothing to do.
     }
     
     public synchronized void bind(TransactionManager tm) {

Modified: felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionnalMethod.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionnalMethod.java?rev=770109&r1=770108&r2=770109&view=diff
==============================================================================
--- felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionnalMethod.java (original)
+++ felix/sandbox/clement/ipojo-utils/transaction/org.apache.felix.ipojo.transaction/src/main/java/org/apache/felix/ipojo/transaction/TransactionnalMethod.java Thu Apr 30 08:11:53 2009
@@ -77,7 +77,6 @@
             if (this.manager != null) {
                 manager = this.manager; // Stack confinement
             } else {
-                System.out.println("No transaction manager...");
                 return; // Nothing can be done...
             }
         }
@@ -130,6 +129,7 @@
                         manager.setTransactionTimeout(timeout);
                     }
                     manager.begin();
+                    System.out.println("== Associate " + Thread.currentThread() + " to " + manager.getTransaction() + " ==");
                     m_owned.put(Thread.currentThread(), manager.getTransaction());
                 } else {
                     if (suspended == null) {
@@ -185,18 +185,24 @@
             case REQUIRES_NEW:
                 // We're necessary the owner.
                 transaction = m_owned.get(Thread.currentThread());
+                System.out.println("== Owned " + Thread.currentThread() + " to " + transaction + "==");
+                if (transaction == null) {
+                    throw new RuntimeException("Cannot apply the REQUIRES NEW propagation, we're not the transaction owner!"); 
+                }
                 try {
                     transaction.commit(); // Commit the transaction
                     m_owned.remove(Thread.currentThread());
                     handler.transactionCommitted(transaction); // Manage potential notification.
                     if (suspended != null) {
+                        manager.suspend(); // suspend the completed transaction.
                         manager.resume(suspended);
                         suspended = null;
                     }
-                 } catch ( RollbackException e) {
+                 } catch ( RollbackException e) { // The transaction was rolledback rather than committed
                     m_owned.remove(Thread.currentThread());
                     if (suspended != null) {
-                        manager.resume(suspended);
+                        manager.suspend(); // suspend the completed transaction.
+                        manager.resume(suspended); // The resume transaction is not rolledback, they are independent.
                         suspended = null;
                     }
                     // The transaction was rolledback
@@ -205,7 +211,7 @@
                     }
                     handler.transactionRolledback(transaction); // Manage potential notification.
                 }
-                
+                break;
             default:
                 throw new UnsupportedOperationException("Unknown or unsupported propagation policy for " + method + " :" + propagation);