mirror of https://github.com/apache/openjpa.git
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.1.x@1342801 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
423ed6ead0
commit
4c2d1f2d8b
|
@ -24,17 +24,17 @@ import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityTransaction;
|
import javax.persistence.EntityTransaction;
|
||||||
import javax.persistence.Query;
|
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;
|
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||||
|
|
||||||
public class TestTimestampPKDeletion extends SQLListenerTestCase {
|
public class TestTimestampPKDeletion extends SQLListenerTestCase {
|
||||||
|
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
setUp(TestEntityWithTimestampPK.class);
|
setUp(EntityWithTimestampPK.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testTimestampPKDeletion() {
|
public void testTimestampPKDeletion() {
|
||||||
TestEntityWithTimestampPK testEntity = new TestEntityWithTimestampPK("test");
|
EntityWithTimestampPK testEntity = new EntityWithTimestampPK("test");
|
||||||
|
|
||||||
EntityManager em = emf.createEntityManager();
|
EntityManager em = emf.createEntityManager();
|
||||||
|
|
||||||
|
@ -46,10 +46,10 @@ public class TestTimestampPKDeletion extends SQLListenerTestCase {
|
||||||
em = emf.createEntityManager();
|
em = emf.createEntityManager();
|
||||||
final EntityTransaction tx = em.getTransaction();
|
final EntityTransaction tx = em.getTransaction();
|
||||||
tx.begin();
|
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();
|
final List<EntityWithTimestampPK> testEntities = q.getResultList();
|
||||||
for (TestEntityWithTimestampPK t : testEntities) {
|
for (EntityWithTimestampPK t : testEntities) {
|
||||||
em.remove(t);
|
em.remove(t);
|
||||||
}
|
}
|
||||||
tx.commit();
|
tx.commit();
|
||||||
|
|
|
@ -23,11 +23,9 @@ import java.io.Serializable;
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import javax.persistence.PersistenceException;
|
import javax.persistence.PersistenceException;
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="TestItemWithFailedExternalizer")
|
public class EntityWithFailedExternalizer implements Serializable {
|
||||||
public class TestItemWithFailedExternalizer implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -73,11 +71,11 @@ public class TestItemWithFailedExternalizer implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestItemWithFailedExternalizer() {
|
public EntityWithFailedExternalizer() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestItemWithFailedExternalizer(int iref, String name, String data) {
|
public EntityWithFailedExternalizer(int iref, String name, String data) {
|
||||||
super();
|
super();
|
||||||
this.iref = iref;
|
this.iref = iref;
|
||||||
this.name = name;
|
this.name = name;
|
|
@ -24,7 +24,7 @@ import javax.persistence.EntityTransaction;
|
||||||
|
|
||||||
import org.apache.openjpa.persistence.PersistenceException;
|
import org.apache.openjpa.persistence.PersistenceException;
|
||||||
import org.apache.openjpa.persistence.RollbackException;
|
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;
|
import org.apache.openjpa.persistence.test.SQLListenerTestCase;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -35,7 +35,7 @@ public class TestBatchFlushWithMetadataException extends SQLListenerTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
setUp(DROP_TABLES, TestItemWithFailedExternalizer.class);
|
setUp(DROP_TABLES, EntityWithFailedExternalizer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreate(){
|
public void testCreate(){
|
||||||
|
@ -43,10 +43,10 @@ public class TestBatchFlushWithMetadataException extends SQLListenerTestCase {
|
||||||
EntityTransaction tx = em.getTransaction();
|
EntityTransaction tx = em.getTransaction();
|
||||||
|
|
||||||
tx.begin();
|
tx.begin();
|
||||||
TestItemWithFailedExternalizer item1 = new TestItemWithFailedExternalizer(1001, "MyName1", "description1");
|
EntityWithFailedExternalizer item1 = new EntityWithFailedExternalizer(1001, "MyName1", "description1");
|
||||||
TestItemWithFailedExternalizer item2 = new TestItemWithFailedExternalizer(1002, "MyName2", "description2");
|
EntityWithFailedExternalizer item2 = new EntityWithFailedExternalizer(1002, "MyName2", "description2");
|
||||||
item1.getExt().throwEx=true;
|
item1.getExt().throwEx=true;
|
||||||
TestItemWithFailedExternalizer item3 = new TestItemWithFailedExternalizer(1003, "MyName3", "description3");
|
EntityWithFailedExternalizer item3 = new EntityWithFailedExternalizer(1003, "MyName3", "description3");
|
||||||
|
|
||||||
em.persist(item1);
|
em.persist(item1);
|
||||||
em.persist(item2);
|
em.persist(item2);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class TestEntityWithTimestampPK {
|
public class EntityWithTimestampPK {
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
private Timestamp idTsp;
|
private Timestamp idTsp;
|
||||||
|
@ -36,13 +36,13 @@ public class TestEntityWithTimestampPK {
|
||||||
return idTsp;
|
return idTsp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestEntityWithTimestampPK(String desc) {
|
public EntityWithTimestampPK(String desc) {
|
||||||
super();
|
super();
|
||||||
this.idTsp = new Timestamp((new Date()).getTime());
|
this.idTsp = new Timestamp((new Date()).getTime());
|
||||||
this.description = desc;
|
this.description = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TestEntityWithTimestampPK(){
|
public EntityWithTimestampPK(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue