public void testRun() throws Exception {
final TestHandler handler=new TestHandler();
ILayer layer = handler.getContext().getMapLayers().get(0);
FeatureSource<SimpleFeatureType, SimpleFeature> resource = layer.getResource(FeatureSource.class, null);
SimpleFeature feature = resource.getFeatures().features().next();
IEditManager editManager = handler.getContext().getEditManager();
((EditManager)editManager).setEditFeature(feature, (Layer) layer);
EditBlackboard editBlackboard = handler.getEditBlackboard();
PrimitiveShape shell = editBlackboard.getGeoms().get(0).getShell();
editBlackboard.addPoint(100,100,shell);
shell.getEditGeom().setShapeType(ShapeType.POINT);
editBlackboard.newGeom("newone", null); //$NON-NLS-1$
StartEditingBehaviour behav=new StartEditingBehaviour(ShapeType.POLYGON);
handler.getBehaviours().add(behav);
assertNotNull( editManager.getEditFeature());
handler.setTesting(false);
MapMouseEvent event = new MapMouseEvent(null, 10,10, MapMouseEvent.NONE, MapMouseEvent.NONE, MapMouseEvent.BUTTON1);
handler.handleEvent(event, EventType.RELEASED);
try{
PlatformGIS.wait(200, 200, WaitCondition.FALSE_CONDITION, null);
}catch (Exception e) {
// its expected
}
assertEquals(1, handler.getEditBlackboard().getGeoms().size());
((CommandManager)((Map)handler.getContext().getMap()).getCommandStack()).undo(false);
assertEquals("Is the feature ID equal", feature.getID(), editManager.getEditFeature().getID());
assertEquals("Is the feature equal", feature, editManager.getEditFeature());
assertFalse( handler.isLocked() );
assertEquals(2, editBlackboard.getGeoms().size());
assertEquals(ShapeType.POINT, editBlackboard.getGeoms().get(0).getShapeType());
assertEquals(Point.valueOf(100,100), editBlackboard.getGeoms().get(0).getShell().getPoint(0));