Skip to main content
summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorpelder2007-05-02 13:15:48 -0400
committerpelder2007-05-02 13:15:48 -0400
commitc4bc0a1084f23db6eeabd41798a45f407a9cb922 (patch)
tree4861d0a1ab68e5eb2d24f0d7be476e08a8171a3f /tests
parent0207798868de8a3925deeb32cfb42e2257c37100 (diff)
downloadorg.eclipse.jet-c4bc0a1084f23db6eeabd41798a45f407a9cb922.tar.gz
org.eclipse.jet-c4bc0a1084f23db6eeabd41798a45f407a9cb922.tar.xz
org.eclipse.jet-c4bc0a1084f23db6eeabd41798a45f407a9cb922.zip
[185143] Enable document XML loading to proceed without errors, in the case where no schema location is specified.
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.jet.tests/data/beanModel.badlocation.xml21
-rw-r--r--tests/org.eclipse.jet.tests/data/newproject.nolocation.xml4
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java75
3 files changed, 85 insertions, 15 deletions
diff --git a/tests/org.eclipse.jet.tests/data/beanModel.badlocation.xml b/tests/org.eclipse.jet.tests/data/beanModel.badlocation.xml
new file mode 100644
index 0000000..e819cbf
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/beanModel.badlocation.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="missing.beanModel.xsd">
+ <beanModel basePackage="org.example" name="Library">
+ <bean name="Library">
+ <attribute kind="FIELD" name="name" type="String"/>
+ <attribute kind="FIELD" name="yearFounded" type="int"/>
+ <attribute kind="DERIVED" name="yearsOpen" type="int"/>
+ <attribute kind="LIST" name="books" type="Book"/>
+ <attribute kind="LIST" name="authors" type="Author"/>
+ </bean>
+ <bean name="Book">
+ <attribute kind="FIELD" name="title" type="String"/>
+ <attribute kind="FIELD" name="pages" type="int"/>
+ <attribute kind="LIST" name="author" type="Author"/>
+ </bean>
+ <bean name="Author">
+ <attribute kind="FIELD" name="name" type="String"/>
+ <attribute kind="LIST" name="books" type="Book"/>
+ </bean>
+ </beanModel>
+</root>
diff --git a/tests/org.eclipse.jet.tests/data/newproject.nolocation.xml b/tests/org.eclipse.jet.tests/data/newproject.nolocation.xml
new file mode 100644
index 0000000..28ae5f1
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/newproject.nolocation.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<p:newProjectModel xmlns:p="org.eclipse.jet.transforms.newproject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <project name="test3.foo.bar"/> <!-- HELLO -->
+</p:newProjectModel>
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java
index db8e8e2..52cf8b0 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java
@@ -1,6 +1,7 @@
package org.eclipse.jet.tests.model.load;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
import junit.framework.TestCase;
@@ -26,17 +27,7 @@ public class TestXMLDocumentLoads extends TestCase {
* for XSD schemas without a target namespace.
* @throws IOException
*/
- public void testOne() throws IOException {
- testVerifyXMLLoadsDoNotAffectGlobalPackageRegistry();
- }
-
- /**
- * This test verifies the the XML Model loader does not put dynamically loaded
- * XSD packages in the the default package registry. This is especially important
- * for XSD schemas without a target namespace.
- * @throws IOException
- */
- public void testVerifyXMLLoadsDoNotAffectGlobalPackageRegistry() throws IOException {
+ public void testPlainXML() throws IOException {
final int pkgRegSz = EPackage.Registry.INSTANCE.size();
URL plainURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/plain.xml");
@@ -45,24 +36,78 @@ public class TestXMLDocumentLoads extends TestCase {
assertNotNull(plainModel1);
assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
+
+ final Object plainModel2 = loader.load(plainURL);
+ assertNotNull(plainModel2);
+
+ assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
+ }
+
+ /**
+ * This test verifies the the XML Model loader does not put dynamically loaded
+ * XSD packages in the the default package registry. This is especially important
+ * for XSD schemas without a target namespace.
+ * @throws IOException
+ */
+ public void testXML_knownSchema_schemaLocation() throws IOException {
+ final int pkgRegSz = EPackage.Registry.INSTANCE.size();
URL newProjectURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/newproject.xml");
final Object newProjectModel = loader.load(newProjectURL);
assertNotNull(newProjectModel);
assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
+ }
+
+ /**
+ * This test verifies the the XML Model loader does not put dynamically loaded
+ * XSD packages in the the default package registry. This is especially important
+ * for XSD schemas without a target namespace.
+ * @throws IOException
+ */
+ public void testXML_knownSchema_noNamespaceSchemaLocation() throws IOException {
+ final int pkgRegSz = EPackage.Registry.INSTANCE.size();
URL beanModelURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/beanModel.xml");
final Object beanModel = loader.load(beanModelURL);
assertNotNull(beanModel);
assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
+ }
+
+ /**
+ * This test verifies the the XML Model loader does not put dynamically loaded
+ * XSD packages in the the default package registry. This is especially important
+ * for XSD schemas without a target namespace.
+ * @throws IOException
+ */
+ public void testXML_unknownSchema() throws IOException {
+ final int pkgRegSz = EPackage.Registry.INSTANCE.size();
- final Object plainModel2 = loader.load(plainURL);
- assertNotNull(plainModel2);
+ URL newProjectURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/newproject.nolocation.xml");
+ final Object newProjectModel = loader.load(newProjectURL);
+ assertNotNull(newProjectModel);
assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
-
-
}
+
+ /**
+ * This test verifies the the XML Model loader does not put dynamically loaded
+ * XSD packages in the the default package registry. This is especially important
+ * for XSD schemas without a target namespace.
+ * @throws MalformedURLException
+ */
+ public void testXML_missingSchema_noNamespace() throws MalformedURLException {
+ try {
+ URL beanModelURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/beanModel.badlocation.xml");
+ loader.load(beanModelURL);
+ fail();
+ } catch (MalformedURLException e) {
+ throw e;
+ } catch (IOException e) {
+ // success
+ }
+ }
+
+
}

Back to the top