o use Hamcrest assertion to determine if Entity was deleted from underlying store.
git-svn-id: https://svn.apache.org/repos/asf/maven/continuum/branches/continuum-jpa@603173 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java b/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
index ca0ce5d..12f2db2 100644
--- a/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
+++ b/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectGroupStoreTest.java
@@ -3,6 +3,8 @@
*/
package org.apache.maven.continuum.store.jpa;
+import static org.apache.maven.continuum.store.matcher.JpaEntity.isDeleted;
+
import java.io.File;
import java.util.List;
import java.util.Properties;
@@ -20,7 +22,6 @@
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -106,21 +107,7 @@
Assert.assertTrue( group.getId() > 0L );
getProjectGroupStore().delete( group );
// assertion follows in a separate transaction
- }
-
- @AfterTransaction
- public void assertProjectGroupDeleted() throws StoreException
- {
- try
- {
- getProjectGroupStore().lookup( ProjectGroup.class, 100L );
- Assert.fail( "Expected exception: " + EntityNotFoundException.class.getSimpleName()
- + ". ProjectNotifier instance should have been deleted from the underlying store." );
- }
- catch ( EntityNotFoundException e )
- {
- // expected!
- }
+ isDeleted( getProjectGroupStore(), ProjectGroup.class, group );
}
@Test
diff --git a/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java b/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
index 239877e..3e8e50b 100644
--- a/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
+++ b/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectNotifierStoreTest.java
@@ -3,13 +3,14 @@
*/
package org.apache.maven.continuum.store.jpa;
+import static org.apache.maven.continuum.store.matcher.JpaEntity.isDeleted;
+
import java.io.File;
import java.util.List;
import java.util.Properties;
import org.apache.maven.continuum.model.project.ProjectNotifier;
import org.apache.maven.continuum.store.ApplicationContextAwareStoreTestCase;
-import org.apache.maven.continuum.store.api.EntityNotFoundException;
import org.apache.maven.continuum.store.api.Store;
import org.apache.maven.continuum.store.api.StoreException;
import org.apache.openjpa.persistence.OpenJPAQuery;
@@ -20,7 +21,6 @@
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -87,21 +87,7 @@
Assert.assertTrue( notifier.getId() > 0L );
getProjectNotifierStore().delete( notifier );
// assertion follows in a separate transaction
- }
-
- @AfterTransaction
- public void assertProjectNotifierDeleted() throws StoreException
- {
- try
- {
- ProjectNotifier notifier = getProjectNotifierStore().lookup( ProjectNotifier.class, 100L );
- Assert.fail( "Expected exception: " + EntityNotFoundException.class.getSimpleName()
- + ". ProjectNotifier instance should have been deleted from the underlying store." );
- }
- catch ( EntityNotFoundException e )
- {
- // expected!
- }
+ isDeleted( getProjectNotifierStore(), ProjectNotifier.class, notifier );
}
@Override
diff --git a/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectStoreTest.java b/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectStoreTest.java
index af8a875..249a956 100644
--- a/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectStoreTest.java
+++ b/continuum-model-jpa/src/test/java/org/apache/maven/continuum/store/jpa/JpaProjectStoreTest.java
@@ -11,10 +11,8 @@
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.store.ApplicationContextAwareStoreTestCase;
-import org.apache.maven.continuum.store.api.EntityNotFoundException;
import org.apache.maven.continuum.store.api.Store;
import org.apache.maven.continuum.store.api.StoreException;
-import org.apache.maven.continuum.store.matcher.JpaEntity;
import org.apache.openjpa.persistence.OpenJPAQuery;
import org.junit.After;
import org.junit.Assert;
@@ -23,7 +21,6 @@
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.transaction.AfterTransaction;
import org.springframework.transaction.annotation.Transactional;
/**
@@ -103,21 +100,6 @@
isDeleted( getProjectStore(), Project.class, project );
}
- // @AfterTransaction
- public void assertProjectDeleted() throws StoreException
- {
- try
- {
- getProjectStore().lookup( Project.class, 100L );
- Assert.fail( "Expected exception: " + EntityNotFoundException.class.getSimpleName()
- + ". Project instance should have been deleted from the underlying store." );
- }
- catch ( EntityNotFoundException e )
- {
- // expected!
- }
- }
-
@Override
@After
public void tearDown() throws Exception
diff --git a/continuum-model-jpa/src/test/resources/META-INF/persistence.xml b/continuum-model-jpa/src/test/resources/META-INF/persistence.xml
index 259797f..6ec2d51 100644
--- a/continuum-model-jpa/src/test/resources/META-INF/persistence.xml
+++ b/continuum-model-jpa/src/test/resources/META-INF/persistence.xml
@@ -42,12 +42,13 @@
<!-- Configure OpenJPA to automatically run the mapping tool at runtime and create schema on Unit Test setup -->
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema(ForeignKeys=true)"/>
- <!-- Enable SQL logging in OpenJPA -->
+ <!-- Enable SQL logging in OpenJPA
<property name="openjpa.Log" value="DefaultLevel=INFO,SQL=TRACE" />
-
- <!-- Change default log level across OpenJPA
- <property name="openjpa.Log" value="DefaultLevel=TRACE"/>
-->
+
+ <!-- Change default log level across OpenJPA -->
+ <property name="openjpa.Log" value="DefaultLevel=WARN"/>
+
</properties>
</persistence-unit>