public void testTransactionUse() throws Exception {
IGeoResource resource1 = MapTests.createGeoResource(UDIGTestUtil.createDefaultTestFeatures(
"type1", 4), false); //$NON-NLS-1$
Map map = MapTests.createNonDynamicMapAndRenderer(resource1, new Dimension(512,512));
ILayer layer = map.getLayersInternal().get(0);
EditManager manager = (EditManager) layer.getMap().getEditManager();
//wrapper/decorator
FeatureStore<SimpleFeatureType, SimpleFeature> store = layer.getResource(FeatureStore.class, new NullProgressMonitor());
//we are in read mode, so the wrapper doesn't delegate to the transaction
assertTrue(store.getTransaction() == Transaction.AUTO_COMMIT);
//read, bounds doesn't start a transaction
store.getBounds();
assertTrue(store.getTransaction() == Transaction.AUTO_COMMIT);
//start editing
store.removeFeatures(Filter.EXCLUDE);
assertTrue(store.getTransaction() != Transaction.AUTO_COMMIT);
//read keeps transaction open
store.getFeatures();
assertTrue(store.getTransaction() != Transaction.AUTO_COMMIT);
//rollback stops
manager.rollbackTransaction();
assertTrue(store.getTransaction() == Transaction.AUTO_COMMIT);
//remove starts again
store.removeFeatures(Filter.INCLUDE);
assertTrue(store.getTransaction() != Transaction.AUTO_COMMIT);
//done
manager.commitTransaction();
assertTrue(store.getTransaction() == Transaction.AUTO_COMMIT);
}