use of org.datanucleus.samples.jtsgeometry.SampleLinearRing in project tests by datanucleus.
the class JtsGeometryMappingTest method testLinearRingMapping.
public void testLinearRingMapping() throws SQLException, ParseException {
if (!runTestsForDatastore()) {
return;
}
LinearRing linearRing = (LinearRing) wktReader.read("LINEARRING(0 0,10 0,10 10,0 10,0 0)");
SampleLinearRing sampleLinearRing;
SampleLinearRing sampleLinearRing_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
sampleLinearRing = new SampleLinearRing(2101, "LinearRing", linearRing);
pm.makePersistent(sampleLinearRing);
id = JDOHelper.getObjectId(sampleLinearRing);
sampleLinearRing = (SampleLinearRing) pm.detachCopy(sampleLinearRing);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
sampleLinearRing_read = (SampleLinearRing) pm.getObjectById(id, true);
assertEquals(sampleLinearRing, sampleLinearRing_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations