diff options
author | Mark Brörkens | 2013-06-13 12:30:26 +0000 |
---|---|---|
committer | Mark Brörkens | 2013-06-13 12:30:26 +0000 |
commit | 0a0d35fa4313a7e29d589e0263ea63289a5fd5e6 (patch) | |
tree | 5fcb7abc5cdef1ec962c6ee32637b0641b7bec3a | |
parent | f6e7841d13960e248681408f8c44dbd20ecb846e (diff) | |
download | org.eclipse.rmf-0a0d35fa4313a7e29d589e0263ea63289a5fd5e6.tar.gz org.eclipse.rmf-0a0d35fa4313a7e29d589e0263ea63289a5fd5e6.tar.xz org.eclipse.rmf-0a0d35fa4313a7e29d589e0263ea63289a5fd5e6.zip |
ASSIGNED - bug 376942: Third-Party Tool Extensions not handled correctly
https://bugs.eclipse.org/bugs/show_bug.cgi?id=376942
added serialization and desirialization test cases
28 files changed, 475 insertions, 167 deletions
diff --git a/org.eclipse.rmf.docs.requirements/.externalToolBuilders/org.eclipse.rmf.docs.requirements.launch b/org.eclipse.rmf.docs.requirements/.externalToolBuilders/org.eclipse.rmf.docs.requirements.launch index f4b9ca11..bbaa269c 100644 --- a/org.eclipse.rmf.docs.requirements/.externalToolBuilders/org.eclipse.rmf.docs.requirements.launch +++ b/org.eclipse.rmf.docs.requirements/.externalToolBuilders/org.eclipse.rmf.docs.requirements.launch @@ -11,7 +11,7 @@ <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value=""/> <booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/> -<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/org.eclipse.rmf.examples.installer/examples/org.eclipse.rmf.docs.requirements/" type="2"/> <item path="/org.eclipse.rmf.docs.requirements/.externalToolBuilders" type="2"/> <item path="/org.eclipse.rmf.docs.requirements/.gitignore" type="1"/> <item path="/org.eclipse.rmf.docs.requirements/.project" type="1"/> <item path="/org.eclipse.rmf.docs.requirements/RMF_CustomerRequirementsSpecification.reqif" type="1"/> <item path="/org.eclipse.rmf.docs.requirements/RMF_SoftwareRequirementsSpecification.reqif" type="1"/> </resources>}"/> +<stringAttribute key="org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE" value="${working_set:<?xml version="1.0" encoding="UTF-8"?> <resources> <item path="/org.eclipse.rmf.examples.installer/examples/org.eclipse.rmf.docs.requirements/" type="2"/> <item path="/org.eclipse.rmf.docs.requirements/.externalToolBuilders" type="2"/> <item path="/org.eclipse.rmf.docs.requirements/.gitignore" type="1"/> <item path="/org.eclipse.rmf.docs.requirements/.project" type="1"/> <item path="/org.eclipse.rmf.docs.requirements/RMF_CustomerRequirementsSpecification.reqif" type="1"/> <item path="/org.eclipse.rmf.docs.requirements/RMF_SoftwareRequirementsSpecification.reqif" type="1"/> <item path="/org.eclipse.rmf.docs.requirements/RMF_SoftwareSpecification.reqif" type="1"/> </resources>}"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${project_loc:/org.eclipse.rmf.docs.requirements}/.externalToolBuilders/copyExample.ant"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-Dbuild.project=${project_loc:/org.eclipse.rmf.docs.requirements}"/> diff --git a/org.eclipse.rmf.examples.installer/examples/org.eclipse.rmf.docs.requirements/RMF_SoftwareSpecification.reqif b/org.eclipse.rmf.examples.installer/examples/org.eclipse.rmf.docs.requirements/RMF_SoftwareSpecification.reqif index 4fcd2f09..2de5900d 100644 --- a/org.eclipse.rmf.examples.installer/examples/org.eclipse.rmf.docs.requirements/RMF_SoftwareSpecification.reqif +++ b/org.eclipse.rmf.examples.installer/examples/org.eclipse.rmf.docs.requirements/RMF_SoftwareSpecification.reqif @@ -40,7 +40,7 @@ <DATATYPE-DEFINITION-STRING IDENTIFIER="rmf-95898f85-f196-475f-8d35-f8db9d9e2dd0" LONG-NAME="T_Headline_String32k" MAX-LENGTH="32000"/> </DATATYPES> <SPEC-TYPES> - <SPEC-OBJECT-TYPE IDENTIFIER="rmf-e7aa3d46-6556-45bd-969b-d7534fa97ad1" LONG-NAME="Requirement Type"> + <SPEC-OBJECT-TYPE IDENTIFIER="rmf-e7aa3d46-6556-45bd-969b-d7534fa97ad1" LONG-NAME="Spec Item Type"> <SPEC-ATTRIBUTES> <ATTRIBUTE-DEFINITION-STRING IDENTIFIER="rmf-150a04f0-8369-4faa-b884-b1477b1764e8" LONG-NAME="Description" IS-EDITABLE="true"> <TYPE> @@ -107,6 +107,30 @@ </ATTRIBUTE-DEFINITION-STRING> </SPEC-ATTRIBUTES> </SPEC-OBJECT-TYPE> + <SPEC-OBJECT-TYPE IDENTIFIER="rmf-f9375e1b-668c-4625-8ade-bc061ba737ef" LONG-NAME="Reference Type"> + <SPEC-ATTRIBUTES> + <ATTRIBUTE-DEFINITION-STRING IDENTIFIER="rmf-19b3693b-4688-4a80-b67f-fa01171fdcd3" LONG-NAME="Author" IS-EDITABLE="true"> + <TYPE> + <DATATYPE-DEFINITION-STRING-REF>rmf-fa6300d0-9e8b-4b57-a6ff-10a6bc76e604</DATATYPE-DEFINITION-STRING-REF> + </TYPE> + </ATTRIBUTE-DEFINITION-STRING> + <ATTRIBUTE-DEFINITION-STRING IDENTIFIER="rmf-69dda60a-262f-405f-9716-6b35c34d502b" LONG-NAME="Title"> + <TYPE> + <DATATYPE-DEFINITION-STRING-REF>rmf-fa6300d0-9e8b-4b57-a6ff-10a6bc76e604</DATATYPE-DEFINITION-STRING-REF> + </TYPE> + </ATTRIBUTE-DEFINITION-STRING> + <ATTRIBUTE-DEFINITION-STRING IDENTIFIER="rmf-dbae7385-ede7-4feb-a9f7-0307021a2ba3" LONG-NAME="URL" IS-EDITABLE="true"> + <TYPE> + <DATATYPE-DEFINITION-STRING-REF>rmf-fa6300d0-9e8b-4b57-a6ff-10a6bc76e604</DATATYPE-DEFINITION-STRING-REF> + </TYPE> + </ATTRIBUTE-DEFINITION-STRING> + <ATTRIBUTE-DEFINITION-STRING IDENTIFIER="rmf-1495c0d0-d792-47f2-ba70-0d78a979f16a" LONG-NAME="Description"> + <TYPE> + <DATATYPE-DEFINITION-STRING-REF>rmf-fa6300d0-9e8b-4b57-a6ff-10a6bc76e604</DATATYPE-DEFINITION-STRING-REF> + </TYPE> + </ATTRIBUTE-DEFINITION-STRING> + </SPEC-ATTRIBUTES> + </SPEC-OBJECT-TYPE> </SPEC-TYPES> <SPEC-OBJECTS> <SPEC-OBJECT IDENTIFIER="rmf-b4682a3d-17b7-49e3-8703-81175b8fd1ec"> @@ -128,19 +152,19 @@ </SPEC-OBJECT> <SPEC-OBJECT IDENTIFIER="rmf-ec76d21c-6f26-4751-877b-e08cfbc6aee7"> <VALUES> - <ATTRIBUTE-VALUE-STRING THE-VALUE="rmf_5"> + <ATTRIBUTE-VALUE-STRING THE-VALUE="http://www.eclipse.org/edapt/"> <DEFINITION> - <ATTRIBUTE-DEFINITION-STRING-REF>rmf-b029ab42-aeb9-420e-ba50-95038d07b56d</ATTRIBUTE-DEFINITION-STRING-REF> + <ATTRIBUTE-DEFINITION-STRING-REF>rmf-dbae7385-ede7-4feb-a9f7-0307021a2ba3</ATTRIBUTE-DEFINITION-STRING-REF> </DEFINITION> </ATTRIBUTE-VALUE-STRING> - <ATTRIBUTE-VALUE-STRING THE-VALUE=""> + <ATTRIBUTE-VALUE-STRING THE-VALUE="Edapt - Framework for Ecore model adaptation and instance migration"> <DEFINITION> - <ATTRIBUTE-DEFINITION-STRING-REF>rmf-0b23aa34-c242-41a0-9157-6062df61ff98</ATTRIBUTE-DEFINITION-STRING-REF> + <ATTRIBUTE-DEFINITION-STRING-REF>rmf-69dda60a-262f-405f-9716-6b35c34d502b</ATTRIBUTE-DEFINITION-STRING-REF> </DEFINITION> </ATTRIBUTE-VALUE-STRING> </VALUES> <TYPE> - <SPEC-OBJECT-TYPE-REF>rmf-e7aa3d46-6556-45bd-969b-d7534fa97ad1</SPEC-OBJECT-TYPE-REF> + <SPEC-OBJECT-TYPE-REF>rmf-f9375e1b-668c-4625-8ade-bc061ba737ef</SPEC-OBJECT-TYPE-REF> </TYPE> </SPEC-OBJECT> </SPEC-OBJECTS> @@ -178,14 +202,15 @@ <configuration:specViewConfigurations> <configuration:ProrSpecViewConfiguration configuration:specification="rmf-d1e0c2eb-4e9a-4b8a-bdf0-069b011d480e"> <configuration:columns> - <configuration:Column configuration:label="ID" configuration:width="141"/> - <configuration:Column configuration:label="Title" configuration:width="358"/> - <configuration:Column configuration:label="Description" configuration:width="271"/> - <configuration:Column configuration:label="Rationale" configuration:width="246"/> - <configuration:Column configuration:label="Notes" configuration:width="229"/> - <configuration:Column configuration:label="Author" configuration:width="109"/> - <configuration:Column configuration:label="Status" configuration:width="60"/> - <configuration:Column configuration:label="Severity" configuration:width="50"/> + <configuration:Column configuration:label="ID" configuration:width="129"/> + <configuration:Column configuration:label="Title" configuration:width="346"/> + <configuration:Column configuration:label="Description" configuration:width="259"/> + <configuration:Column configuration:label="Rationale" configuration:width="234"/> + <configuration:Column configuration:label="Notes" configuration:width="217"/> + <configuration:Column configuration:label="Author" configuration:width="97"/> + <configuration:Column configuration:label="Status" configuration:width="48"/> + <configuration:Column configuration:label="Severity" configuration:width="38"/> + <configuration:Column configuration:label="URL" configuration:width="196"/> </configuration:columns> <configuration:leftHeaderColumn> <configuration:Column configuration:label="Lead Header Column" configuration:width="30"/> @@ -206,7 +231,7 @@ <configuration:ProrPresentationConfigurations> <configuration:presentationConfigurations> <headline:HeadlineConfiguration configuration:datatype="rmf-95898f85-f196-475f-8d35-f8db9d9e2dd0"/> - <id:IdConfiguration configuration:datatype="rmf-1d2c140f-97e9-4d11-9554-63b2bee2dc3c" id:prefix="rmf_" id:count="5"/> + <id:IdConfiguration configuration:datatype="rmf-1d2c140f-97e9-4d11-9554-63b2bee2dc3c" id:prefix="rmf_" id:count="6"/> </configuration:presentationConfigurations> </configuration:ProrPresentationConfigurations> </configuration:presentationConfigurations> diff --git a/org.eclipse.rmf.releng.target/KEPLER_4_3_0.target b/org.eclipse.rmf.releng.target/KEPLER_4_3_0.target index 41d13ad5..0798bf36 100644 --- a/org.eclipse.rmf.releng.target/KEPLER_4_3_0.target +++ b/org.eclipse.rmf.releng.target/KEPLER_4_3_0.target @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> -<?pde version="3.8"?><target name="KEPLER_4_3_0" sequenceNumber="6"> +<?pde version="3.8"?><target name="KEPLER_4_3_0" sequenceNumber="13"> <locations> <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.sphinx.core.feature.group" version="0.0.0"/> @@ -11,21 +11,27 @@ <repository location="http://agilegrid.sourceforge.net/agilegrid/updatesite-rmf/"/> </location> <location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit"> -<unit id="org.apache.xerces" version="2.9.0.v201101211617"/> -<unit id="com.google.guava" version="12.0.0.v201212092141"/> -<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20130517111416/repository/"/> -</location> -<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit"> <unit id="org.eclipse.jdt.feature.group" version="3.9.0.v20130530-1629"/> +<unit id="org.eclipse.platform.sdk" version="4.3.0.I20130530-1430"/> +<unit id="org.eclipse.rcp.sdk.id" version="4.3.0.I20130530-1430"/> +<unit id="org.eclipse.sdk.ide" version="4.3.0.I20130530-1430"/> <unit id="org.eclipse.emf.sdk.feature.group" version="2.9.0.v20130603-0742"/> -<unit id="org.eclipse.emf.compare.source.feature.group" version="2.1.0.201306041352"/> -<unit id="org.eclipse.emf.compare.ide.ui.source.feature.group" version="2.1.0.201306041352"/> +<unit id="org.eclipse.emf.validation.sdk.feature.group" version="1.7.0.201305212004"/> <unit id="org.eclipse.equinox.compendium.sdk.feature.group" version="3.8.0.v20130515-2026"/> <unit id="org.eclipse.equinox.core.sdk.feature.group" version="3.8.0.v20130529-1710"/> <unit id="org.eclipse.equinox.p2.sdk.feature.group" version="3.8.0.v20130528-2154"/> <unit id="org.eclipse.equinox.sdk.feature.group" version="3.9.0.v20130529-1710"/> +<unit id="org.eclipse.objectteams.otdt.feature.group" version="2.2.0.201306040500"/> +<unit id="org.eclipse.objectteams.otequinox.feature.group" version="2.2.0.201305210612"/> +<unit id="org.eclipse.objectteams.otdt.core.patch.feature.group" version="2.2.0.201306040500"/> <unit id="org.eclipse.xsd.sdk.feature.group" version="2.9.0.v20130603-0742"/> <repository location="http://download.eclipse.org/releases/kepler/"/> </location> +<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit"> +<unit id="org.apache.xerces" version="2.9.0.v201101211617"/> +<unit id="com.google.guava" version="12.0.0.v201212092141"/> +<unit id="org.junit" version="4.11.0.v201303080030"/> +<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20130517111416/repository/"/> +</location> </locations> </target> diff --git a/org.eclipse.rmf.tests.serialization/input/ContainmentReferences/data/RootOnly.xml b/org.eclipse.rmf.tests.serialization/resources/input/ContainmentReferences/data/RootOnly.xml index 2c6ba6d2..2c6ba6d2 100644 --- a/org.eclipse.rmf.tests.serialization/input/ContainmentReferences/data/RootOnly.xml +++ b/org.eclipse.rmf.tests.serialization/resources/input/ContainmentReferences/data/RootOnly.xml diff --git a/org.eclipse.rmf.tests.serialization/input/ContainmentReferences/data/RootWithSingleContainment.xml b/org.eclipse.rmf.tests.serialization/resources/input/ContainmentReferences/data/RootWithSingleContainment.xml index 3c4371dd..3c4371dd 100644 --- a/org.eclipse.rmf.tests.serialization/input/ContainmentReferences/data/RootWithSingleContainment.xml +++ b/org.eclipse.rmf.tests.serialization/resources/input/ContainmentReferences/data/RootWithSingleContainment.xml diff --git a/org.eclipse.rmf.tests.serialization/input/ContainmentReferences/data/RootWithSingleContainment.xml.xmi b/org.eclipse.rmf.tests.serialization/resources/input/ContainmentReferences/data/RootWithSingleContainment.xml.xmi index caee1c93..caee1c93 100644 --- a/org.eclipse.rmf.tests.serialization/input/ContainmentReferences/data/RootWithSingleContainment.xml.xmi +++ b/org.eclipse.rmf.tests.serialization/resources/input/ContainmentReferences/data/RootWithSingleContainment.xml.xmi diff --git a/org.eclipse.rmf.tests.serialization/input/ContainmentReferences/ecore/ContainmentReferences.ecore b/org.eclipse.rmf.tests.serialization/resources/input/ContainmentReferences/ecore/ContainmentReferences.ecore index d0273094..d0273094 100644 --- a/org.eclipse.rmf.tests.serialization/input/ContainmentReferences/ecore/ContainmentReferences.ecore +++ b/org.eclipse.rmf.tests.serialization/resources/input/ContainmentReferences/ecore/ContainmentReferences.ecore diff --git a/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/DocumentRoot.xmi b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/DocumentRoot.xmi new file mode 100644 index 00000000..29116ad6 --- /dev/null +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/DocumentRoot.xmi @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="ASCII"?> +<myreqif:DocumentRoot xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:myreqif="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd" + xsi:schemaLocation="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd ../model/myreqif.ecore"/> diff --git a/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/EPackage.xmi b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/EPackage.xmi new file mode 100644 index 00000000..c2e235a4 --- /dev/null +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/EPackage.xmi @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="ASCII"?> +<ecore:EPackage + xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" + name="Nodes" + nsURI="http//www.eclipse.org/rmf/ext/nodes" + nsPrefix="nodes"> + <eClassifiers + xsi:type="ecore:EClass" + name="Node"> + <eStructuralFeatures + xsi:type="ecore:EReference" + name="children" + upperBound="-1" + eType="//Node"/> + </eClassifiers> +</ecore:EPackage> diff --git a/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/REQIF.xmi b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/REQIF.xmi new file mode 100644 index 00000000..7762c40e --- /dev/null +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/REQIF.xmi @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="ASCII"?> +<myreqif:REQIF + xmi:version="2.0" + xmlns:xmi="http://www.omg.org/XMI" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:myreqif="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd" + xsi:schemaLocation="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd ../model/myreqif.ecore"> + <cORECONTENT> + <rEQIFCONTENT/> + </cORECONTENT> + <tOOLEXTENSIONS> + <rEQIFTOOLEXTENSION/> + </tOOLEXTENSIONS> +</myreqif:REQIF> diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/bare.reqif b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/bare.xml index bc29efc7..bc29efc7 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/bare.reqif +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/bare.xml diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/bareWithSchemaHint.reqif b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/bareWithEcoreHint.xml index f44cf47e..1b5870de 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/bareWithSchemaHint.reqif +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/bareWithEcoreHint.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?>
-<REQ-IF xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd" xsi:schemaLocation="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd input/org.eclipse.rmf.tests.serialization.env/model/myreqif.xsd">
+<REQ-IF xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd" xsi:schemaLocation="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd resources/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.ecore">
<CORE-CONTENT>
<REQ-IF-CONTENT/>
</CORE-CONTENT>
diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/bareWithEcoreHint.reqif b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/bareWithSchemaHint.xml index 5146ea4b..8c90187c 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/bareWithEcoreHint.reqif +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/bareWithSchemaHint.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?>
-<REQ-IF xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd" xsi:schemaLocation="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd input/org.eclipse.rmf.tests.serialization.env/model/myreqif.ecore">
+<REQ-IF xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd" xsi:schemaLocation="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd resources/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.xsd">
<CORE-CONTENT>
<REQ-IF-CONTENT/>
</CORE-CONTENT>
diff --git a/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/bare_toolExtensions_AnyTypeAndEcoreType.xml b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/bare_toolExtensions_AnyTypeAndEcoreType.xml new file mode 100644 index 00000000..ad18978a --- /dev/null +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/bare_toolExtensions_AnyTypeAndEcoreType.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<REQ-IF xmlns="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd"
+ xmlns:ext="http://www.eclipse.org/rmf/myExtension" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <CORE-CONTENT>
+ <REQ-IF-CONTENT/>
+ </CORE-CONTENT>
+ <TOOL-EXTENSIONS>
+ <REQ-IF-TOOL-EXTENSION>
+ <ext:myExtension xmlns="http://www.eclipse.org/rmf/myExtension"></ext:myExtension>
+ <ecore:ePackage xsi:type="ecore:EPackage" name="Nodes"
+ nsURI="http//www.eclipse.org/rmf/ext/nodes" nsPrefix="nodes">
+ <ecore:eClassifiers xsi:type="ecore:EClass" name="Node">
+ <ecore:eStructuralFeatures xsi:type="ecore:EReference"
+ name="children" upperBound="-1"/>
+ </ecore:eClassifiers>
+ </ecore:ePackage>
+ </REQ-IF-TOOL-EXTENSION>
+ </TOOL-EXTENSIONS>
+</REQ-IF>
\ No newline at end of file diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/simple.reqif b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/simple.xml index 44ccf6d2..44ccf6d2 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/simple.reqif +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/simple.xml diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/toolExtensions.reqif b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/simple_toolExtensions.xml index 9ce61517..9ce61517 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/toolExtensions.reqif +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/simple_toolExtensions.xml diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/toolExtensions_redefinedNsPrefix.reqif b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/simple_toolExtensions_redefinedNsPrefix.xml index e029c434..5a3436ed 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/toolExtensions_redefinedNsPrefix.reqif +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/simple_toolExtensions_redefinedNsPrefix.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?>
-<REQ-IF xmlns="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd" xmlns:ext="http://www.eclipse.org/rmf/myExtension">
+<REQ-IF xmlns="http://www.eclipse.org/rmf/tests/serialization/env/myreqif.xsd">
<THE-HEADER>
<REQ-IF-HEADER IDENTIFIER="a">
<CREATION-TIME>2005-05-23T12:00:00+02:00</CREATION-TIME>
diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/toolExtensions_xsiType.reqif b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/simple_toolExtensions_xsiType.xml index 26507e37..26507e37 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/data/toolExtensions_xsiType.reqif +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/data/simple_toolExtensions_xsiType.xml diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.ecore b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.ecore index eb67c7b6..eb67c7b6 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.ecore +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.ecore diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.genmodel b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.genmodel index 0edc96b3..0edc96b3 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.genmodel +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.genmodel diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.xsd b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.xsd index ddc3fd41..ddc3fd41 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.xsd +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/model/myreqif.xsd diff --git a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/model/xml.xsd b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/model/xml.xsd index aea7d0db..aea7d0db 100644 --- a/org.eclipse.rmf.tests.serialization/input/org.eclipse.rmf.tests.serialization.env/model/xml.xsd +++ b/org.eclipse.rmf.tests.serialization/resources/input/org.eclipse.rmf.tests.serialization.env/model/xml.xsd diff --git a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/AbstractEMFTestCase.java b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/AbstractEMFTestCase.java new file mode 100644 index 00000000..db200fcf --- /dev/null +++ b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/AbstractEMFTestCase.java @@ -0,0 +1,10 @@ +package org.eclipse.rmf.tests.serialization.env.emf; + +import java.util.HashMap; + +import org.eclipse.sphinx.testutils.AbstractTestCase; + +public abstract class AbstractEMFTestCase extends AbstractTestCase { + private static HashMap<String, Object> backupRegistry = new HashMap<String, Object>(); + +} diff --git a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFDeserializationTests.java b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFDeserializationTests.java index 819a79f8..634a1aba 100644 --- a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFDeserializationTests.java +++ b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFDeserializationTests.java @@ -33,6 +33,8 @@ import org.eclipse.rmf.tests.serialization.env.emf.myreqif.CORECONTENTType; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.DocumentRoot; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.MyreqifPackage; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.REQIF; +import org.eclipse.rmf.tests.serialization.env.emf.myreqif.REQIFTOOLEXTENSION; +import org.eclipse.rmf.tests.serialization.env.emf.myreqif.TOOLEXTENSIONSType; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.util.MyreqifResourceFactoryImpl; import org.eclipse.xsd.XSDPackage; import org.eclipse.xsd.ecore.XSDEcoreBuilder; @@ -44,23 +46,24 @@ import org.junit.Test; @SuppressWarnings("nls") public class EMFDeserializationTests { - public static final String DATA_BASEDIR = "input/org.eclipse.rmf.tests.serialization.env/data/"; //$NON-NLS-1$ - public static final String MODEL_BASEDIR = "input/org.eclipse.rmf.tests.serialization.env/model/"; //$NON-NLS-1$ + public static final String DATA_BASEDIR = "resources/input/org.eclipse.rmf.tests.serialization.env/data/"; + public static final String MODEL_BASEDIR = "resources/input/org.eclipse.rmf.tests.serialization.env/model/"; + private static HashMap<String, Object> backupRegistry = new HashMap<String, Object>(); @BeforeClass - public static void backupPackageRegistry() { + public static void setupOnce() { backupRegistry = new HashMap<String, Object>(); backupRegistry.putAll(EPackage.Registry.INSTANCE); } @Before - public void beforeTestCase() { + public void setUp() { EPackage.Registry.INSTANCE.clear(); } @AfterClass - public static void restorePackageRegistry() { + public static void tearDownOnce() { EPackage.Registry.INSTANCE.clear(); EPackage.Registry.INSTANCE.putAll(backupRegistry); } @@ -72,15 +75,39 @@ public class EMFDeserializationTests { */ @Test - public void positiveloadResourceWithPreregisteredGeneratedPackage() throws IOException { - String fileName = DATA_BASEDIR + "bare.reqif"; //$NON-NLS-1$ + public void testPositiveloadResourceWithPreregisteredGeneratedPackage() throws IOException { + String fileName = DATA_BASEDIR + "bare.xml"; + + // prepare resource set + ResourceSet resourceSet = new ResourceSetImpl(); + EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); + EPackage.Registry.INSTANCE.put(XMLNamespacePackage.eNS_URI, XMLNamespacePackage.eINSTANCE); + resourceSet.getPackageRegistry().put(MyreqifPackage.eNS_URI, MyreqifPackage.eINSTANCE); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new MyreqifResourceFactoryImpl()); + + // load data + URI emfURI = URI.createURI(fileName, true); + Resource resource = resourceSet.createResource(emfURI); + HashMap<String, Object> options = new HashMap<String, Object>(); + enableNewMethods(options); + + resource.load(options); + + // validate data + validateLoadErrors(resource); + validateBareDataWithGeneratedPackage(resource); + } + + @Test + public void testPositiveloadResourceWithPreregisteredGeneratedPackageAndNestedAnyTypesWithRedefinedNsPrefix() throws IOException { + String fileName = DATA_BASEDIR + "simple_toolExtensions_redefinedNsPrefix.xml"; // prepare resource set ResourceSet resourceSet = new ResourceSetImpl(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); EPackage.Registry.INSTANCE.put(XMLNamespacePackage.eNS_URI, XMLNamespacePackage.eINSTANCE); resourceSet.getPackageRegistry().put(MyreqifPackage.eNS_URI, MyreqifPackage.eINSTANCE); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new MyreqifResourceFactoryImpl()); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new MyreqifResourceFactoryImpl()); // load data URI emfURI = URI.createURI(fileName, true); @@ -93,19 +120,46 @@ public class EMFDeserializationTests { // validate data validateLoadErrors(resource); validateBareDataWithGeneratedPackage(resource); + validateAnyTypeInGeneratedPackage(resource, 1); + } + + @Test + public void testPositiveloadResourceWithPreregisteredGeneratedPackageAndNestedAnyAndEcoreTypes() throws IOException { + String fileName = DATA_BASEDIR + "bare_toolExtensions_AnyTypeAndEcoreType.xml"; + + // prepare resource set + ResourceSet resourceSet = new ResourceSetImpl(); + EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); + EPackage.Registry.INSTANCE.put(XMLNamespacePackage.eNS_URI, XMLNamespacePackage.eINSTANCE); + resourceSet.getPackageRegistry().put(MyreqifPackage.eNS_URI, MyreqifPackage.eINSTANCE); + resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new MyreqifResourceFactoryImpl()); + + // load data + URI emfURI = URI.createURI(fileName, true); + Resource resource = resourceSet.createResource(emfURI); + HashMap<String, Object> options = new HashMap<String, Object>(); + enableNewMethods(options); + resource.load(options); + + // validate data + validateLoadErrors(resource); + validateBareDataWithGeneratedPackage(resource); + validateAnyTypeInGeneratedPackage(resource, 2); + validateEcoreInGeneratedPackage(resource, 2); } @Test - public void positiveloadResourceWithPreregisteredGeneratedPackageCheckOptionsSideEffects() throws IOException { - String fileName = DATA_BASEDIR + "bare.reqif"; //$NON-NLS-1$ + public void testPositiveloadResourceWithPreregisteredGeneratedPackageCheckOptionsSideEffects() throws IOException { + String fileName = DATA_BASEDIR + "bare.xml"; //$NON-NLS-1$ // prepare resource set ResourceSet resourceSet = new ResourceSetImpl(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); EPackage.Registry.INSTANCE.put(XMLNamespacePackage.eNS_URI, XMLNamespacePackage.eINSTANCE); resourceSet.getPackageRegistry().put(MyreqifPackage.eNS_URI, MyreqifPackage.eINSTANCE); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new MyreqifResourceFactoryImpl()); //$NON-NLS-1$ + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new MyreqifResourceFactoryImpl()); //$NON-NLS-1$ // load data URI emfURI = URI.createURI(fileName, true); @@ -122,12 +176,11 @@ public class EMFDeserializationTests { // validate data validateLoadErrors(resource); validateBareDataWithGeneratedPackage(resource); - } @Test - public void positiveloadResourceWithPreregisteredPackageInEcoreFile() throws IOException { - String fileName = DATA_BASEDIR + "bare.reqif"; //$NON-NLS-1$ + public void testPositiveloadResourceWithPreregisteredPackageInEcoreFile() throws IOException { + String fileName = DATA_BASEDIR + "bare.xml"; //$NON-NLS-1$ // prepare resource set ResourceSet resourceSet = new ResourceSetImpl(); @@ -147,7 +200,7 @@ public class EMFDeserializationTests { // get the data resourceSet.getPackageRegistry().put(MyreqifPackage.eNS_URI, reqifPackage); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new XMLResourceFactoryImpl()); //$NON-NLS-1$ + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl()); //$NON-NLS-1$ // load data // note: loading an instance against an ecore that is generated from xsd requires extended meta data switched on @@ -164,8 +217,8 @@ public class EMFDeserializationTests { } @Test - public void positiveloadResourceWithPreregisteredPackageInXSDFile() throws IOException { - String fileName = DATA_BASEDIR + "bare.reqif"; //$NON-NLS-1$ + public void testPositiveloadResourceWithPreregisteredPackageInXSDFile() throws IOException { + String fileName = DATA_BASEDIR + "bare.xml"; //$NON-NLS-1$ // prepare resource set XSDEcoreBuilder xsdEcoreBuilder = new XSDEcoreBuilder(); @@ -174,7 +227,7 @@ public class EMFDeserializationTests { ResourceSet resourceSet = new ResourceSetImpl(); resourceSet.getPackageRegistry().put(MyreqifPackage.eNS_URI, reqifPackage); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new XMLResourceFactoryImpl()); //$NON-NLS-1$ + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl()); //$NON-NLS-1$ // load data // note: loading an instance against an ecore that is generated from xsd requires extended meta data switched on @@ -191,12 +244,12 @@ public class EMFDeserializationTests { } @Test - public void positiveloadResourceWithoutPackageInfo() throws IOException { - String fileName = DATA_BASEDIR + "bare.reqif"; //$NON-NLS-1$ + public void testPositiveloadResourceWithoutPackageInfo() throws IOException { + String fileName = DATA_BASEDIR + "bare.xml"; //$NON-NLS-1$ // prepare resource set ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new XMLResourceFactoryImpl()); //$NON-NLS-1$ + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl()); //$NON-NLS-1$ // load data // note: loading of XML files with unknown structure requires OPTION_RECORD_UNKNOWN_FEATURE @@ -236,8 +289,8 @@ public class EMFDeserializationTests { } @Test - public void positiveloadResourceWithLocationHintPackageInEcoreFile() throws IOException { - String fileName = DATA_BASEDIR + "bareWithEcoreHint.reqif"; //$NON-NLS-1$ + public void testPositiveloadResourceWithLocationHintPackageInEcoreFile() throws IOException { + String fileName = DATA_BASEDIR + "bareWithEcoreHint.xml"; //$NON-NLS-1$ // prepare resource set // NOTE: @@ -245,8 +298,8 @@ public class EMFDeserializationTests { EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new XMLResourceFactoryImpl()); //$NON-NLS-1$ - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); //$NON-NLS-1$ + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl()); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); resourceSet.getPackageRegistry().put(XSDPackage.eNS_URI, XSDPackage.eINSTANCE); // load data @@ -269,13 +322,13 @@ public class EMFDeserializationTests { } @Test - public void positiveloadResourceWithLocationHintPackageInXSDFile() throws IOException { - String fileName = DATA_BASEDIR + "bareWithSchemaHint.reqif"; //$NON-NLS-1$ + public void testPositiveloadResourceWithLocationHintPackageInXSDFile() throws IOException { + String fileName = DATA_BASEDIR + "bareWithSchemaHint.xml"; //$NON-NLS-1$ // prepare resource set ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new XMLResourceFactoryImpl()); //$NON-NLS-1$ - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl()); //$NON-NLS-1$ // resourceSet.getPackageRegistry().put(XSDPackage.eNS_URI, XSDPackage.eINSTANCE); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl()); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl()); // load data // note: loading an instance against an ecore that is generated from xsd requires extended meta data switched on @@ -299,29 +352,25 @@ public class EMFDeserializationTests { } - @Test - public void loadResourceWithInvalidLocationHintPackage() { - } - private void validateBareDataWithDynamicEcore(Resource resource, EPackage reqifPackage) { assertEquals(1, resource.getContents().size()); EObject documentRoot = resource.getContents().get(0); assertFalse(documentRoot instanceof DocumentRoot); - EClass documentRootEClass = (EClass) reqifPackage.getEClassifier("DocumentRoot"); //$NON-NLS-1$ + EClass documentRootEClass = (EClass) reqifPackage.getEClassifier("DocumentRoot"); assertEquals(documentRootEClass, documentRoot.eClass()); - EStructuralFeature reqifFeature = documentRootEClass.getEStructuralFeature("rEQIF"); //$NON-NLS-1$ + EStructuralFeature reqifFeature = documentRootEClass.getEStructuralFeature("rEQIF"); Object reqifObject = documentRoot.eGet(reqifFeature); assertNotNull(reqifObject); assertTrue(reqifObject instanceof EObject); EObject reqif = (EObject) reqifObject; - EClass reqifEClass = (EClass) reqifPackage.getEClassifier("REQIF"); //$NON-NLS-1$ + EClass reqifEClass = (EClass) reqifPackage.getEClassifier("REQIF"); assertEquals(reqifEClass, reqif.eClass()); - EStructuralFeature coreContentFeature = reqifEClass.getEStructuralFeature("cORECONTENT"); //$NON-NLS-1$ + EStructuralFeature coreContentFeature = reqifEClass.getEStructuralFeature("cORECONTENT"); Object coreContentObject = reqif.eGet(coreContentFeature); assertNotNull(coreContentObject); @@ -335,13 +384,68 @@ public class EMFDeserializationTests { assertTrue(root instanceof DocumentRoot); DocumentRoot documentRoot = (DocumentRoot) root; - assertTrue(null != documentRoot.getREQIF()); + assertNotNull(documentRoot.getREQIF()); REQIF reqif = documentRoot.getREQIF(); - assertTrue(null != reqif.getCORECONTENT()); + assertNotNull(reqif.getCORECONTENT()); CORECONTENTType coreContent = reqif.getCORECONTENT(); - assertTrue(null != coreContent.getREQIFCONTENT()); + assertNotNull(coreContent.getREQIFCONTENT()); + } + + private void validateAnyTypeInGeneratedPackage(Resource resource, int expectedExtensionSize) { + // test data + assertEquals(1, resource.getContents().size()); + EObject root = resource.getContents().get(0); + + assertTrue(root instanceof DocumentRoot); + DocumentRoot documentRoot = (DocumentRoot) root; + + assertNotNull(documentRoot.getREQIF()); + REQIF reqif = documentRoot.getREQIF(); + + assertNotNull(reqif.getTOOLEXTENSIONS()); + TOOLEXTENSIONSType toolExtensions = reqif.getTOOLEXTENSIONS(); + + assertNotNull(toolExtensions.getREQIFTOOLEXTENSION()); + assertEquals(1, toolExtensions.getREQIFTOOLEXTENSION().size()); + REQIFTOOLEXTENSION reqifToolExtension = toolExtensions.getREQIFTOOLEXTENSION().get(0); + + assertNotNull(reqifToolExtension.getAny()); + assertEquals(expectedExtensionSize, reqifToolExtension.getAny().size()); + org.eclipse.emf.ecore.util.FeatureMap.Entry myExtensionEntry = reqifToolExtension.getAny().get(0); + + Object myExtensionObject = myExtensionEntry.getValue(); + assertTrue(myExtensionObject instanceof AnyTypeImpl); + assertEquals("myExtension", myExtensionEntry.getEStructuralFeature().getName()); + } + + private void validateEcoreInGeneratedPackage(Resource resource, int expectedExtensionSize) { + // test data + assertEquals(1, resource.getContents().size()); + EObject root = resource.getContents().get(0); + + assertTrue(root instanceof DocumentRoot); + DocumentRoot documentRoot = (DocumentRoot) root; + + assertNotNull(documentRoot.getREQIF()); + REQIF reqif = documentRoot.getREQIF(); + + assertNotNull(reqif.getTOOLEXTENSIONS()); + TOOLEXTENSIONSType toolExtensions = reqif.getTOOLEXTENSIONS(); + + assertNotNull(toolExtensions.getREQIFTOOLEXTENSION()); + assertEquals(1, toolExtensions.getREQIFTOOLEXTENSION().size()); + REQIFTOOLEXTENSION reqifToolExtension = toolExtensions.getREQIFTOOLEXTENSION().get(0); + + assertNotNull(reqifToolExtension.getAny()); + assertEquals(expectedExtensionSize, reqifToolExtension.getAny().size()); + org.eclipse.emf.ecore.util.FeatureMap.Entry myExtensionEntry = reqifToolExtension.getAny().get(1); + + Object ePackageObject = myExtensionEntry.getValue(); + assertTrue(ePackageObject instanceof EPackage); + EPackage ePackage = (EPackage) ePackageObject; + assertEquals(1, ePackage.getEClassifiers().size()); } private void validateLoadErrors(Resource resource) { @@ -349,7 +453,7 @@ public class EMFDeserializationTests { assertEquals(0, resource.getWarnings().size()); } - private void enableNewMethods(Map<String, Object> options) { + protected void enableNewMethods(Map<String, Object> options) { // Retrieve application-defined XMLReader features (see http://xerces.apache.org/xerces2-j/features.html for // available features and their details) Map<String, Boolean> parserFeatures = new HashMap<String, Boolean>(); diff --git a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFDeserializationWithSchemaValidationTests.java b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFDeserializationWithSchemaValidationTests.java index 346fe6b3..856ab1ab 100644 --- a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFDeserializationWithSchemaValidationTests.java +++ b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFDeserializationWithSchemaValidationTests.java @@ -21,44 +21,23 @@ import org.eclipse.emf.ecore.xml.type.XMLTypePackage; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.DocumentRoot; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.MyreqifPackage; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.util.MyreqifResourceFactoryImpl; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; @SuppressWarnings("nls") public class EMFDeserializationWithSchemaValidationTests { - public static final String DATA_BASEDIR = "input/org.eclipse.rmf.tests.serialization.env/data/"; //$NON-NLS-1$ - public static final String MODEL_BASEDIR = "input/org.eclipse.rmf.tests.serialization.env/model/"; //$NON-NLS-1$ - private static HashMap<String, Object> backupRegistry = new HashMap<String, Object>(); - - @BeforeClass - public static void initRegistry() { - backupRegistry = new HashMap<String, Object>(); - backupRegistry.putAll(EPackage.Registry.INSTANCE); - } - - @Before - public void beforeTestCase() { - EPackage.Registry.INSTANCE.clear(); - } - - @AfterClass - public static void restorePackageRegistry() { - EPackage.Registry.INSTANCE.clear(); - EPackage.Registry.INSTANCE.putAll(backupRegistry); - } + public static final String DATA_BASEDIR = "resources/input/org.eclipse.rmf.tests.serialization.env/data/"; //$NON-NLS-1$ + public static final String MODEL_BASEDIR = "resources/input/org.eclipse.rmf.tests.serialization.env/model/"; //$NON-NLS-1$ @Test public void testSchemaValidationOnLoadWithValidFile() throws IOException { - String fileName = DATA_BASEDIR + "simple.reqif"; //$NON-NLS-1$ + String fileName = DATA_BASEDIR + "simple.xml"; //$NON-NLS-1$ // prepare resource set ResourceSet resourceSet = new ResourceSetImpl(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); EPackage.Registry.INSTANCE.put(XMLNamespacePackage.eNS_URI, XMLNamespacePackage.eINSTANCE); resourceSet.getPackageRegistry().put(MyreqifPackage.eNS_URI, MyreqifPackage.eINSTANCE); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new MyreqifResourceFactoryImpl()); //$NON-NLS-1$ + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new MyreqifResourceFactoryImpl()); //$NON-NLS-1$ // load data URI emfURI = URI.createURI(fileName, true); @@ -78,14 +57,14 @@ public class EMFDeserializationWithSchemaValidationTests { @Test public void testSchemaValidationOnLoadWithInvalidFile() { - String fileName = DATA_BASEDIR + "bare.reqif"; //$NON-NLS-1$ + String fileName = DATA_BASEDIR + "bare.xml"; //$NON-NLS-1$ // prepare resource set ResourceSet resourceSet = new ResourceSetImpl(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); EPackage.Registry.INSTANCE.put(XMLNamespacePackage.eNS_URI, XMLNamespacePackage.eINSTANCE); resourceSet.getPackageRegistry().put(MyreqifPackage.eNS_URI, MyreqifPackage.eINSTANCE); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new MyreqifResourceFactoryImpl()); //$NON-NLS-1$ + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new MyreqifResourceFactoryImpl()); //$NON-NLS-1$ // load data URI emfURI = URI.createURI(fileName, true); diff --git a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFRoundtripTests.java b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFRoundtripTests.java new file mode 100644 index 00000000..00378e1a --- /dev/null +++ b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFRoundtripTests.java @@ -0,0 +1,124 @@ +package org.eclipse.rmf.tests.serialization.env.emf; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import org.apache.xerces.impl.Constants; +import org.eclipse.core.runtime.Plugin; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; +import org.eclipse.rmf.tests.serialization.env.emf.myreqif.DocumentRoot; +import org.eclipse.rmf.tests.serialization.env.emf.myreqif.MyreqifPackage; +import org.eclipse.rmf.tests.serialization.env.emf.myreqif.util.MyreqifResourceFactoryImpl; +import org.eclipse.rmf.tests.serialization.internal.Activator; +import org.eclipse.sphinx.testutils.AbstractTestCase; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@SuppressWarnings("nls") +public class EMFRoundtripTests extends AbstractTestCase { + public static final String DATA_BASEDIR = "org.eclipse.rmf.tests.serialization.env/data/"; + public static final String WORKING_BASEDIR = "org.eclipse.rmf.tests.serialization.env.emf/"; + + private static HashMap<String, Object> backupRegistry = new HashMap<String, Object>(); + + @BeforeClass + public static void setupOnce() { + backupRegistry = new HashMap<String, Object>(); + backupRegistry.putAll(EPackage.Registry.INSTANCE); + } + + @Override + @Before + public void setUp() throws Exception { + super.setUp(); + EPackage.Registry.INSTANCE.clear(); + } + + @AfterClass + public static void tearDownOnce() { + EPackage.Registry.INSTANCE.clear(); + EPackage.Registry.INSTANCE.putAll(backupRegistry); + } + + @Test + public void testRoundtrip() throws IOException { + String inputFileName = DATA_BASEDIR + "bare_toolExtensions_AnyTypeAndEcoreType.xml"; + String workingFileName = WORKING_BASEDIR + "bare_toolExtensions_AnyTypeAndEcoreType.xml"; + + // prepare resource set + EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); + EPackage.Registry.INSTANCE.put(XMLNamespacePackage.eNS_URI, XMLNamespacePackage.eINSTANCE); + EPackage.Registry.INSTANCE.put(MyreqifPackage.eNS_URI, MyreqifPackage.eINSTANCE); + EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); + + try { + // load data + HashMap<String, Object> options = new HashMap<String, Object>(); + enableNewMethods(options); + + EObject root = loadInputFile(inputFileName, new MyreqifResourceFactoryImpl(), options); + assertTrue(root instanceof DocumentRoot); + saveWorkingFile(workingFileName, root, new MyreqifResourceFactoryImpl(), options); + assertTrue(true); + String savedContents = loadWorkingFileAsString(workingFileName); + assertTrue(savedContents.contains("<REQ-IF")); + } catch (Exception ex) { + assertTrue(ex.getMessage(), false); + } + + } + + protected void enableNewMethods(Map<String, Object> options) { + // Retrieve application-defined XMLReader features (see http://xerces.apache.org/xerces2-j/features.html for + // available features and their details) + Map<String, Boolean> parserFeatures = new HashMap<String, Boolean>(); + + // Retrieve application-defined XMLReader properties (see http://xerces.apache.org/xerces2-j/properties.html + // for available properties and their details) + Map<String, Object> parserProperties = new HashMap<String, Object>(); + + // Perform namespace processing (prefixes will be stripped off element and attribute names and replaced with the + // corresponding namespace URIs) but do not report attributes used for namespace declarations, and do not report + // original prefixed names + parserFeatures.put(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE, true); + parserFeatures.put(Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACE_PREFIXES_FEATURE, false); + + options.put(XMLResource.OPTION_PARSER_FEATURES, parserFeatures); + options.put(XMLResource.OPTION_PARSER_PROPERTIES, parserProperties); + options.put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE); + + } + + @Override + protected Plugin getTestPlugin() { + return new Activator.Implementation(); + } + + /** + * required to overwrite this, since the Sphinx AbstractTestCase doesn't properly handle plain java tests + */ + @Override + protected EObject loadInputFile(String inputFileName, ResourceFactoryImpl resourceFactory, Map<?, ?> options) throws Exception { + URI emfURI = URI.createURI("resources/input/" + inputFileName, true); + XMLResource resource = (XMLResource) resourceFactory.createResource(emfURI); + resource.load(options); + + ResourceSet resourceSet = createDefaultResourceSet(); + resourceSet.getResources().add(resource); + + assertHasNoLoadProblems(resource); + + return resource.getContents().get(0); + } +} diff --git a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFSerializationTests.java b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFSerializationTests.java index bb217e75..c5b685da 100644 --- a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFSerializationTests.java +++ b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/emf/EMFSerializationTests.java @@ -5,6 +5,7 @@ import java.util.Map; import org.eclipse.core.runtime.Plugin; import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.EcoreFactory; import org.eclipse.emf.ecore.EcorePackage; @@ -17,39 +18,19 @@ import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl; import org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl; import org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage; import org.eclipse.emf.ecore.xml.type.XMLTypePackage; +import org.eclipse.rmf.tests.serialization.env.emf.myreqif.CORECONTENTType; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.DocumentRoot; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.MyreqifFactory; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.MyreqifPackage; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.REQIF; +import org.eclipse.rmf.tests.serialization.env.emf.myreqif.REQIFCONTENT; import org.eclipse.rmf.tests.serialization.env.emf.myreqif.util.MyreqifResourceFactoryImpl; import org.eclipse.rmf.tests.serialization.internal.Activator; -import org.eclipse.sphinx.testutils.AbstractTestCase; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; @SuppressWarnings("nls") -public class EMFSerializationTests extends AbstractTestCase { +public class EMFSerializationTests extends AbstractEMFTestCase { public static final String RELATIVE_WORK_DIR = "org.eclipse.rmf.tests.serialization.env.emf/EMFSerializationTests/"; - private static HashMap<String, Object> backupRegistry = new HashMap<String, Object>(); - - @BeforeClass - public static void initRegistry() { - backupRegistry = new HashMap<String, Object>(); - backupRegistry.putAll(EPackage.Registry.INSTANCE); - } - - @Before - public void beforeTestCase() { - EPackage.Registry.INSTANCE.clear(); - } - - @AfterClass - public static void restorePackageRegistry() { - EPackage.Registry.INSTANCE.clear(); - EPackage.Registry.INSTANCE.putAll(backupRegistry); - } class EmptyPrefixResourceFactoryImpl extends EcoreResourceFactoryImpl { @Override @@ -87,8 +68,14 @@ public class EMFSerializationTests extends AbstractTestCase { // create model DocumentRoot documentRoot = MyreqifFactory.eINSTANCE.createDocumentRoot(); REQIF reqif = MyreqifFactory.eINSTANCE.createREQIF(); - reqif.setLang("en"); + CORECONTENTType coreContent = MyreqifFactory.eINSTANCE.createCORECONTENTType(); + REQIFCONTENT reqifContent = MyreqifFactory.eINSTANCE.createREQIFCONTENT(); + documentRoot.setREQIF(reqif); + reqif.setCORECONTENT(coreContent); + coreContent.setREQIFCONTENT(reqifContent); + + reqif.setLang("en"); // save model EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); @@ -110,7 +97,12 @@ public class EMFSerializationTests extends AbstractTestCase { // create model DocumentRoot documentRoot = MyreqifFactory.eINSTANCE.createDocumentRoot(); REQIF reqif = MyreqifFactory.eINSTANCE.createREQIF(); + CORECONTENTType coreContent = MyreqifFactory.eINSTANCE.createCORECONTENTType(); + REQIFCONTENT reqifContent = MyreqifFactory.eINSTANCE.createREQIFCONTENT(); + documentRoot.setREQIF(reqif); + reqif.setCORECONTENT(coreContent); + coreContent.setREQIFCONTENT(reqifContent); // save model EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); @@ -133,7 +125,12 @@ public class EMFSerializationTests extends AbstractTestCase { // create model DocumentRoot documentRoot = MyreqifFactory.eINSTANCE.createDocumentRoot(); REQIF reqif = MyreqifFactory.eINSTANCE.createREQIF(); + CORECONTENTType coreContent = MyreqifFactory.eINSTANCE.createCORECONTENTType(); + REQIFCONTENT reqifContent = MyreqifFactory.eINSTANCE.createREQIFCONTENT(); + documentRoot.setREQIF(reqif); + reqif.setCORECONTENT(coreContent); + coreContent.setREQIFCONTENT(reqifContent); // save model EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); @@ -155,7 +152,12 @@ public class EMFSerializationTests extends AbstractTestCase { DocumentRoot documentRoot = MyreqifFactory.eINSTANCE.createDocumentRoot(); documentRoot.getXMLNSPrefixMap().put("", MyreqifPackage.eNS_URI); REQIF reqif = MyreqifFactory.eINSTANCE.createREQIF(); + CORECONTENTType coreContent = MyreqifFactory.eINSTANCE.createCORECONTENTType(); + REQIFCONTENT reqifContent = MyreqifFactory.eINSTANCE.createREQIFCONTENT(); + documentRoot.setREQIF(reqif); + reqif.setCORECONTENT(coreContent); + coreContent.setREQIFCONTENT(reqifContent); // save model EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); @@ -175,6 +177,8 @@ public class EMFSerializationTests extends AbstractTestCase { // create model EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage(); + EClass eClass = EcoreFactory.eINSTANCE.createEClass(); + ePackage.getEClassifiers().add(eClass); // save model EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); diff --git a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/xerces/XercesSchemaValidationTests.java b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/xerces/XercesSchemaValidationTests.java index 77f5ccb8..cd7a1099 100644 --- a/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/xerces/XercesSchemaValidationTests.java +++ b/org.eclipse.rmf.tests.serialization/src/org/eclipse/rmf/tests/serialization/env/xerces/XercesSchemaValidationTests.java @@ -27,8 +27,8 @@ import org.xml.sax.XMLReader; @SuppressWarnings("nls") public class XercesSchemaValidationTests { - public static final String DATA_BASEDIR = "input/org.eclipse.rmf.tests.serialization.env/data/"; - public static final String MODEL_BASEDIR = "input/org.eclipse.rmf.tests.serialization.env/model/"; + public static final String DATA_BASEDIR = "resources/input/org.eclipse.rmf.tests.serialization.env/data/"; + public static final String MODEL_BASEDIR = "resources/input/org.eclipse.rmf.tests.serialization.env/model/"; class MyErrorHandler implements ErrorHandler { public List<SAXParseException> errors = new Vector<SAXParseException>(); @@ -53,47 +53,8 @@ public class XercesSchemaValidationTests { }; @Test - public void testSchemaValidationWithValidFile() { - String fileName = DATA_BASEDIR + "simple.reqif"; - StreamSource[] schemaDocuments = new StreamSource[] { new StreamSource(MODEL_BASEDIR + "myreqif.xsd") }; - Source instanceDocument = new StreamSource(fileName); - - SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); - Schema s; - try { - s = sf.newSchema(schemaDocuments); - Validator v = s.newValidator(); - v.validate(instanceDocument); - - } catch (SAXException ex) { - assertTrue(ex.getMessage(), false); - } catch (IOException ex) { - assertTrue(ex.getMessage(), false); - } - } - - @Test - public void testSchemaValidationWithInvalidFile() { - String fileName = DATA_BASEDIR + "bare.reqif"; - StreamSource[] schemaDocuments = new StreamSource[] { new StreamSource(MODEL_BASEDIR + "myreqif.xsd") }; - Source instanceDocument = new StreamSource(fileName); - SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); - Schema s; - try { - s = sf.newSchema(schemaDocuments); - Validator v = s.newValidator(); - v.validate(instanceDocument); - assertTrue(false); - } catch (SAXException ex) { - assertTrue(ex.getMessage().contains("cvc-complex-type.2.4.a:")); - } catch (IOException ex) { - assertTrue(ex.getMessage(), false); - } - } - - @Test public void testSchemaValidationOnLoadWithValidFile() { - String fileName = DATA_BASEDIR + "simple.reqif"; + String fileName = DATA_BASEDIR + "simple.xml"; try { MyErrorHandler errorHandler = new MyErrorHandler(); @@ -118,13 +79,13 @@ public class XercesSchemaValidationTests { } catch (IOException ex) { assertTrue(ex.getMessage(), false); } catch (ParserConfigurationException ex) { - // TODO Auto-generated catch block + assertTrue(ex.getMessage(), false); } } @Test public void testSchemaValidationOnLoadWithInvalidFile() { - String fileName = DATA_BASEDIR + "bare.reqif"; + String fileName = DATA_BASEDIR + "bare.xml"; try { MyErrorHandler errorHandler = new MyErrorHandler(); SAXParserFactory factory = SAXParserFactory.newInstance(); @@ -148,13 +109,52 @@ public class XercesSchemaValidationTests { } catch (IOException ex) { assertTrue(ex.getMessage(), false); } catch (ParserConfigurationException ex) { - // TODO Auto-generated catch block + assertTrue(ex.getMessage(), false); + } + } + + @Test + public void testSchemaValidationWithValidFile() { + String fileName = DATA_BASEDIR + "simple.xml"; + StreamSource[] schemaDocuments = new StreamSource[] { new StreamSource(MODEL_BASEDIR + "myreqif.xsd") }; + Source instanceDocument = new StreamSource(fileName); + + SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); + Schema s; + try { + s = sf.newSchema(schemaDocuments); + Validator v = s.newValidator(); + v.validate(instanceDocument); + + } catch (SAXException ex) { + assertTrue(ex.getMessage(), false); + } catch (IOException ex) { + assertTrue(ex.getMessage(), false); + } + } + + @Test + public void testSchemaValidationWithInvalidFile() { + String fileName = DATA_BASEDIR + "bare.xml"; + StreamSource[] schemaDocuments = new StreamSource[] { new StreamSource(MODEL_BASEDIR + "myreqif.xsd") }; + Source instanceDocument = new StreamSource(fileName); + SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema"); + Schema s; + try { + s = sf.newSchema(schemaDocuments); + Validator v = s.newValidator(); + v.validate(instanceDocument); + assertTrue(false); + } catch (SAXException ex) { + assertTrue(ex.getMessage().contains("cvc-complex-type.2.4.a:")); + } catch (IOException ex) { + assertTrue(ex.getMessage(), false); } } @Test public void testSchemaValidationWithValidToolExtensionsFile() { - String fileName = DATA_BASEDIR + "toolExtensions.reqif"; + String fileName = DATA_BASEDIR + "simple_toolExtensions.xml"; StreamSource[] schemaDocuments = new StreamSource[] { new StreamSource(MODEL_BASEDIR + "myreqif.xsd") }; Source instanceDocument = new StreamSource(fileName); @@ -173,7 +173,7 @@ public class XercesSchemaValidationTests { } public void testSchemaValidationWithValidRedefinedToolExtensionsFile() { - String fileName = DATA_BASEDIR + "toolExtensions_redefinedNsPrefix.reqif"; + String fileName = DATA_BASEDIR + "simple_toolExtensions_redefinedNsPrefix.xml"; StreamSource[] schemaDocuments = new StreamSource[] { new StreamSource(MODEL_BASEDIR + "myreqif.xsd") }; Source instanceDocument = new StreamSource(fileName); @@ -197,7 +197,7 @@ public class XercesSchemaValidationTests { */ @Test public void testSchemaValidationWithValidToolExtensionsXsiTypeFile() { - String fileName = DATA_BASEDIR + "toolExtensions_xsiType.reqif"; + String fileName = DATA_BASEDIR + "simple_toolExtensions_xsiType.xml"; StreamSource[] schemaDocuments = new StreamSource[] { new StreamSource(MODEL_BASEDIR + "myreqif.xsd") }; Source instanceDocument = new StreamSource(fileName); |