Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rewrite WDF test TestSequence.testAllocSize
The test
org.eclipse.persistence.testing.tests.wdf.jpa1.generator.TestSequence.testAllocSize
made incorrect assumptions on implementation details and therefore
failed. This change changes the test implementation.

The new test is no longer skipped on Oracle and MaxDB platforms.
However, it is skipped when executed inside an application server.

Signed-off-by: Sabine Heider <sabine.heider@sap.com>
  • Loading branch information
sabineheider committed Feb 18, 2013
1 parent 8ec8b93 commit b720c1e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
Expand Up @@ -93,6 +93,21 @@
<property name="eclipselink.jdbc.batch-writing" value="JDBC"/>
</properties>
</persistence-unit>

<persistence-unit name="jpa1testmodel-2" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<non-jta-data-source>%%data-source-name%%</non-jta-data-source>
<class>org.eclipse.persistence.testing.models.wdf.jpa1.fancy.Animal</class>
<class>org.eclipse.persistence.testing.models.wdf.jpa1.fancy.Element</class>
<class>org.eclipse.persistence.testing.models.wdf.jpa1.fancy.Plant</class>

<exclude-unlisted-classes>true</exclude-unlisted-classes>
<shared-cache-mode>ENABLE_SELECTIVE</shared-cache-mode>
<properties>
<property name="eclipselink.target-database" value="%%database-platform%%"/>
</properties>
</persistence-unit>

<!--
<persistence-unit name="jpa1testmodel_jta">
<description>ATS Test Persistence Unit</description>
Expand Down
Expand Up @@ -69,7 +69,7 @@ public abstract class AbstractBaseTest {
private final JPAEnvironment environment;
private final String puName;
private final static DataSource dataSource;
private final static Map EMF_PROPERTIES;
protected final static Map EMF_PROPERTIES;

private static boolean seesJPA2 = (LockModeType.values().length > 2);

Expand Down
Expand Up @@ -14,6 +14,9 @@
package org.eclipse.persistence.testing.tests.wdf.jpa1.generator;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

import junit.framework.Assert;

Expand Down Expand Up @@ -76,18 +79,22 @@ public void testPersistFlock() {
}

@Test
@Skip(databases = {MySQLPlatform.class, SQLServerPlatform.class, DerbyPlatform.class})
@ToBeInvestigated(databases = OraclePlatform.class, databaseNames = "org.eclipse.persistence.platform.database.MaxDBPlatform")
// adjust test
@Skip(server=true, databases = {MySQLPlatform.class, SQLServerPlatform.class, DerbyPlatform.class})
public void testAllocSize() {
JPAEnvironment env = getEnvironment();
EntityManager em = env.getEntityManager();

EntityManagerFactory emf2 = Persistence.createEntityManagerFactory("jpa1testmodel-2", EMF_PROPERTIES);
EntityManager em2 = emf2.createEntityManager();

try {
em.getTransaction().begin();
em2.getTransaction().begin();

final Plant tree = new Plant("tree");
final Element water = new Element("water");
em.persist(tree); // id 1
em.persist(water); // id 4
em2.persist(water); // id 4
Assert.assertEquals("wrong allocation", ((int) tree.getId() + 3), ((int) water.getId()));
final Plant flower = new Plant("flower");
final Plant grass = new Plant("grass");
Expand All @@ -97,11 +104,18 @@ public void testAllocSize() {
em.persist(bush); // id 7
Assert.assertEquals("wrong allocation", ((int) water.getId() + 3), ((int) bush.getId()));
em.getTransaction().commit();
em2.getTransaction().commit();
} finally {
if (em.getTransaction().isActive()) {
em.getTransaction().rollback();
}
em.close();
if (em2.getTransaction().isActive()) {
em2.getTransaction().rollback();
}
em2.close();
emf2.close();
}
}

}

0 comments on commit b720c1e

Please sign in to comment.