Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.jet.tests')
-rw-r--r--tests/org.eclipse.jet.tests/data/beanModel.xml21
-rw-r--r--tests/org.eclipse.jet.tests/data/beanModel.xsd39
-rw-r--r--tests/org.eclipse.jet.tests/data/newproject.xml4
-rw-r--r--tests/org.eclipse.jet.tests/data/newproject.xsd81
-rw-r--r--tests/org.eclipse.jet.tests/data/plain.xml21
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java3
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java68
7 files changed, 236 insertions, 1 deletions
diff --git a/tests/org.eclipse.jet.tests/data/beanModel.xml b/tests/org.eclipse.jet.tests/data/beanModel.xml
new file mode 100644
index 0000000..fb8d74c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/beanModel.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="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/beanModel.xsd b/tests/org.eclipse.jet.tests/data/beanModel.xsd
new file mode 100644
index 0000000..13a285a
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/beanModel.xsd
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+
+ <xsd:complexType name="root">
+ <xsd:sequence>
+ <xsd:element name="beanModel" type="beanModel" maxOccurs="unbounded" minOccurs="0"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="project">
+ <xsd:sequence>
+ <xsd:element name="beanModel" type="beanModel" maxOccurs="unbounded" minOccurs="0"></xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"></xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="beanModel">
+ <xsd:sequence>
+ <xsd:element name="bean" type="bean" maxOccurs="unbounded" minOccurs="0"></xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"></xsd:attribute>
+ <xsd:attribute name="basePackage" type="xsd:string"></xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="bean">
+ <xsd:sequence>
+ <xsd:element name="attribute" type="attribute" maxOccurs="unbounded" minOccurs="0"></xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"></xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:complexType name="attribute">
+ <xsd:attribute name="name" type="xsd:string"></xsd:attribute>
+ <xsd:attribute name="type" type="xsd:string"></xsd:attribute>
+ <xsd:attribute name="kind" type="xsd:string"></xsd:attribute>
+ </xsd:complexType>
+
+ <xsd:element name="root" type="root"></xsd:element>
+</xsd:schema> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/newproject.xml b/tests/org.eclipse.jet.tests/data/newproject.xml
new file mode 100644
index 0000000..08c4b03
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/newproject.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" xsi:schemaLocation="org.eclipse.jet.transforms.newproject newproject.xsd ">
+ <project name="test3.foo.bar"/> <!-- HELLO -->
+</p:newProjectModel>
diff --git a/tests/org.eclipse.jet.tests/data/newproject.xsd b/tests/org.eclipse.jet.tests/data/newproject.xsd
new file mode 100644
index 0000000..55c11d1
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/newproject.xsd
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="org.eclipse.jet.transforms.newproject" xmlns="org.eclipse.jet.transforms.newproject">
+
+ <xsd:element name="newProjectModel" type="newProjectModel"></xsd:element>
+
+ <xsd:complexType name="newProjectModel">
+ <xsd:sequence minOccurs="1">
+ <xsd:element name="project" type="project" minOccurs="1"
+ maxOccurs="1">
+ </xsd:element>
+ <xsd:any namespace="##other" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="project">
+ <xsd:attribute name="name" type="xsd:string" use="required"></xsd:attribute>
+ <xsd:attribute name="bundleName" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The display name of the resulting JET project. If
+ not specified, this defaults to the value specified
+ in the 'name' parameter.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="bundleSymbolicName" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The id of the JET project. If not specified, this
+ defaults to the name of the project.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="bundleVersion" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The initial version number of the project. If not
+ specified, this defaults to 1.0.0.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="bundleVendor" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The Vendor of the JET Project. If not specified,
+ this defaults to the empty string.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="binDir" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>
+ The directory which will contain binary (compiled)
+ Java classes. If not specified, the default is
+ 'bin'.
+ </xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="jet2javaDir" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>The directory into which Java source files corresponding to JET templates will be written. The default is 'jet2java'.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="templatesDir" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>The directory to which initial tempates will be written. The default if 'templates'.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="templateLoader" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>The fully qualified Java Class name of the template loader class. The default is 'org.eclipse.jet.compiled._jet_transformation'.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:attribute name="startTemplate" type="xsd:string" use="optional">
+ <xsd:annotation>
+ <xsd:documentation>The path of the start template. This path is relative the the tempates directory specified by templatesDir. The default is 'main.jet'.</xsd:documentation>
+ </xsd:annotation>
+ </xsd:attribute>
+ <xsd:anyAttribute namespace="##other"></xsd:anyAttribute>
+ </xsd:complexType>
+</xsd:schema> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/plain.xml b/tests/org.eclipse.jet.tests/data/plain.xml
new file mode 100644
index 0000000..254246d
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/plain.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Root1>
+ <beanModel1 basePackage="org.example" name="Library">
+ <bean1 name="Library">
+ <attribute1 kind="FIELD" name="name" type="String"/>
+ <attribute1 kind="FIELD" name="yearFounded" type="int"/>
+ <attribute1 kind="DERIVED" name="yearsOpen" type="int"/>
+ <attribute1 kind="LIST" name="books" type="Book"/>
+ <attribute1 kind="LIST" name="authors" type="Author"/>
+ </bean1>
+ <bean1 name="Book">
+ <attribute1 kind="FIELD" name="title" type="String"/>
+ <attribute1 kind="FIELD" name="pages" type="int"/>
+ <attribute1 kind="LIST" name="author" type="Author"/>
+ </bean1>
+ <bean1 name="Author">
+ <attribute1 kind="FIELD" name="name" type="String"/>
+ <attribute1 kind="LIST" name="books" type="Book"/>
+ </bean1>
+ </beanModel1>
+</Root1> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java
index f2d2180..465fb9e 100644
--- a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java
@@ -9,8 +9,9 @@ public class AllTests {
TestSuite suite = new TestSuite(
"Test for org.eclipse.jet.tests.model.load");
//$JUnit-BEGIN$
- suite.addTestSuite(EmfModelLoaderTests.class);
suite.addTestSuite(WorkspaceContextTests.class);
+ suite.addTestSuite(TestXMLDocumentLoads.class);
+ suite.addTestSuite(EmfModelLoaderTests.class);
//$JUnit-END$
return suite;
}
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
new file mode 100644
index 0000000..db8e8e2
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/TestXMLDocumentLoads.java
@@ -0,0 +1,68 @@
+package org.eclipse.jet.tests.model.load;
+
+import java.io.IOException;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.jet.internal.runtime.model.EMFXMLModelLoader;
+
+public class TestXMLDocumentLoads extends TestCase {
+
+
+ private EMFXMLModelLoader loader;
+
+ protected void setUp() throws Exception {
+ // TODO Auto-generated method stub
+ super.setUp();
+
+ loader = new EMFXMLModelLoader();
+ }
+
+ /**
+ * 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 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 {
+ final int pkgRegSz = EPackage.Registry.INSTANCE.size();
+
+ URL plainURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/plain.xml");
+
+ final Object plainModel1 = loader.load(plainURL);
+ assertNotNull(plainModel1);
+
+ assertEquals(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());
+
+ 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());
+
+ final Object plainModel2 = loader.load(plainURL);
+ assertNotNull(plainModel2);
+
+ assertEquals(pkgRegSz, EPackage.Registry.INSTANCE.size());
+
+
+ }
+}

Back to the top