Add test case with manual set ID
If an ID is manually set before saving, it should neither be duplicated nor overwritten.
diff --git a/org.eclipse.bpmn2.tests/src/org/eclipse/bpmn2/tests/XMLSerializationTest.java b/org.eclipse.bpmn2.tests/src/org/eclipse/bpmn2/tests/XMLSerializationTest.java
index f804942..c663211 100644
--- a/org.eclipse.bpmn2.tests/src/org/eclipse/bpmn2/tests/XMLSerializationTest.java
+++ b/org.eclipse.bpmn2.tests/src/org/eclipse/bpmn2/tests/XMLSerializationTest.java
@@ -36,6 +36,7 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.xml.sax.SAXParseException;
/**
* Tests serialization as XML.
@@ -230,4 +231,19 @@
throw e;
}
}
+
+ @Test
+ public void testIDAlreadySet() throws Exception {
+ model.setId("id1");
+ Resource res = null;
+ try {
+ res = createWithContentAndLoad("idAlreadySet", model);
+ } catch (WrappedException e) {
+ if (e.exception() instanceof SAXParseException)
+ fail("Duplicate attribute 'id'.");
+ else
+ throw e;
+ }
+ assertEquals("id1", getRootDefinitionElement(res).getId());
+ }
}