OPENJPA-2095 - JUnit 4 treats Test*.class as test case. Otherwise the following exception will be observed.

java.lang.IllegalArgumentException: Test class can only have one constructor
    at org.junit.runners.model.TestClass.<init>(TestClass.java:32)
    at org.junit.runners.ParentRunner.<init>(ParentRunner.java:54)
    
Rename entity classes prefix Test* to avoid the problem.

git-svn-id: https://svn.apache.org/repos/asf/openjpa/branches/2.0.x@1342800 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Albert Lee 2012-05-25 20:28:30 +00:00
parent 17ccc596c7
commit dc662be961
4 changed files with 17 additions and 19 deletions

View File

@ -24,17 +24,17 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;
import javax.persistence.Query;
import org.apache.openjpa.persistence.simple.TestEntityWithTimestampPK;
import org.apache.openjpa.persistence.simple.EntityWithTimestampPK;
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
public class TestTimestampPKDeletion extends SQLListenerTestCase {
public void setUp() {
setUp(TestEntityWithTimestampPK.class);
setUp(EntityWithTimestampPK.class);
}
public void testTimestampPKDeletion() {
TestEntityWithTimestampPK testEntity = new TestEntityWithTimestampPK("test");
EntityWithTimestampPK testEntity = new EntityWithTimestampPK("test");
EntityManager em = emf.createEntityManager();
@ -46,10 +46,10 @@ public class TestTimestampPKDeletion extends SQLListenerTestCase {
em = emf.createEntityManager();
final EntityTransaction tx = em.getTransaction();
tx.begin();
final Query q = em.createQuery("SELECT testEntity FROM TestEntityWithTimestampPK testEntity ");
final Query q = em.createQuery("SELECT testEntity FROM EntityWithTimestampPK testEntity ");
final List<TestEntityWithTimestampPK> testEntities = q.getResultList();
for (TestEntityWithTimestampPK t : testEntities) {
final List<EntityWithTimestampPK> testEntities = q.getResultList();
for (EntityWithTimestampPK t : testEntities) {
em.remove(t);
}
tx.commit();

View File

@ -23,11 +23,9 @@ import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.PersistenceException;
import javax.persistence.Table;
@Entity
@Table(name="TestItemWithFailedExternalizer")
public class TestItemWithFailedExternalizer implements Serializable {
public class EntityWithFailedExternalizer implements Serializable {
private static final long serialVersionUID = 1L;
@ -73,11 +71,11 @@ public class TestItemWithFailedExternalizer implements Serializable {
}
}
public TestItemWithFailedExternalizer() {
public EntityWithFailedExternalizer() {
super();
}
public TestItemWithFailedExternalizer(int iref, String name, String data) {
public EntityWithFailedExternalizer(int iref, String name, String data) {
super();
this.iref = iref;
this.name = name;

View File

@ -24,7 +24,7 @@ import javax.persistence.EntityTransaction;
import org.apache.openjpa.persistence.PersistenceException;
import org.apache.openjpa.persistence.RollbackException;
import org.apache.openjpa.persistence.jdbc.common.apps.TestItemWithFailedExternalizer;
import org.apache.openjpa.persistence.jdbc.common.apps.EntityWithFailedExternalizer;
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
/*
@ -35,7 +35,7 @@ public class TestBatchFlushWithMetadataException extends SQLListenerTestCase {
@Override
public void setUp() throws Exception {
setUp(DROP_TABLES, TestItemWithFailedExternalizer.class);
setUp(DROP_TABLES, EntityWithFailedExternalizer.class);
}
public void testCreate(){
@ -43,10 +43,10 @@ public class TestBatchFlushWithMetadataException extends SQLListenerTestCase {
EntityTransaction tx = em.getTransaction();
tx.begin();
TestItemWithFailedExternalizer item1 = new TestItemWithFailedExternalizer(1001, "MyName1", "description1");
TestItemWithFailedExternalizer item2 = new TestItemWithFailedExternalizer(1002, "MyName2", "description2");
EntityWithFailedExternalizer item1 = new EntityWithFailedExternalizer(1001, "MyName1", "description1");
EntityWithFailedExternalizer item2 = new EntityWithFailedExternalizer(1002, "MyName2", "description2");
item1.getExt().throwEx=true;
TestItemWithFailedExternalizer item3 = new TestItemWithFailedExternalizer(1003, "MyName3", "description3");
EntityWithFailedExternalizer item3 = new EntityWithFailedExternalizer(1003, "MyName3", "description3");
em.persist(item1);
em.persist(item2);

View File

@ -25,7 +25,7 @@ import javax.persistence.Entity;
import javax.persistence.Id;
@Entity
public class TestEntityWithTimestampPK {
public class EntityWithTimestampPK {
@Id
private Timestamp idTsp;
@ -36,13 +36,13 @@ public class TestEntityWithTimestampPK {
return idTsp;
}
public TestEntityWithTimestampPK(String desc) {
public EntityWithTimestampPK(String desc) {
super();
this.idTsp = new Timestamp((new Date()).getTime());
this.description = desc;
}
public TestEntityWithTimestampPK(){
public EntityWithTimestampPK(){
}