mirror of https://github.com/apache/openjpa.git
Testcase updates for Sybase
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1021522 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
abf397a513
commit
a99e618f5a
|
@ -46,8 +46,8 @@ import javax.persistence.criteria.Subquery;
|
|||
import javax.persistence.metamodel.EntityType;
|
||||
import javax.persistence.metamodel.Metamodel;
|
||||
|
||||
import org.apache.openjpa.jdbc.sql.AbstractSQLServerDictionary;
|
||||
import org.apache.openjpa.jdbc.sql.OracleDictionary;
|
||||
import org.apache.openjpa.jdbc.sql.SQLServerDictionary;
|
||||
import org.apache.openjpa.persistence.test.AllowFailure;
|
||||
|
||||
/**
|
||||
|
@ -1568,12 +1568,12 @@ public class TestTypesafeCriteria extends CriteriaTest {
|
|||
String jpql = "select c.accountNum*10.32597 from Customer c where c.id=10";
|
||||
long accountNumber = 1234516279;
|
||||
|
||||
if (getDictionary() instanceof SQLServerDictionary) {
|
||||
if (getDictionary() instanceof AbstractSQLServerDictionary) {
|
||||
// @AllowFailure
|
||||
// TODO - Skipping for MSSQL, as the calculation result has a precision larger than 38
|
||||
// TODO - Skipping for MSSQL & Sybase, as the calculation result has a precision larger than 38
|
||||
// params=(BigDecimal) 10.3259699999999998709654391859658062458038330078125
|
||||
getEntityManagerFactory().getConfiguration().getLog("test").warn(
|
||||
"SKIPPING testBigDecimalConversion() for SQLServer");
|
||||
"SKIPPING testBigDecimalConversion() for SQLServer & Sybase");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.EntityTransaction;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.openjpa.event.TransactionEvent;
|
||||
import org.apache.openjpa.event.TransactionListener;
|
||||
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
|
||||
|
@ -107,12 +108,10 @@ public class TestBeforeCommit extends AbstractPersistenceTestCase implements Tra
|
|||
ae = doQuery(em);
|
||||
if (dict instanceof OracleDictionary) {
|
||||
assertNull(ae.getName());
|
||||
}
|
||||
else if (dict instanceof SybaseDictionary) {
|
||||
} else if (dict instanceof SybaseDictionary) {
|
||||
// Sybase converts "" to " "
|
||||
assertEquals(" ", ae.getName());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
assertEquals("", ae.getName());
|
||||
}
|
||||
assertEquals(1, ae.getVersion());
|
||||
|
@ -124,15 +123,23 @@ public class TestBeforeCommit extends AbstractPersistenceTestCase implements Tra
|
|||
// when BeforeCommit was fired AE was not managed. As a result its state is out of sync with the database.
|
||||
assertEquals("Ava", ae.getName());
|
||||
ae = doQuery(em);
|
||||
if (dict instanceof OracleDictionary)
|
||||
if (dict instanceof OracleDictionary) {
|
||||
assertNull(ae.getName());
|
||||
else
|
||||
} else if (dict instanceof SybaseDictionary) {
|
||||
assertEquals(" ", ae.getName());
|
||||
} else {
|
||||
assertEquals("", ae.getName());
|
||||
}
|
||||
assertEquals(1, ae.getVersion());
|
||||
}
|
||||
|
||||
public void beforeCommit(TransactionEvent event) {
|
||||
ae.setName(ae.getName() == null ? "Ava" : ae.getName()+ "Ava");
|
||||
if(StringUtils.isBlank(ae.getName())) {
|
||||
ae.setName("Ava");
|
||||
}
|
||||
else {
|
||||
ae.setName(ae.getName() + "Ava");
|
||||
}
|
||||
}
|
||||
|
||||
private AnEntity doQuery(EntityManager em) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import javax.persistence.RollbackException;
|
|||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.apache.openjpa.jdbc.sql.SybaseDictionary;
|
||||
import org.apache.openjpa.persistence.kernel.common.apps.Blobs;
|
||||
import org.apache.openjpa.persistence.kernel.common.apps.Lobs;
|
||||
import org.apache.openjpa.persistence.test.SingleEMFTestCase;
|
||||
|
@ -83,7 +84,7 @@ public class TestLobs extends SingleEMFTestCase {
|
|||
em.close();
|
||||
}
|
||||
|
||||
public void testBlobZeroLengthByteArray() {
|
||||
public void testBlobZeroLengthByteArray() throws Exception {
|
||||
// test with 0 length bytes
|
||||
byte[] bytes = new byte[0];
|
||||
EntityManager em = emf.createEntityManager();
|
||||
|
@ -93,7 +94,16 @@ public class TestLobs extends SingleEMFTestCase {
|
|||
lobs.setLobNotNullable(bytes);
|
||||
lobs.setLobNullable(bytes);
|
||||
em.persist(lobs);
|
||||
try {
|
||||
em.getTransaction().commit();
|
||||
} catch (Exception e) {
|
||||
if (getDBDictionary() instanceof SybaseDictionary) {
|
||||
assertTrue(e instanceof RollbackException);
|
||||
return;
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
em.close();
|
||||
|
||||
em = emf.createEntityManager();
|
||||
|
@ -192,8 +202,23 @@ public class TestLobs extends SingleEMFTestCase {
|
|||
em.getTransaction().begin();
|
||||
Query query = em.createQuery("select e from Lobs e");
|
||||
lobs = (Lobs)query.getSingleResult();
|
||||
assertTrue(lobs.getLobNullable() == null || lobs.getLobNullable().length() == 0);
|
||||
assertTrue(lobs.getLobNotNullable() == null || lobs.getLobNotNullable().length() == 0);
|
||||
|
||||
if (lobs.getLobNullable() != null) {
|
||||
if (getDBDictionary() instanceof SybaseDictionary) {
|
||||
// Sybase stores empty strings as " "
|
||||
assertEquals(" ", lobs.getLobNullable());
|
||||
} else {
|
||||
assertEquals(0, lobs.getLobNullable().length());
|
||||
}
|
||||
}
|
||||
if (lobs.getLobNotNullable() != null) {
|
||||
if (getDBDictionary() instanceof SybaseDictionary) {
|
||||
// Sybase stores empty strings as " "
|
||||
assertEquals(" ", lobs.getLobNotNullable());
|
||||
} else {
|
||||
assertEquals(0, lobs.getLobNotNullable().length());
|
||||
}
|
||||
}
|
||||
assertEquals(lobs.getLobNullable(), lobs.getLobNotNullable());
|
||||
em.remove(lobs);
|
||||
em.getTransaction().commit();
|
||||
|
|
|
@ -95,7 +95,7 @@ public class TestSpec10_1_27_Ex4 extends SQLListenerTestCase {
|
|||
setCandidate(q, Company.class);
|
||||
rs = q.getResultList();
|
||||
Map.Entry me = (Map.Entry) rs.get(0);
|
||||
assertTrue(d.equals(me.getKey()));
|
||||
assertEquals(d, me.getKey());
|
||||
|
||||
em.clear();
|
||||
query = "select KEY(e) from Company c " +
|
||||
|
|
Loading…
Reference in New Issue