OPENJPA-2809 more test fixes

This commit is contained in:
Mark Struberg 2023-04-24 12:25:23 +02:00
parent d9ceb44526
commit 3a436b585d
8 changed files with 28 additions and 28 deletions

View File

@ -20,7 +20,7 @@ import jakarta.persistence.Entity;
import jakarta.persistence.Id;
@Entity
public class SnakeCaseDDLEntity {
public class SnakeCaseDDLMy1Entity {
@Id
private String fooBar;

View File

@ -132,13 +132,13 @@ public class TestDelimitIdentifiers {
{
final EntityManager em = entityManagerFactory.createEntityManager();
try {
assertEquals(2, em.createQuery("select x from TestDelimitIdentifiers$AllFieldTypes x").
assertEquals(2, em.createQuery("select x from DelimitedIdentifiersAllFieldTypesEntity x").
getResultList().size());
assertEquals(1, em.createQuery("select x from TestDelimitIdentifiers$AllFieldTypes x where x.stringField = 'foo'").
assertEquals(1, em.createQuery("select x from DelimitedIdentifiersAllFieldTypesEntity x where x.stringField = 'foo'").
getResultList().size());
assertEquals(0, em.createQuery("select x from TestDelimitIdentifiers$AllFieldTypes x where x.stringField = 'bar'").
assertEquals(0, em.createQuery("select x from DelimitedIdentifiersAllFieldTypesEntity x where x.stringField = 'bar'").
getResultList().size());
assertEquals(1, em.createQuery("select x from TestDelimitIdentifiers$AllFieldTypes x where x.intField >= 10").
assertEquals(1, em.createQuery("select x from DelimitedIdentifiersAllFieldTypesEntity x where x.intField >= 10").
getResultList().size());
} finally {
em.close();

View File

@ -62,7 +62,7 @@ public class TestSnakeCaseDDL {
final PersistenceUnitInfoImpl persistenceUnitInfo = new PersistenceUnitInfoImpl();
persistenceUnitInfo.setExcludeUnlistedClasses(true);
persistenceUnitInfo.addManagedClassName(SnakeCaseDDLEntity.class.getName());
persistenceUnitInfo.addManagedClassName(SnakeCaseDDLMy1Entity.class.getName());
persistenceUnitInfo.addManagedClassName(SnakeCaseDDLMy2Entity.class.getName());
final BasicDataSource ds = new BasicDataSource();
ds.setDriver(derbyDriver);
@ -74,7 +74,7 @@ public class TestSnakeCaseDDL {
final Map<String, Collection<String>> columns = new HashMap<>();
try (final Connection connection = ds.getConnection()) {
try (final ResultSet tables = connection.getMetaData()
.getTables(null, null, "TestSnakeCaseDDL$MyEntity%", null)) {
.getTables(null, null, "SnakeCaseDDLMy%", null)) {
while (tables.next()) {
final String table = tables.getString(3);
createdTables.add(table);
@ -100,7 +100,7 @@ public class TestSnakeCaseDDL {
final EntityManager em = entityManagerFactory.createEntityManager();
em.getTransaction().begin();
try {
final SnakeCaseDDLEntity entity = new SnakeCaseDDLEntity();
final SnakeCaseDDLMy1Entity entity = new SnakeCaseDDLMy1Entity();
entity.setFooBar("1");
entity.setThisField(123);
em.persist(entity);
@ -117,7 +117,7 @@ public class TestSnakeCaseDDL {
{
final EntityManager em = entityManagerFactory.createEntityManager();
try {
final SnakeCaseDDLEntity myEntity1 = em.find(SnakeCaseDDLEntity.class, "1");
final SnakeCaseDDLMy1Entity myEntity1 = em.find(SnakeCaseDDLMy1Entity.class, "1");
assertNotNull(myEntity1);
assertEquals("1", myEntity1.getFooBar());
assertEquals(123, myEntity1.getThisField());
@ -127,7 +127,7 @@ public class TestSnakeCaseDDL {
}
try (final Connection connection = ds.getConnection();
final Statement statement = connection.createStatement();
final ResultSet rs = statement.executeQuery("select foo_bar, this_field from \"TestSnakeCaseDDL$MyEntity1\"")) {
final ResultSet rs = statement.executeQuery("select foo_bar, this_field from \"SnakeCaseDDLMy1Entity\"")) {
assertTrue (rs.next());
assertEquals("1", rs.getString(1));
assertEquals(123, rs.getInt(2));
@ -137,10 +137,10 @@ public class TestSnakeCaseDDL {
entityManagerFactory.close();
}
ds.close();
assertEquals(2, columns.get("TestSnakeCaseDDL$MyEntity1").size());
assertTrue(columns.get("TestSnakeCaseDDL$MyEntity1").contains("FOO_BAR"));
assertTrue(columns.get("TestSnakeCaseDDL$MyEntity1").contains("THIS_FIELD"));
assertEquals(singleton("ANOTHER_FIELD"), columns.get("TestSnakeCaseDDL$MyEntity2"));
assertEquals(2, columns.get("SnakeCaseDDLMy1Entity").size());
assertTrue(columns.get("SnakeCaseDDLMy1Entity").contains("FOO_BAR"));
assertTrue(columns.get("SnakeCaseDDLMy1Entity").contains("THIS_FIELD"));
assertEquals(singleton("ANOTHER_FIELD"), columns.get("SnakeCaseDDLMy2Entity"));
}
}

View File

@ -24,7 +24,7 @@ import jakarta.persistence.Table;
@Entity
@Table(name = "Inner2")
public class TestEJBLobsInner2Entity implements Serializable {
public class EJBLobsInner2Entity implements Serializable {
private static final long serialVersionUID = 1L;
@Id
public String string = null;

View File

@ -24,7 +24,7 @@ import jakarta.persistence.Table;
@Entity
@Table(name = "inntable")
public class TestEJBLobsInnerEntity {
public class EJBLobsInnerEntity {
@Id
private String string = null;
@ -32,7 +32,7 @@ public class TestEJBLobsInnerEntity {
private Object eblob = null;
@OneToOne(cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
private TestEJBLobsInner2Entity blobField = null;
private EJBLobsInner2Entity blobField = null;
public String getString() {
return string;
@ -58,11 +58,11 @@ public class TestEJBLobsInnerEntity {
eblob = val;
}
public TestEJBLobsInner2Entity getBlob() {
public EJBLobsInner2Entity getBlob() {
return blobField;
}
public void setBlob(TestEJBLobsInner2Entity val) {
public void setBlob(EJBLobsInner2Entity val) {
blobField = val;
}
}

View File

@ -25,7 +25,7 @@ import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
public class TestEJBLobs extends AbstractTestCase {
private EntityManager _pm = null;
private TestEJBLobsInnerEntity _inner = null;
private EJBLobsInnerEntity _inner = null;
public TestEJBLobs(String name) {
super(name, "kernelcactusapp");
@ -33,7 +33,7 @@ public class TestEJBLobs extends AbstractTestCase {
@Override
public void setUp() throws Exception {
super.setUp(TestEJBLobsInnerEntity.class, TestEJBLobsInner2Entity.class);
super.setUp(EJBLobsInnerEntity.class, EJBLobsInner2Entity.class);
EntityManager em = currentEntityManager();
startTx(em);
@ -41,12 +41,12 @@ public class TestEJBLobs extends AbstractTestCase {
endTx(em);
endEm(em);
TestEJBLobsInnerEntity inner = new TestEJBLobsInnerEntity();
EJBLobsInnerEntity inner = new EJBLobsInnerEntity();
inner.setString("string");
inner.setClob("clobField");
inner.setEBlob("eblob");
TestEJBLobsInner2Entity inner2 = new TestEJBLobsInner2Entity();
EJBLobsInner2Entity inner2 = new EJBLobsInner2Entity();
inner2.string = "inner2";
inner.setBlob(inner2);
@ -64,7 +64,7 @@ public class TestEJBLobs extends AbstractTestCase {
endEm(_pm);
_pm = currentEntityManager();
_inner = _pm.find(TestEJBLobsInnerEntity.class, "string");
_inner = _pm.find(EJBLobsInnerEntity.class, "string");
}
public void testOtherFields() {
@ -91,13 +91,13 @@ public class TestEJBLobs extends AbstractTestCase {
}
public void testDelete() {
deleteAll(TestEJBLobsInnerEntity.class);
deleteAll(EJBLobsInnerEntity.class);
}
public void testUpdate() {
startTx(_pm);
_inner.setClob("newvalue");
TestEJBLobsInner2Entity inner2 = new TestEJBLobsInner2Entity();
EJBLobsInner2Entity inner2 = new EJBLobsInner2Entity();
inner2.string = "newinner2";
_inner.setBlob(inner2);
endTx(_pm);

View File

@ -113,8 +113,8 @@
<class>org.apache.openjpa.persistence.kernel.common.apps.SingleIdString</class>
<class>org.apache.openjpa.persistence.kernel.common.apps.SingleIdWrapper</class>
<class>org.apache.openjpa.persistence.kernel.common.apps.ValueStrategyPC</class>
<class>org.apache.openjpa.persistence.kernel.TestEJBLobsInnerEntity</class>
<class>org.apache.openjpa.persistence.kernel.TestEJBLobsInner2Entity</class>
<class>org.apache.openjpa.persistence.kernel.EJBLobsInnerEntity</class>
<class>org.apache.openjpa.persistence.kernel.EJBLobsInner2Entity</class>
<class>org.apache.openjpa.persistence.kernel.StaticInnerClassesContainer.Inner</class>
<class>org.apache.openjpa.persistence.kernel.TestEJBNoPersistentFieldsNholderEntity</class>
<class>org.apache.openjpa.persistence.kernel.EJBNoPersistentFieldsNoPersistentFieldsPCEntity</class>