use of org.datanucleus.samples.jtsgeometry.SamplePolygon in project tests by datanucleus.
the class JtsGeometryMappingTest method testPolygonMapping.
public void testPolygonMapping() throws SQLException, ParseException {
if (!runTestsForDatastore()) {
return;
}
Polygon polygon = (Polygon) wktReader.read("POLYGON((25 25,75 25,75 75,25 75,25 25),(45 45,55 45,55 55,45 55,45 45))");
SamplePolygon samplePolygon;
SamplePolygon samplePolygon_read;
PersistenceManager pm = pmf.getPersistenceManager();
Transaction tx = pm.currentTransaction();
Object id = null;
try {
tx.begin();
samplePolygon = new SamplePolygon(3001, "Polygon 1", polygon);
pm.makePersistent(samplePolygon);
id = JDOHelper.getObjectId(samplePolygon);
samplePolygon = (SamplePolygon) pm.detachCopy(samplePolygon);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
pm = pmf.getPersistenceManager();
tx = pm.currentTransaction();
try {
tx.begin();
samplePolygon_read = (SamplePolygon) pm.getObjectById(id, true);
assertEquals(samplePolygon, samplePolygon_read);
tx.commit();
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
}
Aggregations