onami-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sclas...@apache.org
Subject svn commit: r1542116 [3/3] - in /onami/sandbox/persist: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/onami/ src/main/java/org/apache/onami/persist/ src/test/ src/test/java/ src/test/java/org/ sr...
Date Thu, 14 Nov 2013 23:19:37 GMT
Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/SingleTransactionTest.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/SingleTransactionTest.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/SingleTransactionTest.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/SingleTransactionTest.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,224 @@
+package org.apache.onami.persist;
+
+/*
+ * 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.Injector;
+import junit.framework.TestCase;
+import org.apache.onami.persist.testframework.TransactionalWorker;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnAnyThrowingNone;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnAnyThrowingRuntimeTestException;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnAnyThrowingTestException;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnNoneThrowingNone;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnNoneThrowingRuntimeTestException;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnNoneThrowingTestException;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnRuntimeTestExceptionThrowingNone;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnRuntimeTestExceptionThrowingTestException;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnTestExceptionThrowingNone;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnTestExceptionThrowingRuntimeTestException;
+import org.apache.onami.persist.testframework.tasks.TaskRollingBackOnTestExceptionThrowingTestException;
+
+/**
+ * Tests running a single non nested transaction.
+ * The test make us of the testframework. For every test a new Injector is created.
+ */
+public class SingleTransactionTest
+    extends TestCase
+{
+
+    private Injector injector;
+
+    @Override
+    public void setUp()
+    {
+        final PersistenceModule pm = new PersistenceModule();
+        pm.addApplicationManagedPersistenceUnit( "testUnit" );
+        injector = Guice.createInjector( pm );
+
+        //startup persistence
+        injector.getInstance( PersistenceService.class ).start();
+    }
+
+    @Override
+    public void tearDown()
+    {
+        injector.getInstance( PersistenceService.class ).stop();
+        injector = null;
+    }
+
+
+    public void testTaskRollingBackOnAnyThrowingNone()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnAnyThrowingNone.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertAllEntitesHaveBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnAnyThrowingRuntimeTestException()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnAnyThrowingRuntimeTestException.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertNoEntityHasBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnAnyThrowingTestException()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnAnyThrowingTestException.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertNoEntityHasBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnNoneThrowingNone()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnNoneThrowingNone.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertAllEntitesHaveBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnNoneThrowingRuntimeTestException()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnNoneThrowingRuntimeTestException.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertAllEntitesHaveBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnNoneThrowingTestException()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnNoneThrowingTestException.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertAllEntitesHaveBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnRuntimeTestExceptionThrowingNone()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnRuntimeTestExceptionThrowingNone.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertAllEntitesHaveBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertNoEntityHasBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnRuntimeTestExceptionThrowingTestException()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnRuntimeTestExceptionThrowingTestException.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertAllEntitesHaveBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnTestExceptionThrowingNone()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnTestExceptionThrowingNone.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertAllEntitesHaveBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnTestExceptionThrowingRuntimeTestException()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnTestExceptionThrowingRuntimeTestException.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertAllEntitesHaveBeenPersisted();
+    }
+
+    public void testTaskRollingBackOnTestExceptionThrowingTestException()
+    {
+        // given
+        final TransactionalWorker worker = injector.getInstance( TransactionalWorker.class );
+        worker.scheduleTask( TaskRollingBackOnTestExceptionThrowingTestException.class );
+
+        // when
+        worker.doTasks();
+
+        // then
+        worker.assertNoEntityHasBeenPersisted();
+    }
+
+}

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

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

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

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionTestEntity.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionTestEntity.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionTestEntity.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionTestEntity.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,85 @@
+package org.apache.onami.persist.testframework;
+
+/*
+ * 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 javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import java.io.Serializable;
+import java.util.UUID;
+
+/**
+ * Entities which can be created during transaction tests.
+ * The ID will be unique in every run of a test.
+ */
+@Entity
+public final class TransactionTestEntity
+    implements Serializable
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private UUID id = UUID.randomUUID();
+
+    private String text;
+
+    /**
+     * Default constructor.
+     */
+    public TransactionTestEntity()
+    {
+        // nop
+    }
+
+    /**
+     * Convenience constructor for directly setting the text.
+     *
+     * @param text will be stored in the column {@code text}.
+     */
+    public TransactionTestEntity( String text )
+    {
+        this.text = text;
+    }
+
+    @Id
+    public UUID getId()
+    {
+        return id;
+    }
+
+    @SuppressWarnings("unused")
+    // used by the persistence framework
+    private void setId( UUID id )
+    {
+        this.id = id;
+    }
+
+    @Column(length = 200)
+    public String getText()
+    {
+        return text;
+    }
+
+    public void setText( String text )
+    {
+        this.text = text;
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionTestEntity.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionTestEntity.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalTask.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalTask.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalTask.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalTask.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,95 @@
+package org.apache.onami.persist.testframework;
+
+/*
+ * 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.common.annotations.VisibleForTesting;
+import com.google.inject.Inject;
+import org.apache.onami.persist.EntityManagerProvider;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+import java.util.ArrayList;
+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
+ * call {@link #doOtherTasks()} to allow the {@link TransactionalWorker} to call the other scheduled
+ * tasks.
+ */
+public abstract class TransactionalTask
+{
+
+    @Inject
+    private EntityManagerProvider emProvider;
+
+    private TransactionalWorker worker;
+
+    private final List<TransactionTestEntity> persistedEntities = new ArrayList<TransactionTestEntity>();
+
+    /**
+     * Should 'try to' create entities in the persistent storage (i.e. DB).
+     * Use {@link #storeEntity(TransactionTestEntity)} to persist entities.
+     *
+     * @throws TestException        may be thrown to test rollback.
+     * @throws RuntimeTestException may be thrown to test rollback.
+     */
+    public abstract void doTransactional()
+        throws TestException, RuntimeTestException;
+
+    /**
+     * Does other tasks.
+     *
+     * @throws TestException        may be thrown to test rollback.
+     * @throws RuntimeTestException may be thrown to test rollback.
+     */
+    protected final void doOtherTasks()
+        throws TestException, RuntimeTestException
+    {
+        worker.doNextTask();
+    }
+
+    /**
+     * Stores an entity.
+     *
+     * @param entity the entity to store.
+     */
+    protected final void storeEntity( TransactionTestEntity entity )
+    {
+        emProvider.get().persist( entity );
+        persistedEntities.add( entity );
+    }
+
+    @VisibleForTesting
+    void setWorker( TransactionalWorker transactionalWorker )
+    {
+        worker = transactionalWorker;
+    }
+
+    @VisibleForTesting
+    List<TransactionTestEntity> getPersistedEntities()
+    {
+        return persistedEntities;
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalTask.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalTask.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalWorker.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalWorker.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalWorker.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalWorker.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,232 @@
+package org.apache.onami.persist.testframework;
+
+/*
+ * 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.common.annotations.VisibleForTesting;
+import com.google.inject.Inject;
+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.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Worker for transactional tests. The worker instantiates the {@link TransactionalTask} and
+ * executes them.
+ */
+public class TransactionalWorker
+{
+
+    private static final String DO_TRANSACTIONAL = "doTransactional";
+
+    private final TransactionalTasks tasks = new TransactionalTasks();
+
+    private final List<TransactionTestEntity> storedEntities = new ArrayList<TransactionTestEntity>();
+
+    @Inject
+    private Injector injector;
+
+    @Inject
+    private UnitOfWork unitOfWork;
+
+    @Inject
+    private EntityManagerProvider emProvider;
+
+    /**
+     * Schedules a task for execution by this worker.
+     * If more than one task are scheduled they will be called in the order they have been
+     * scheduled.
+     *
+     * @param taskType the task to schedule for execution.
+     */
+    public void scheduleTask( Class<? extends TransactionalTask> taskType )
+    {
+        checkTransactionalAnnotation( taskType );
+        final TransactionalTask task = injector.getInstance( taskType );
+        task.setWorker( this );
+        tasks.add( task );
+    }
+
+    private void checkTransactionalAnnotation( Class<? extends TransactionalTask> taskType )
+    {
+        try
+        {
+            final Method method = taskType.getMethod( DO_TRANSACTIONAL );
+            final Transactional annotation = method.getAnnotation( Transactional.class );
+            checkNotNull( annotation, "@Transactional annotation missing on %s.%s", taskType.getSimpleName(),
+                          DO_TRANSACTIONAL );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            // should never occure.
+            throw new RuntimeException( e );
+        }
+    }
+
+    /**
+     * Executes the previously specified tasks. All entities which were stored using
+     * {@link TransactionalTask#storeEntity(TransactionTestEntity)} are collected by the worker.<p/>
+     */
+    public void doTasks()
+    {
+        checkState( tasks.hasTasks(), "no tasks have been added to the worker." );
+        checkState( tasks.hasNext(), "doTasks() has already been executed." );
+        checkState( !unitOfWork.isActive(), "Active UnitOfWork found." );
+
+        try
+        {
+            doNextTask();
+        }
+        catch ( TestException e )
+        {
+            // do nothing
+        }
+        catch ( RuntimeTestException e )
+        {
+            // do nothing
+        }
+
+        checkState( !tasks.hasNext(), "One of the tasks forgot to call doOtherTasks()." );
+        checkState( !unitOfWork.isActive(), "Active UnitOfWork after tasks found." );
+    }
+
+    /**
+     * Check all stored entities if they actually have been persisted in the DB.
+     */
+    @Transactional
+    public void assertAllEntitesHaveBeenPersisted()
+    {
+        checkState( !storedEntities.isEmpty(), "no entities to check" );
+        for ( TransactionTestEntity storedEntity : storedEntities )
+        {
+            assertNotNull( "At least one entity which should have been peristed was NOT found in the DB. " + tasks,
+                           emProvider.get().find( TransactionTestEntity.class, storedEntity.getId() ) );
+        }
+    }
+
+    /**
+     * Check all stored entities if they actually have NOT been persisted in the DB.
+     */
+    @Transactional
+    public void assertNoEntityHasBeenPersisted()
+    {
+        checkState( !storedEntities.isEmpty(), "no entities to check" );
+        for ( TransactionTestEntity storedEntity : storedEntities )
+        {
+            assertNull( "At least one entity which should NOT have been peristed was found in the DB. " + tasks,
+                        emProvider.get().find( TransactionTestEntity.class, storedEntity.getId() ) );
+        }
+    }
+
+    @VisibleForTesting
+    void doNextTask()
+        throws TestException
+    {
+        if ( tasks.hasNext() )
+        {
+            final TransactionalTask task = tasks.next();
+            try
+            {
+                task.doTransactional();
+            }
+            finally
+            {
+                storedEntities.addAll( task.getPersistedEntities() );
+            }
+        }
+    }
+
+
+    /**
+     * Class holding the tasks of a worker.
+     */
+    private static class TransactionalTasks
+    {
+
+        private final List<TransactionalTask> tasks = new ArrayList<TransactionalTask>();
+
+        private int pos = 0;
+
+        /**
+         * @return {@code true} if there have already been tasks added.
+         */
+        public boolean hasTasks()
+        {
+            return !tasks.isEmpty();
+        }
+
+        /**
+         * Add a task.
+         *
+         * @param task the task to add.
+         * @throws IllegalStateException if {@link #next()} has already been called on this instance.
+         */
+        public void add( TransactionalTask task )
+        {
+            checkState( pos == 0 );
+            tasks.add( task );
+        }
+
+        /**
+         * @return {@code true} if there are more tasks.
+         */
+        public boolean hasNext()
+        {
+            return pos < tasks.size();
+        }
+
+        /**
+         * @return the next task.
+         * @throws IndexOutOfBoundsException if there are no more tasks.
+         */
+        public TransactionalTask next()
+        {
+            final TransactionalTask result = tasks.get( pos );
+            pos++;
+            return result;
+        }
+
+        @Override
+        public String toString()
+        {
+            final StringBuilder sb = new StringBuilder( "Tasks[" );
+            String separator = "";
+            for ( TransactionalTask t : tasks )
+            {
+                sb.append( separator );
+                final String taskType = t.getClass().getSimpleName();
+                sb.append( taskType.replaceAll( "\\$\\$EnhancerByGuice\\$\\$.*", "" ) );
+                separator = ", ";
+            }
+            sb.append( "]" );
+            return sb.toString();
+        }
+    }
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalWorker.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/TransactionalWorker.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/RuntimeTestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/RuntimeTestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/RuntimeTestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/RuntimeTestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,58 @@
+package org.apache.onami.persist.testframework.exceptions;
+
+/*
+ * 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 org.apache.onami.persist.testframework.TransactionalTask;
+
+/**
+ * Exception which can be thrown by a {@link TransactionalTask}.
+ */
+public class RuntimeTestException
+    extends RuntimeException
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private final String message;
+
+    /**
+     * Constructor.
+     */
+    public RuntimeTestException()
+    {
+        this.message = RuntimeTestException.class.getSimpleName();
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message the message of the exception.
+     */
+    public RuntimeTestException( String message )
+    {
+        this.message = message;
+    }
+
+    @Override
+    public String getMessage()
+    {
+        return message;
+    }
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/RuntimeTestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/RuntimeTestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/RuntimeTestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/TestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/TestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/TestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/TestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,58 @@
+package org.apache.onami.persist.testframework.exceptions;
+
+/*
+ * 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 org.apache.onami.persist.testframework.TransactionalTask;
+
+/**
+ * Exception which can be thrown by a {@link TransactionalTask}.
+ */
+public class TestException
+    extends Exception
+{
+
+    private static final long serialVersionUID = 1L;
+
+    private final String message;
+
+    /**
+     * Constructor.
+     */
+    public TestException()
+    {
+        message = TestException.class.getSimpleName();
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param message the message of the exception.
+     */
+    public TestException( String message )
+    {
+        this.message = message;
+    }
+
+    @Override
+    public String getMessage()
+    {
+        return message;
+    }
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/TestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/TestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/exceptions/TestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,49 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - roll back if any exception happened.
+ * - throw no new exception.
+ */
+public class TaskRollingBackOnAnyThrowingNone
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(rollbackOn = Exception.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingNone.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,50 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - roll back if any exception happened.
+ * - throw a new {@link RuntimeTestException}.
+ */
+public class TaskRollingBackOnAnyThrowingRuntimeTestException
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(rollbackOn = Exception.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+        throw new RuntimeTestException( getClass().getSimpleName() );
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,50 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - roll backy if an exception happened.
+ * - throw a new {@link TestException}.
+ */
+public class TaskRollingBackOnAnyThrowingTestException
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(rollbackOn = Exception.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+        throw new TestException( getClass().getSimpleName() );
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnAnyThrowingTestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,49 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - never roll back.
+ * - throw no new exception.
+ */
+public class TaskRollingBackOnNoneThrowingNone
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(ignore = Exception.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingNone.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,50 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - never roll back.
+ * - throw a new {@link RuntimeTestException}.
+ */
+public class TaskRollingBackOnNoneThrowingRuntimeTestException
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(ignore = Exception.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+        throw new RuntimeTestException( getClass().getSimpleName() );
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,50 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - never roll back.
+ * - throw a new {@link TestException}.
+ */
+public class TaskRollingBackOnNoneThrowingTestException
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(ignore = Exception.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+        throw new TestException();
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnNoneThrowingTestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,49 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - roll back on {@link RuntimeTestException}.
+ * - throw no new Exception
+ */
+public class TaskRollingBackOnRuntimeTestExceptionThrowingNone
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(rollbackOn = RuntimeTestException.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingNone.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,50 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - roll back on {@link RuntimeTestException}.
+ * - throw a new {@link RuntimeTestException}.
+ */
+public class TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(rollbackOn = RuntimeTestException.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+        throw new RuntimeTestException( getClass().getSimpleName() );
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,50 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - roll back on {@link RuntimeTestException}.
+ * - throw a new {@link TestException}.
+ */
+public class TaskRollingBackOnRuntimeTestExceptionThrowingTestException
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(rollbackOn = RuntimeTestException.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+        throw new TestException( getClass().getSimpleName() );
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnRuntimeTestExceptionThrowingTestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,49 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - roll back on {@link TestException}.
+ * - throw no new Exception
+ */
+public class TaskRollingBackOnTestExceptionThrowingNone
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(rollbackOn = TestException.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingNone.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,50 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - roll back on {@link TestException}.
+ * - throw a new {@link RuntimeTestException}.
+ */
+public class TaskRollingBackOnTestExceptionThrowingRuntimeTestException
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(rollbackOn = TestException.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+        throw new RuntimeTestException( getClass().getSimpleName() );
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingRuntimeTestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java (added)
+++ onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java Thu Nov 14 23:19:36 2013
@@ -0,0 +1,50 @@
+package org.apache.onami.persist.testframework.tasks;
+
+/*
+ * 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 org.apache.onami.persist.Transactional;
+import org.apache.onami.persist.testframework.TransactionTestEntity;
+import org.apache.onami.persist.testframework.TransactionalTask;
+import org.apache.onami.persist.testframework.exceptions.RuntimeTestException;
+import org.apache.onami.persist.testframework.exceptions.TestException;
+
+/**
+ * Task which stores an entity and will:
+ * - roll back on {@link TestException}.
+ * - throw a new {@link TestException}.
+ */
+public class TaskRollingBackOnTestExceptionThrowingTestException
+    extends TransactionalTask
+{
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    @Transactional(rollbackOn = TestException.class)
+    public void doTransactional()
+        throws TestException, RuntimeTestException
+    {
+        storeEntity( new TransactionTestEntity() );
+        doOtherTasks();
+        throw new TestException( getClass().getSimpleName() );
+    }
+
+}

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: onami/sandbox/persist/src/test/java/org/apache/onami/persist/testframework/tasks/TaskRollingBackOnTestExceptionThrowingTestException.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: onami/sandbox/persist/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/resources/META-INF/persistence.xml?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/resources/META-INF/persistence.xml (added)
+++ onami/sandbox/persist/src/test/resources/META-INF/persistence.xml Thu Nov 14 23:19:36 2013
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+        http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
+
+    <!-- JPA test "unit" -->
+    <persistence-unit name="testUnit" transaction-type="RESOURCE_LOCAL">
+        <provider>org.hibernate.ejb.HibernatePersistence</provider>
+
+        <class>org.apache.onami.persist.testframework.TransactionTestEntity</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:persistence"/>
+            <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="hiberante.cache_provider" value="org.hibernate.cache.NoCacheProvider"/>
+
+            <property name="hibernate.hbm2ddl.auto" value="create"/>
+        </properties>
+    </persistence-unit>
+
+</persistence>
+

Propchange: onami/sandbox/persist/src/test/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id

Propchange: onami/sandbox/persist/src/test/resources/META-INF/persistence.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: onami/sandbox/persist/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/onami/sandbox/persist/src/test/resources/log4j.properties?rev=1542116&view=auto
==============================================================================
--- onami/sandbox/persist/src/test/resources/log4j.properties (added)
+++ onami/sandbox/persist/src/test/resources/log4j.properties Thu Nov 14 23:19:36 2013
@@ -0,0 +1,6 @@
+log4j.rootLogger=warn, console
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.Target=System.out
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%p [%c{1}] - %m %n

Propchange: onami/sandbox/persist/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: onami/sandbox/persist/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:keywords = Date Revision Author HeadURL Id



Mime
View raw message