onami-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sclas...@apache.org
Subject svn commit: r1600690 - in /onami/trunk/persist/src: main/java/org/apache/onami/persist/ test/java/org/apache/onami/persist/ test/java/org/apache/onami/persist/test/ test/java/org/apache/onami/persist/test/transaction/testframework/ test/java/org/apache...
Date Thu, 05 Jun 2014 16:02:08 GMT
Author: sclassen
Date: Thu Jun  5 16:02:07 2014
New Revision: 1600690

URL: http://svn.apache.org/r1600690
Log:
onami-persist: added multiple PU test and fixed bug regarding requestInjection().

Added:
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/MultiplePuTest.java   (with props)
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/TestEntity.java
      - copied, changed from r1599234, onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionTestEntity.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/UnderstandRequestInjectionTest.java   (with props)
Removed:
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionTestEntity.java
Modified:
    onami/trunk/persist/src/main/java/org/apache/onami/persist/AllPersistenceUnits.java
    onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceModule.java
    onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceUnitModule.java
    onami/trunk/persist/src/main/java/org/apache/onami/persist/TxnInterceptor.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/AllPersistenceUnitsTest.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/TxnInterceptorTest.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalTask.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalWorker.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java
    onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java
    onami/trunk/persist/src/test/resources/META-INF/persistence.xml

Modified: onami/trunk/persist/src/main/java/org/apache/onami/persist/AllPersistenceUnits.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/main/java/org/apache/onami/persist/AllPersistenceUnits.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/main/java/org/apache/onami/persist/AllPersistenceUnits.java (original)
+++ onami/trunk/persist/src/main/java/org/apache/onami/persist/AllPersistenceUnits.java Thu Jun  5 16:02:07 2014
@@ -20,9 +20,13 @@ package org.apache.onami.persist;
  */
 
 import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Key;
 import com.google.inject.Singleton;
 
+import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Set;
 
 import static org.apache.onami.persist.Preconditions.checkNotNull;
@@ -38,26 +42,46 @@ class AllPersistenceUnits
     /**
      * Collection of all known persistence services.
      */
-    private final Set<PersistenceService> persistenceServices = new HashSet<PersistenceService>();
+    private final List<PersistenceService> persistenceServices = new ArrayList<PersistenceService>();
 
     /**
      * Collection of all known units of work.
      */
-    private final Set<UnitOfWork> unitsOfWork = new HashSet<UnitOfWork>();
+    private final List<UnitOfWork> unitsOfWork = new ArrayList<UnitOfWork>();
+
+    /**
+     * Collection of the keys of all known persistence services.
+     */
+    private final Set<Key<PersistenceService>> persistenceServiceKeys = new HashSet<Key<PersistenceService>>();
+
+    /**
+     * Collection of the keys of of all known units of work.
+     */
+    private final Set<Key<UnitOfWork>> unitOfWorkKeys = new HashSet<Key<UnitOfWork>>();
 
     /**
      * Adds a persistence service and a unit of work to this collection.
      *
-     * @param ps  the persistence service to add. Must not be {@code null}.
-     * @param uow the unit of work to add. Must not be {@code null}.
+     * @param psKey  the persistence service to add. Must not be {@code null}.
+     * @param uowKey the unit of work to add. Must not be {@code null}.
      */
+    void add( Key<PersistenceService> psKey, Key<UnitOfWork> uowKey )
+    {
+        persistenceServiceKeys.add( checkNotNull( psKey, "psKey is mandatory!" ) );
+        unitOfWorkKeys.add( checkNotNull( uowKey, "ouwKey is mandatory!" ) );
+    }
+
     @Inject
-    void add( PersistenceService ps, UnitOfWork uow )
+    private void init( Injector injector )
     {
-        checkNotNull( ps );
-        checkNotNull( uow );
-        persistenceServices.add( ps );
-        unitsOfWork.add( uow );
+        for ( Key<PersistenceService> persistenceServiceKey : persistenceServiceKeys )
+        {
+            persistenceServices.add( injector.getInstance( persistenceServiceKey ) );
+        }
+        for ( Key<UnitOfWork> unitOfWorkKey : unitOfWorkKeys )
+        {
+            unitsOfWork.add( injector.getInstance( unitOfWorkKey ) );
+        }
     }
 
     /**

Modified: onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceModule.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceModule.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceModule.java (original)
+++ onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceModule.java Thu Jun  5 16:02:07 2014
@@ -75,6 +75,7 @@ public abstract class PersistenceModule
         bind( PersistenceFilter.class ).to( PersistenceFilterImpl.class );
 
         final AllPersistenceUnits allPersistenceUnits = new AllPersistenceUnits();
+        requestInjection( allPersistenceUnits );
         bind( AllPersistenceServices.class ).toInstance( allPersistenceUnits );
         bind( AllUnitsOfWork.class ).toInstance( allPersistenceUnits );
 

Modified: onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceUnitModule.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceUnitModule.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceUnitModule.java (original)
+++ onami/trunk/persist/src/main/java/org/apache/onami/persist/PersistenceUnitModule.java Thu Jun  5 16:02:07 2014
@@ -90,11 +90,7 @@ class PersistenceUnitModule
             requestInjection( transactionInterceptor );
         }
 
-        // request injection into allPersistenceUnits - this adds the current persistence unit to the allPersistenceUnits.
-        if ( allPersistenceUnits != null )
-        {
-            requestInjection( allPersistenceUnits );
-        }
+        allPersistenceUnits.add( getPersistenceKey(), getUnitOfWorkKey() );
     }
 
     /**
@@ -133,6 +129,31 @@ class PersistenceUnitModule
         expose( type ).annotatedWith( config.getAnnotation() );
     }
 
+
+    private Key<PersistenceService> getPersistenceKey()
+    {
+        if ( config.isAnnotated() )
+        {
+            return Key.get( PersistenceService.class, config.getAnnotation() );
+        }
+        else
+        {
+            return Key.get( PersistenceService.class );
+        }
+    }
+
+    private Key<UnitOfWork> getUnitOfWorkKey()
+    {
+        if ( config.isAnnotated() )
+        {
+            return Key.get( UnitOfWork.class, config.getAnnotation() );
+        }
+        else
+        {
+            return Key.get( UnitOfWork.class );
+        }
+    }
+
     private void bindPersistenceServiceAndEntityManagerFactoryProviderAndProperties()
     {
         if ( config.isApplicationManagedPersistenceUnit() )

Modified: onami/trunk/persist/src/main/java/org/apache/onami/persist/TxnInterceptor.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/main/java/org/apache/onami/persist/TxnInterceptor.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/main/java/org/apache/onami/persist/TxnInterceptor.java (original)
+++ onami/trunk/persist/src/main/java/org/apache/onami/persist/TxnInterceptor.java Thu Jun  5 16:02:07 2014
@@ -33,23 +33,27 @@ class TxnInterceptor
     /**
      * Unit of work.
      */
-    @Inject
-    @VisibleForTesting
-    UnitOfWork unitOfWork;
+    private UnitOfWork unitOfWork;
 
     /**
      * Factory for {@link TransactionFacade}.
      */
-    @Inject
-    @VisibleForTesting
-    TransactionFacadeFactory tfProvider;
+    private TransactionFacadeFactory tfProvider;
 
     /**
      * Helper for working with the concrete transactional annotations on methods and classes.
      */
+    private TransactionalAnnotationHelper txnAnnotationHelper;
+
     @Inject
     @VisibleForTesting
-    TransactionalAnnotationHelper txnAnnotationHelper;
+    void init( UnitOfWork unitOfWork, TransactionFacadeFactory tfProvider,
+               TransactionalAnnotationHelper txnAnnotationHelper )
+    {
+        this.unitOfWork = unitOfWork;
+        this.tfProvider = tfProvider;
+        this.txnAnnotationHelper = txnAnnotationHelper;
+    }
 
     /**
      * {@inheritDoc}

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/AllPersistenceUnitsTest.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/AllPersistenceUnitsTest.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/AllPersistenceUnitsTest.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/AllPersistenceUnitsTest.java Thu Jun  5 16:02:07 2014
@@ -19,9 +19,13 @@ package org.apache.onami.persist;
  * under the License.
  */
 
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Key;
 import org.junit.Before;
 import org.junit.Test;
 
+import static com.google.inject.name.Names.named;
 import static org.hamcrest.CoreMatchers.is;
 import static org.junit.Assert.assertThat;
 import static org.junit.Assert.fail;
@@ -33,6 +37,14 @@ import static org.mockito.Mockito.*;
 public class AllPersistenceUnitsTest
 {
 
+    private static final Key<PersistenceService> PS_KEY_1 = Key.get( PersistenceService.class, named( "1" ) );
+
+    private static final Key<PersistenceService> PS_KEY_2 = Key.get( PersistenceService.class, named( "2" ) );
+
+    private static final Key<UnitOfWork> UOW_KEY_1 = Key.get( UnitOfWork.class, named( "1" ) );
+
+    private static final Key<UnitOfWork> UOW_KEY_2 = Key.get( UnitOfWork.class, named( "2" ) );
+
     private AllPersistenceUnits sut;
 
     private PersistenceService ps1;
@@ -47,16 +59,32 @@ public class AllPersistenceUnitsTest
     public void setUp()
         throws Exception
     {
-        sut = new AllPersistenceUnits();
-
+        // create mocks
         ps1 = mock( PersistenceService.class );
         ps2 = mock( PersistenceService.class );
 
         uow1 = mock( UnitOfWork.class );
         uow2 = mock( UnitOfWork.class );
 
-        sut.add( ps1, uow1 );
-        sut.add( ps2, uow2 );
+        // create subject under test
+        sut = new AllPersistenceUnits();
+
+        sut.add( PS_KEY_1, UOW_KEY_1 );
+        sut.add( PS_KEY_2, UOW_KEY_2 );
+
+        // use guice to trigger the init method of AllPersistenceUnits
+        Guice.createInjector( new AbstractModule()
+        {
+            @Override
+            protected void configure()
+            {
+                bind( PS_KEY_1 ).toInstance( ps1 );
+                bind( PS_KEY_2 ).toInstance( ps2 );
+                bind( UOW_KEY_1 ).toInstance( uow1 );
+                bind( UOW_KEY_2 ).toInstance( uow2 );
+                requestInjection( sut );
+            }
+        } );
     }
 
     @Test

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/TxnInterceptorTest.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/TxnInterceptorTest.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/TxnInterceptorTest.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/TxnInterceptorTest.java Thu Jun  5 16:02:07 2014
@@ -34,7 +34,7 @@ import static org.mockito.Mockito.*;
 /**
  * Test for {@link TxnInterceptor}
  */
-@RunWith( HierarchicalContextRunner.class )
+@RunWith(HierarchicalContextRunner.class)
 public class TxnInterceptorTest
 {
 
@@ -59,9 +59,7 @@ public class TxnInterceptorTest
         txnAnnotationHelper = mock( TransactionalAnnotationHelper.class );
 
         sut = new TxnInterceptor();
-        sut.unitOfWork = unitOfWork;
-        sut.tfProvider = tfProvider;
-        sut.txnAnnotationHelper = txnAnnotationHelper;
+        sut.init( unitOfWork, tfProvider, txnAnnotationHelper );
 
         invocation = mock( MethodInvocation.class );
     }

Added: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/MultiplePuTest.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/MultiplePuTest.java?rev=1600690&view=auto
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/MultiplePuTest.java (added)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/MultiplePuTest.java Thu Jun  5 16:02:07 2014
@@ -0,0 +1,126 @@
+package org.apache.onami.persist.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.google.inject.BindingAnnotation;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Key;
+import org.apache.onami.persist.EntityManagerProvider;
+import org.apache.onami.persist.PersistenceModule;
+import org.apache.onami.persist.PersistenceService;
+import org.apache.onami.persist.UnitOfWork;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class MultiplePuTest
+{
+
+    private Injector injector;
+
+    private EntityManagerProvider firstEmp;
+
+    private EntityManagerProvider secondEmp;
+
+    @Before
+    public void setUp()
+    {
+        final PersistenceModule pm = createPersistenceModuleForTest();
+        injector = Guice.createInjector( pm );
+
+        //startup persistence
+        injector.getInstance( Key.get( PersistenceService.class, FirstPU.class ) ).start();
+        injector.getInstance( Key.get( PersistenceService.class, SecondPU.class ) ).start();
+
+        injector.getInstance( Key.get( UnitOfWork.class, FirstPU.class ) ).begin();
+        injector.getInstance( Key.get( UnitOfWork.class, SecondPU.class ) ).begin();
+
+        firstEmp = injector.getInstance( Key.get( EntityManagerProvider.class, FirstPU.class ) );
+        secondEmp = injector.getInstance( Key.get( EntityManagerProvider.class, SecondPU.class ) );
+    }
+
+    @After
+    public void tearDown()
+        throws Exception
+    {
+        injector.getInstance( Key.get( UnitOfWork.class, FirstPU.class ) ).end();
+        injector.getInstance( Key.get( UnitOfWork.class, SecondPU.class ) ).end();
+
+        injector.getInstance( Key.get( PersistenceService.class, FirstPU.class ) ).stop();
+        injector.getInstance( Key.get( PersistenceService.class, SecondPU.class ) ).stop();
+    }
+
+    private PersistenceModule createPersistenceModuleForTest()
+    {
+        return new PersistenceModule()
+        {
+
+            @Override
+            protected void configurePersistence()
+            {
+                bindApplicationManagedPersistenceUnit( "firstUnit" ).annotatedWith( FirstPU.class );
+                bindApplicationManagedPersistenceUnit( "secondUnit" ).annotatedWith( SecondPU.class );
+            }
+        };
+    }
+
+
+    @Test
+    public void storeUnitsInTwoPersistenceUnits()
+        throws Exception
+    {
+        // given
+        final TestEntity firstEntity = new TestEntity();
+        final TestEntity secondEntity = new TestEntity();
+
+        // when
+        firstEmp.get().persist( firstEntity );
+        secondEmp.get().persist( secondEntity );
+
+        // then
+        assertNotNull( firstEmp.get().find( TestEntity.class, firstEntity.getId() ) );
+        assertNotNull( secondEmp.get().find( TestEntity.class, secondEntity.getId() ) );
+        assertNull( firstEmp.get().find( TestEntity.class, secondEntity.getId() ) );
+        assertNull( secondEmp.get().find( TestEntity.class, firstEntity.getId() ) );
+    }
+
+    @Retention( RetentionPolicy.RUNTIME )
+    @Target( { FIELD, PARAMETER, METHOD } )
+    @BindingAnnotation
+    public static @interface FirstPU
+    {
+    }
+
+    @Retention( RetentionPolicy.RUNTIME )
+    @Target( { FIELD, PARAMETER, METHOD } )
+    @BindingAnnotation
+    public static @interface SecondPU
+    {
+    }
+}

Propchange: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/MultiplePuTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/MultiplePuTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/MultiplePuTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/TestEntity.java (from r1599234, onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionTestEntity.java)
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/TestEntity.java?p2=onami/trunk/persist/src/test/java/org/apache/onami/persist/test/TestEntity.java&p1=onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionTestEntity.java&r1=1599234&r2=1600690&rev=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionTestEntity.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/TestEntity.java Thu Jun  5 16:02:07 2014
@@ -1,4 +1,4 @@
-package org.apache.onami.persist.test.transaction.testframework;
+package org.apache.onami.persist.test;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -29,7 +29,7 @@ import java.util.UUID;
  * The ID will be unique in every run of a test.
  */
 @Entity
-public final class TransactionTestEntity
+public final class TestEntity
     implements Serializable
 {
 
@@ -43,7 +43,7 @@ public final class TransactionTestEntity
         return id;
     }
 
-    @SuppressWarnings("unused")
+    @SuppressWarnings( "unused" )
     // used by the persistence framework
     private void setId( UUID id )
     {

Added: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/UnderstandRequestInjectionTest.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/UnderstandRequestInjectionTest.java?rev=1600690&view=auto
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/UnderstandRequestInjectionTest.java (added)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/UnderstandRequestInjectionTest.java Thu Jun  5 16:02:07 2014
@@ -0,0 +1,122 @@
+package org.apache.onami.persist.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.PrivateModule;
+import org.junit.Test;
+
+import java.util.Set;
+
+import static com.google.common.collect.Sets.newHashSet;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test for understanding how guice handles the requestInjection() method.
+ */
+public class UnderstandRequestInjectionTest
+{
+    @Test
+    public void requestInjectionInOnePrivateModule()
+        throws Exception
+    {
+        final ObjectWithSetterInjection obj = new ObjectWithSetterInjection();
+        Guice.createInjector( new PrivateModule()
+        {
+            @Override
+            protected void configure()
+            {
+                bind( Foo.class ).to( Foo1.class );
+                requestInjection( obj );
+            }
+        } );
+
+        obj.assertAddedTypes( 1 );
+    }
+
+    @Test
+    public void requestInjectionInTwoPrivateModule()
+        throws Exception
+    {
+        final ObjectWithSetterInjection obj = new ObjectWithSetterInjection();
+        Guice.createInjector( new PrivateModule()
+                              {
+                                  @Override
+                                  protected void configure()
+                                  {
+                                      bind( Foo.class ).to( Foo1.class );
+                                      requestInjection( obj );
+                                  }
+                              }, //                                                                 //
+                              new PrivateModule()
+                              {
+                                  @Override
+                                  protected void configure()
+                                  {
+                                      bind( Foo.class ).to( Foo2.class );
+                                  }
+                              }
+        );
+
+        obj.assertAddedTypes( 1 );
+    }
+
+    private static class ObjectWithSetterInjection
+    {
+        private Set<Integer> actuals = newHashSet();
+
+        @Inject
+        public void addFoo( Foo foo )
+        {
+            actuals.add( foo.type() );
+        }
+
+        void assertAddedTypes( Integer... types )
+        {
+            Set<Integer> expected = newHashSet( types );
+            assertThat( actuals, is( expected ) );
+        }
+    }
+
+    private interface Foo
+    {
+        int type();
+    }
+
+    private static class Foo1
+        implements Foo
+    {
+        public int type()
+        {
+            return 1;
+        }
+    }
+
+    private static class Foo2
+        implements Foo
+    {
+        public int type()
+        {
+            return 2;
+        }
+    }
+}

Propchange: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/UnderstandRequestInjectionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/UnderstandRequestInjectionTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/UnderstandRequestInjectionTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalTask.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalTask.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalTask.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalTask.java Thu Jun  5 16:02:07 2014
@@ -22,6 +22,7 @@ package org.apache.onami.persist.test.tr
 import com.google.common.annotations.VisibleForTesting;
 import com.google.inject.Inject;
 import org.apache.onami.persist.EntityManagerProvider;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
 
@@ -33,8 +34,8 @@ import java.util.List;
  * A {@link TransactionalTask} is a task which is executed during a transaction
  * test. {@link TransactionalTask}s are passed to a {@link TransactionalWorker} which will call
  * them one after another.
- * The sub classes of {@link TransactionalTask} should create a {@link TransactionTestEntity} and
- * use {@link #storeEntity(TransactionTestEntity)} to persist entities in the DB. They also must
+ * The sub classes of {@link TransactionalTask} should create a {@link org.apache.onami.persist.test.TestEntity} and
+ * use {@link #storeEntity(org.apache.onami.persist.test.TestEntity)} to persist entities in the DB. They also must
  * call {@link #doOtherTasks()} to allow the {@link TransactionalWorker} to call the other scheduled
  * tasks.
  */
@@ -46,11 +47,11 @@ public abstract class TransactionalTask
 
     private TransactionalWorker worker;
 
-    private final List<TransactionTestEntity> persistedEntities = new ArrayList<TransactionTestEntity>();
+    private final List<TestEntity> persistedEntities = new ArrayList<TestEntity>();
 
     /**
      * Should 'try to' create entities in the persistent storage (i.e. DB).
-     * Use {@link #storeEntity(TransactionTestEntity)} to persist entities.
+     * Use {@link #storeEntity(org.apache.onami.persist.test.TestEntity)} to persist entities.
      *
      * @throws TestException        may be thrown to test rollback.
      * @throws RuntimeTestException may be thrown to test rollback.
@@ -75,7 +76,7 @@ public abstract class TransactionalTask
      *
      * @param entity the entity to store.
      */
-    protected final void storeEntity( TransactionTestEntity entity )
+    protected final void storeEntity( TestEntity entity )
     {
         final EntityManager entityManager = emProvider.get();
         entityManager.persist( entity );
@@ -90,7 +91,7 @@ public abstract class TransactionalTask
     }
 
     @VisibleForTesting
-    List<TransactionTestEntity> getPersistedEntities()
+    List<TestEntity> getPersistedEntities()
     {
         return persistedEntities;
     }

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalWorker.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalWorker.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalWorker.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/TransactionalWorker.java Thu Jun  5 16:02:07 2014
@@ -25,6 +25,7 @@ import com.google.inject.Injector;
 import org.apache.onami.persist.EntityManagerProvider;
 import org.apache.onami.persist.Transactional;
 import org.apache.onami.persist.UnitOfWork;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
 
@@ -48,7 +49,7 @@ public class TransactionalWorker
 
     private final TransactionalTasks tasks = new TransactionalTasks();
 
-    private final List<TransactionTestEntity> storedEntities = new ArrayList<TransactionTestEntity>();
+    private final List<TestEntity> storedEntities = new ArrayList<TestEntity>();
 
     @Inject
     private Injector injector;
@@ -92,7 +93,7 @@ public class TransactionalWorker
 
     /**
      * Executes the previously specified tasks. All entities which were stored using
-     * {@link TransactionalTask#storeEntity(TransactionTestEntity)} are collected by the worker.<p/>
+     * {@link TransactionalTask#storeEntity(org.apache.onami.persist.test.TestEntity)} are collected by the worker.<p/>
      */
     public void doTasks()
     {
@@ -124,10 +125,10 @@ public class TransactionalWorker
     public void assertAllEntitiesHaveBeenPersisted()
     {
         checkState( !storedEntities.isEmpty(), "no entities to check" );
-        for ( TransactionTestEntity storedEntity : storedEntities )
+        for ( TestEntity storedEntity : storedEntities )
         {
             assertNotNull( "At least one entity which should have been persisted was NOT found in the DB. " + tasks,
-                           emProvider.get().find( TransactionTestEntity.class, storedEntity.getId() ) );
+                           emProvider.get().find( TestEntity.class, storedEntity.getId() ) );
         }
     }
 
@@ -138,10 +139,10 @@ public class TransactionalWorker
     public void assertNoEntityHasBeenPersisted()
     {
         checkState( !storedEntities.isEmpty(), "no entities to check" );
-        for ( TransactionTestEntity storedEntity : storedEntities )
+        for ( TestEntity storedEntity : storedEntities )
         {
             assertNull( "At least one entity which should NOT have been persisted was found in the DB. " + tasks,
-                        emProvider.get().find( TransactionTestEntity.class, storedEntity.getId() ) );
+                        emProvider.get().find( TestEntity.class, storedEntity.getId() ) );
         }
     }
 

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnAnyThrowin
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
     }
 

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnAnyThrowin
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
         throw new RuntimeTestException( getClass().getSimpleName() );
     }

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnAnyThrowin
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
         throw new TestException( getClass().getSimpleName() );
     }

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnNoneThrowi
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
     }
 

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnNoneThrowi
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
         throw new RuntimeTestException( getClass().getSimpleName() );
     }

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnNoneThrowi
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
         throw new TestException();
     }

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnRuntimeTes
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
     }
 

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnRuntimeTes
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
         throw new RuntimeTestException( getClass().getSimpleName() );
     }

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnRuntimeTes
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
         throw new TestException( getClass().getSimpleName() );
     }

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnTestExcept
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
     }
 

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnTestExcept
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
         throw new RuntimeTestException( getClass().getSimpleName() );
     }

Modified: onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java (original)
+++ onami/trunk/persist/src/test/java/org/apache/onami/persist/test/transaction/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java Thu Jun  5 16:02:07 2014
@@ -20,7 +20,7 @@ package org.apache.onami.persist.test.tr
  */
 
 import org.apache.onami.persist.Transactional;
-import org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity;
+import org.apache.onami.persist.test.TestEntity;
 import org.apache.onami.persist.test.transaction.testframework.TransactionalTask;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.RuntimeTestException;
 import org.apache.onami.persist.test.transaction.testframework.exceptions.TestException;
@@ -42,7 +42,7 @@ public class TaskRollingBackOnTestExcept
     public void doTransactional()
         throws TestException, RuntimeTestException
     {
-        storeEntity( new TransactionTestEntity() );
+        storeEntity( new TestEntity() );
         doOtherTasks();
         throw new TestException( getClass().getSimpleName() );
     }

Modified: onami/trunk/persist/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/onami/trunk/persist/src/test/resources/META-INF/persistence.xml?rev=1600690&r1=1600689&r2=1600690&view=diff
==============================================================================
--- onami/trunk/persist/src/test/resources/META-INF/persistence.xml (original)
+++ onami/trunk/persist/src/test/resources/META-INF/persistence.xml Thu Jun  5 16:02:07 2014
@@ -26,7 +26,7 @@
     <persistence-unit name="testUnit" transaction-type="RESOURCE_LOCAL">
         <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
 
-        <class>org.apache.onami.persist.test.transaction.testframework.TransactionTestEntity</class>
+        <class>org.apache.onami.persist.test.TestEntity</class>
 
         <exclude-unlisted-classes>true</exclude-unlisted-classes>
 
@@ -43,4 +43,46 @@
         </properties>
     </persistence-unit>
 
+    <!-- JPA first "unit" -->
+    <persistence-unit name="firstUnit" transaction-type="RESOURCE_LOCAL">
+        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+
+        <class>org.apache.onami.persist.test.TestEntity</class>
+
+        <exclude-unlisted-classes>true</exclude-unlisted-classes>
+
+        <properties>
+            <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
+            <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:first"/>
+            <property name="hibernate.connection.username" value="sa"/>
+            <property name="hibernate.connection.password" value="sa"/>
+            <property name="hibernate.connection.pool_size" value="2"/>
+            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+            <property name="hibernate.cache_provider" value="org.hibernate.cache.NoCacheProvider"/>
+
+            <property name="hibernate.hbm2ddl.auto" value="create"/>
+        </properties>
+    </persistence-unit>
+
+    <!-- JPA second "unit" -->
+    <persistence-unit name="secondUnit" transaction-type="RESOURCE_LOCAL">
+        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
+
+        <class>org.apache.onami.persist.test.TestEntity</class>
+
+        <exclude-unlisted-classes>true</exclude-unlisted-classes>
+
+        <properties>
+            <property name="hibernate.connection.driver_class" value="org.hsqldb.jdbcDriver"/>
+            <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:second"/>
+            <property name="hibernate.connection.username" value="sa"/>
+            <property name="hibernate.connection.password" value="sa"/>
+            <property name="hibernate.connection.pool_size" value="2"/>
+            <property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
+            <property name="hibernate.cache_provider" value="org.hibernate.cache.NoCacheProvider"/>
+
+            <property name="hibernate.hbm2ddl.auto" value="create"/>
+        </properties>
+    </persistence-unit>
+
 </persistence>



Mime
View raw message