summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMark Broerkens2012-04-04 08:27:33 (EDT)
committer Michael Jastram2012-04-05 07:58:02 (EDT)
commit6560fbd7d0475c185c89b2ed9c12e72f6dab17bb (patch)
treed143c3e7c58a6c707ebecdb30c9120a4cadbed90
parent157d1c1557e479c734204bd732b2d754c2d08639 (diff)
downloadorg.eclipse.rmf-6560fbd7d0475c185c89b2ed9c12e72f6dab17bb.zip
org.eclipse.rmf-6560fbd7d0475c185c89b2ed9c12e72f6dab17bb.tar.gz
org.eclipse.rmf-6560fbd7d0475c185c89b2ed9c12e72f6dab17bb.tar.bz2
modified load and save of ReqIF data to run as pure java tests
-rw-r--r--org.eclipse.rmf.reqif10.tests/input/sample.reqif2
-rw-r--r--org.eclipse.rmf.reqif10.tests/input/simple.reqif103
-rw-r--r--org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/domain/TC1000SimpleContentTests.java4
-rw-r--r--org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/referencedata/ReferenceDataTests.java35
-rw-r--r--org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/util/AbstractTestCase.java36
5 files changed, 160 insertions, 20 deletions
diff --git a/org.eclipse.rmf.reqif10.tests/input/sample.reqif b/org.eclipse.rmf.reqif10.tests/input/sample.reqif
index 4544408..a12c264 100644
--- a/org.eclipse.rmf.reqif10.tests/input/sample.reqif
+++ b/org.eclipse.rmf.reqif10.tests/input/sample.reqif
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<REQ-IF xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<REQ-IF xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd">
<THE-HEADER>
<REQ-IF-HEADER IDENTIFIER="_3dd1a60c-59d1-11da-86ca-4bda04a730ce">
<COMMENT>Embedded OLE object with multiple representation forms.</COMMENT>
diff --git a/org.eclipse.rmf.reqif10.tests/input/simple.reqif b/org.eclipse.rmf.reqif10.tests/input/simple.reqif
new file mode 100644
index 0000000..74aed69
--- /dev/null
+++ b/org.eclipse.rmf.reqif10.tests/input/simple.reqif
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<REQ-IF xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd" xsi:schemaLocation="http://www.omg.org/spec/ReqIF/20110401/reqif.xsd reqif.xsd http://www.w3.org/1999/xhtml driver.xsd">
+ <THE-HEADER>
+ <REQ-IF-HEADER IDENTIFIER="3dd1a60c-59d1-11da-86ca-4bda04a730ce">
+ <COMMENT>Embedded OLE object with multiple representation forms.</COMMENT>
+ <CREATION-TIME>2005-05-23T12:00:00+02:00</CREATION-TIME>
+ <SOURCE-TOOL-ID>Manually written</SOURCE-TOOL-ID>
+ <TITLE>Test data RIF72</TITLE>
+ </REQ-IF-HEADER>
+ </THE-HEADER>
+ <CORE-CONTENT>
+ <REQ-IF-CONTENT>
+ <DATATYPES>
+ <DATATYPE-DEFINITION-STRING DESC="This is a standard string type." IDENTIFIER="3631dcd2-59d1-11da-beb2-6fbc179f63e3" LONG-NAME="Standard String Type" MAX-LENGTH="65535"/>
+ </DATATYPES>
+ <SPEC-TYPES>
+ <SPEC-OBJECT-TYPE DESC="SpecObjectType" IDENTIFIER="3631dcd2-59d1-11da-beb2-6fbc179f63e2" LAST-CHANGE="2005-05-30T11:42:19+02:00" LONG-NAME="Example SpecType">
+ <SPEC-ATTRIBUTES>
+ <ATTRIBUTE-DEFINITION-STRING DESC="This attribute contains the author of the requirement as a string." IDENTIFIER="356b02ec-59d1-11da-afa6-6b90abdfb5db" LAST-CHANGE="2005-05-30T11:51:25+02:00" LONG-NAME="Description">
+ <DEFAULT-VALUE>
+ <ATTRIBUTE-VALUE-STRING THE-VALUE="TBD"/>
+ </DEFAULT-VALUE>
+ <TYPE>
+ <DATATYPE-DEFINITION-STRING-REF>3631dcd2-59d1-11da-beb2-6fbc179f63e3</DATATYPE-DEFINITION-STRING-REF>
+ </TYPE>
+ </ATTRIBUTE-DEFINITION-STRING>
+ </SPEC-ATTRIBUTES>
+ </SPEC-OBJECT-TYPE>
+ <SPECIFICATION-TYPE DESC="" IDENTIFIER="_Hb_0DMf8EeCG3ORKRCOoiQ" LONG-NAME="SpecificationType">
+ <SPEC-ATTRIBUTES>
+ <ATTRIBUTE-DEFINITION-STRING IDENTIFIER="_IZZ3dsf8EeCG3ORKRCOoiQ" LONG-NAME="Description">
+ <TYPE>
+ <DATATYPE-DEFINITION-STRING-REF>3631dcd2-59d1-11da-beb2-6fbc179f63e3</DATATYPE-DEFINITION-STRING-REF>
+ </TYPE>
+ </ATTRIBUTE-DEFINITION-STRING>
+ </SPEC-ATTRIBUTES>
+ </SPECIFICATION-TYPE>
+ <SPEC-RELATION-TYPE IDENTIFIER="_W2fzNMf8EeCG3ORKRCOoiQ" LONG-NAME="SpecRelationType">
+ <SPEC-ATTRIBUTES>
+ <ATTRIBUTE-DEFINITION-STRING IDENTIFIER="_aNRhtsf8EeCG3ORKRCOoiQ" LONG-NAME="Description">
+ <TYPE>
+ <DATATYPE-DEFINITION-STRING-REF>3631dcd2-59d1-11da-beb2-6fbc179f63e3</DATATYPE-DEFINITION-STRING-REF>
+ </TYPE>
+ </ATTRIBUTE-DEFINITION-STRING>
+ </SPEC-ATTRIBUTES>
+ </SPEC-RELATION-TYPE>
+ <RELATION-GROUP-TYPE IDENTIFIER="_dj3qFsf8EeCG3ORKRCOoiQ" LONG-NAME="SpecRelationGroupType">
+ <SPEC-ATTRIBUTES>
+ <ATTRIBUTE-DEFINITION-STRING IDENTIFIER="_feUklsf8EeCG3ORKRCOoiQ" LONG-NAME="Description"/>
+ </SPEC-ATTRIBUTES>
+ </RELATION-GROUP-TYPE>
+ </SPEC-TYPES>
+ <SPEC-OBJECTS>
+ <SPEC-OBJECT IDENTIFIER="2c84e85a-59d1-11da-8ef5-afdbd01c7a79" LAST-CHANGE="2005-05-30T17:22:47+02:00">
+ <VALUES>
+ <ATTRIBUTE-VALUE-STRING THE-VALUE="SpecObjectDescriptionValue">
+ <DEFINITION>
+ <ATTRIBUTE-DEFINITION-STRING-REF>356b02ec-59d1-11da-afa6-6b90abdfb5db</ATTRIBUTE-DEFINITION-STRING-REF>
+ </DEFINITION>
+ </ATTRIBUTE-VALUE-STRING>
+ </VALUES>
+ <TYPE>
+ <SPEC-OBJECT-TYPE-REF>3631dcd2-59d1-11da-beb2-6fbc179f63e2</SPEC-OBJECT-TYPE-REF>
+ </TYPE>
+ </SPEC-OBJECT>
+ </SPEC-OBJECTS>
+ <SPEC-RELATIONS>
+ <SPEC-RELATION IDENTIFIER="_Nd0Micf8EeCG3ORKRCOoiQ">
+ <VALUES>
+ <ATTRIBUTE-VALUE-STRING THE-VALUE=""/>
+ </VALUES>
+ <TYPE>
+ <SPEC-RELATION-TYPE-REF>_W2fzNMf8EeCG3ORKRCOoiQ</SPEC-RELATION-TYPE-REF>
+ </TYPE>
+ </SPEC-RELATION>
+ </SPEC-RELATIONS>
+ <SPECIFICATIONS>
+ <SPECIFICATION IDENTIFIER="_J04MUMZOEeCMe7Bm-O_YaA">
+ <VALUES>
+ <ATTRIBUTE-VALUE-STRING THE-VALUE="SpecificationDescriptionValue"/>
+ </VALUES>
+ <CHILDREN>
+ <SPEC-HIERARCHY IDENTIFIER="3dd45190-59d1-11da-a4bd-f3b1a51212c8" LAST-CHANGE="2005-05-31T10:58:13+02:00" LONG-NAME="Requirements document structure">
+ <OBJECT>
+ <SPEC-OBJECT-REF>2c84e85a-59d1-11da-8ef5-afdbd01c7a79</SPEC-OBJECT-REF>
+ </OBJECT>
+ </SPEC-HIERARCHY>
+ </CHILDREN>
+ <TYPE>
+ <SPECIFICATION-TYPE-REF>_Hb_0DMf8EeCG3ORKRCOoiQ</SPECIFICATION-TYPE-REF>
+ </TYPE>
+ </SPECIFICATION>
+ </SPECIFICATIONS>
+ <SPEC-RELATION-GROUPS>
+ <RELATION-GROUP IDENTIFIER="_P8sCusf8EeCG3ORKRCOoiQ">
+ <TYPE>
+ <RELATION-GROUP-TYPE-REF>_dj3qFsf8EeCG3ORKRCOoiQ</RELATION-GROUP-TYPE-REF>
+ </TYPE>
+ </RELATION-GROUP>
+ </SPEC-RELATION-GROUPS>
+ </REQ-IF-CONTENT>
+ </CORE-CONTENT>
+</REQ-IF> \ No newline at end of file
diff --git a/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/domain/TC1000SimpleContentTests.java b/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/domain/TC1000SimpleContentTests.java
index 220b546..7818ddb 100644
--- a/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/domain/TC1000SimpleContentTests.java
+++ b/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/domain/TC1000SimpleContentTests.java
@@ -60,12 +60,10 @@ public class TC1000SimpleContentTests extends AbstractTestCase {
private static final String WORKING_DIRECTORY = "work";
- /**
@Test
public void testSchemaCompliance() throws Exception {
- validateAgainstSchema("TC1000.ReqIF");
+ validateAgainstSchema(WORKING_DIRECTORY + IPath.SEPARATOR + "TC1000.reqif");
}
- */
@Test
diff --git a/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/referencedata/ReferenceDataTests.java b/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/referencedata/ReferenceDataTests.java
index ceb7ff2..13374b9 100644
--- a/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/referencedata/ReferenceDataTests.java
+++ b/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/referencedata/ReferenceDataTests.java
@@ -1,11 +1,18 @@
package org.eclipse.rmf.reqif10.tests.referencedata;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import java.io.File;
+import java.io.FilenameFilter;
import java.io.IOException;
+import java.util.Collection;
+import java.util.Map;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.rmf.reqif10.ReqIF;
import org.eclipse.rmf.reqif10.tests.util.AbstractTestCase;
import org.junit.Test;
@@ -15,17 +22,29 @@ public class ReferenceDataTests extends AbstractTestCase {
final String INPUT_DIR = "input";
final String WORK_DIR = "work";
+ class ReqIFFileNameFilter implements FilenameFilter {
+ @Override
+ public boolean accept(File dir, String name) {
+ if (name.endsWith("reqif")) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
@Test
public void testAllFilesInInputFolder() {
File folder = new File(INPUT_DIR);
if (folder.exists() && folder.isDirectory()) {
- for (String fileName :folder.list()) {
+ for (String fileName :folder.list(new ReqIFFileNameFilter())) {
System.out.println("Reading file: " + fileName);
try {
// System.out.println("validating input file");
// validateAgainstSchema(INPUT_DIR + IPath.SEPARATOR + fileName);
System.out.println("reading input file");
ReqIF reqIF = loadReqIFFile(INPUT_DIR + IPath.SEPARATOR + fileName);
+ // check for unresolved proxies
+ assertTrue(checkUnresolvedProxies(reqIF));
System.out.println("writing file");
saveReqIFFile(reqIF, WORK_DIR + IPath.SEPARATOR + fileName);
// System.out.println("validating written file");
@@ -37,5 +56,19 @@ public class ReferenceDataTests extends AbstractTestCase {
}
}
}
+
+ protected boolean checkUnresolvedProxies(ReqIF reqif) {
+
+ Map<EObject, Collection<Setting>> map = EcoreUtil.UnresolvedProxyCrossReferencer.find(reqif);
+ for (EObject eObject : map.keySet()) {
+ System.out.println("Unresolved Proxy to object " + eObject);
+ for (Setting setting : map.get(eObject)) {
+ System.out.println("-" + setting.getEStructuralFeature().getName() + " of " + setting.getEObject());
+ }
+ }
+
+ return map.size() == 0;
+
+ }
}
diff --git a/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/util/AbstractTestCase.java b/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/util/AbstractTestCase.java
index 47a12b2..2908a41 100644
--- a/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/util/AbstractTestCase.java
+++ b/org.eclipse.rmf.reqif10.tests/src/org/eclipse/rmf/reqif10/tests/util/AbstractTestCase.java
@@ -6,12 +6,13 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Mark Bršrkens - initial API and implementation
+ * Mark Broerkens - initial API and implementation
*
*/
package org.eclipse.rmf.reqif10.tests.util;
import java.io.IOException;
+import java.util.Map;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
@@ -24,8 +25,10 @@ import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.rmf.reqif10.ReqIF;
+import org.eclipse.rmf.reqif10.ReqIF10Package;
import org.eclipse.rmf.serialization.ReqIFResourceFactoryImpl;
import org.eclipse.rmf.serialization.ReqIFResourceSetImpl;
@@ -33,7 +36,7 @@ public class AbstractTestCase {
public void validateAgainstSchema(String filename) throws Exception {
- StreamSource[] schemaDocuments = new StreamSource[]{new StreamSource("schema/ReqIF.xsd")};
+ StreamSource[] schemaDocuments = new StreamSource[]{new StreamSource("schema/reqif.xsd")};
//StreamSource[] schemaDocuments = new StreamSource[]{new StreamSource("http://www.omg.org/spec/ReqIF/20110401/ReqIF.xsd")};
Source instanceDocument = new StreamSource(filename);
@@ -44,27 +47,23 @@ public class AbstractTestCase {
v.validate(instanceDocument);
}
- public static void saveReqIFFile(ReqIF ReqIF, String fileName) throws IOException {
+ public static void saveReqIFFile(ReqIF reqif, String fileName) throws IOException {
+ ReqIFResourceSetImpl resourceSet = getReqIFResourceSet();
+
URI emfURI = createEMFURI(fileName);
- ReqIFResourceFactoryImpl resourceFactory = new ReqIFResourceFactoryImpl();
- ReqIFResourceSetImpl resourceSet = new ReqIFResourceSetImpl();
- Resource resource = resourceFactory.createResource(emfURI);
- resourceSet.getResources().add(resource);
- resource.getContents().add(ReqIF);
+ Resource resource = resourceSet.createResource(emfURI);
+
+ resource.getContents().add(reqif);
resource.save(null);
- resourceSet = null;
}
- public static ReqIF loadReqIFFile(String fileName) throws IOException {
+ public static ReqIF loadReqIFFile(String fileName) throws IOException {
+ ReqIFResourceSetImpl resourceSet = getReqIFResourceSet();
URI emfURI = createEMFURI(fileName);
- ReqIFResourceFactoryImpl resourceFactory = new ReqIFResourceFactoryImpl();
- XMLResource resource = (XMLResource) resourceFactory.createResource(emfURI);
+ XMLResource resource = (XMLResource) resourceSet.createResource(emfURI);
resource.load(null);
-
- ReqIFResourceSetImpl resourceSet = new ReqIFResourceSetImpl();
- resourceSet.getResources().add(resource);
EList<EObject> rootObjects = resource.getContents();
@@ -74,6 +73,13 @@ public class AbstractTestCase {
return (ReqIF)rootObjects.get(0);
}
}
+
+ private static ReqIFResourceSetImpl getReqIFResourceSet() {
+ ReqIFResourceSetImpl resourceSet = new ReqIFResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("reqif", new ReqIFResourceFactoryImpl());
+ resourceSet.getPackageRegistry().put(ReqIF10Package.eNS_URI, ReqIF10Package.eINSTANCE);
+ return resourceSet;
+ }
private static URI createEMFURI(String fileName) {
return URI.createURI(fileName, true);