use of org.jpox.samples.rdbms.types.DB2Types in project tests by datanucleus.
the class TypesMappingTest method testDB2DataLinkType.
/**
* Test for DB2 datastore "DATALINK" type.
*/
public void testDB2DataLinkType() {
if (!vendorID.equals("db2")) {
return;
}
DB2Types types;
Object id = null;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
types = new DB2Types();
types.setDataLinkString("http://www.jpox.org");
types.setDataLinkString2("http://www.someurl.org/path");
types.setSimpleString("some string");
pm.makePersistent(types);
id = JDOHelper.getObjectId(types);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
types = (DB2Types) pm.getObjectById(id, true);
assertEquals("DataLinkString retrieved is wrong", "http://www.jpox.org".toUpperCase(), types.getDataLinkString().toUpperCase());
assertEquals("DataLinkString2 retrieved is wrong", "/path".toUpperCase(), types.getDataLinkString2().toUpperCase());
assertEquals("Simple String retrieved is wrong", "some string", types.getSimpleString());
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
types = (DB2Types) ((Collection) pm.newQuery(DB2Types.class).execute()).iterator().next();
assertEquals("DataLinkString retrieved from Query is wrong", "http://www.jpox.org".toUpperCase(), types.getDataLinkString().toUpperCase());
assertEquals("DataLinkString2 retrieved from Query is wrong", "/path".toUpperCase(), types.getDataLinkString2().toUpperCase());
assertEquals("Simple String retrieved from Query is wrong", "some string", types.getSimpleString());
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations