summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-02-24 14:19:03 (EST)
committer pelder2006-02-24 14:19:03 (EST)
commitcf44b010c9f9e75f08f52dca3fe9e34e7ff57205 (patch)
tree1436f903691e7a5e230cea2b1549f52326e09639
parent79d9bb81ecd0f91b46087d61dac630f0d1bd6ddb (diff)
downloadorg.eclipse.jet-cf44b010c9f9e75f08f52dca3fe9e34e7ff57205.zip
org.eclipse.jet-cf44b010c9f9e75f08f52dca3fe9e34e7ff57205.tar.gz
org.eclipse.jet-cf44b010c9f9e75f08f52dca3fe9e34e7ff57205.tar.bz2
Initial commit
-rw-r--r--plugins/org.eclipse.jet.ui/.classpath7
-rw-r--r--plugins/org.eclipse.jet.ui/.cvsignore1
-rw-r--r--plugins/org.eclipse.jet.ui/.project28
-rw-r--r--plugins/org.eclipse.jet.ui/.settings/org.eclipse.core.resources.prefs3
-rw-r--r--plugins/org.eclipse.jet.ui/META-INF/MANIFEST.MF18
-rw-r--r--plugins/org.eclipse.jet.ui/about.html24
-rw-r--r--plugins/org.eclipse.jet.ui/build.properties9
-rw-r--r--plugins/org.eclipse.jet.ui/icons/JET2File.gifbin0 -> 907 bytes
-rw-r--r--plugins/org.eclipse.jet.ui/icons/JET2LaunchIcon.gifbin0 -> 907 bytes
-rw-r--r--plugins/org.eclipse.jet.ui/icons/JET2Project.gifbin0 -> 957 bytes
-rw-r--r--plugins/org.eclipse.jet.ui/icons/JET2ProjectWizard.gifbin0 -> 597 bytes
-rw-r--r--plugins/org.eclipse.jet.ui/icons/JET2ProjectWizardBanner.gifbin0 -> 3180 bytes
-rw-r--r--plugins/org.eclipse.jet.ui/icons/JETRuntimeError.gifbin0 -> 1717 bytes
-rw-r--r--plugins/org.eclipse.jet.ui/icons/sample.gifbin0 -> 983 bytes
-rw-r--r--plugins/org.eclipse.jet.ui/plugin.properties31
-rw-r--r--plugins/org.eclipse.jet.ui/plugin.xml97
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/filters/JavaFilter.java77
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/Messages.java43
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/messages.properties27
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformMainTab.java166
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformationTabGroup.java48
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/LaunchShortcut.java112
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/popup/actions/UnloadAction.java81
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/Activator.java55
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewProjectInfo.java83
-rw-r--r--plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewProjectWizard.java102
-rw-r--r--tests/org.eclipse.jet.tests/.classpath7
-rw-r--r--tests/org.eclipse.jet.tests/.cvsignore1
-rw-r--r--tests/org.eclipse.jet.tests/.project28
-rw-r--r--tests/org.eclipse.jet.tests/.settings/org.eclipse.core.resources.prefs6
-rw-r--r--tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.core.prefs49
-rw-r--r--tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF13
-rw-r--r--tests/org.eclipse.jet.tests/about.html24
-rw-r--r--tests/org.eclipse.jet.tests/build.properties8
-rw-r--r--tests/org.eclipse.jet.tests/data/DOMInspector.xml11
-rw-r--r--tests/org.eclipse.jet.tests/data/alljet2.jet34
-rw-r--r--tests/org.eclipse.jet.tests/data/alljet2.jet.expected93
-rw-r--r--tests/org.eclipse.jet.tests/data/bean.model.sample.xml22
-rw-r--r--tests/org.eclipse.jet.tests/data/beans.xsd42
-rw-r--r--tests/org.eclipse.jet.tests/data/dm-example.xml37
-rw-r--r--tests/org.eclipse.jet.tests/data/dm-example.xsd145
-rw-r--r--tests/org.eclipse.jet.tests/data/jetast.ecore97
-rw-r--r--tests/org.eclipse.jet.tests/data/library.xml25
-rw-r--r--tests/org.eclipse.jet.tests/data/library.xml.indisguise25
-rw-r--r--tests/org.eclipse.jet.tests/data/sample.dataaccess10
-rw-r--r--tests/org.eclipse.jet.tests/data/taglibs.jet10
-rw-r--r--tests/org.eclipse.jet.tests/data/taglibs.jet.astdump.expected46
-rw-r--r--tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java94
-rw-r--r--tests/org.eclipse.jet.tests/data/unclosedComment.jet3
-rw-r--r--tests/org.eclipse.jet.tests/data/unclosedDeclaration.jet3
-rw-r--r--tests/org.eclipse.jet.tests/data/unclosedDirective.jet1
-rw-r--r--tests/org.eclipse.jet.tests/data/unclosedExpression.jet3
-rw-r--r--tests/org.eclipse.jet.tests/data/unclosedScriplet.jet3
-rw-r--r--tests/org.eclipse.jet.tests/data/unclosedXMLEnd.jet3
-rw-r--r--tests/org.eclipse.jet.tests/data/unclosedXMLStart.jet3
-rw-r--r--tests/org.eclipse.jet.tests/data/xmlEndWithAttributes.jet3
-rw-r--r--tests/org.eclipse.jet.tests/data/xmlStartWithoutEnd.jet8
-rw-r--r--tests/org.eclipse.jet.tests/model/dataAccess.ecore24
-rw-r--r--tests/org.eclipse.jet.tests/model/dataAccess.genmodel25
-rw-r--r--tests/org.eclipse.jet.tests/plugin.properties20
-rw-r--r--tests/org.eclipse.jet.tests/plugin.xml48
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/Customer.java44
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/DataAccessFactory.java73
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/DataAccessPackage.java503
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/Employee.java71
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/Order.java110
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/Person.java81
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/impl/CustomerImpl.java147
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/impl/DataAccessFactoryImpl.java130
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/impl/DataAccessPackageImpl.java327
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/impl/EmployeeImpl.java217
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/impl/OrderImpl.java271
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/impl/PersonImpl.java215
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/util/DataAccessAdapterFactory.java171
-rw-r--r--tests/org.eclipse.jet.tests/src/dataAccess/util/DataAccessSwitch.java195
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java22
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/AllTests.java18
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java245
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java391
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java18
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/EmfModelLoaderTests.java82
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/WorkspaceContextTests.java37
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/AllTests.java17
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleLoading.java31
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/AllTests.java17
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/TestTagLibManager.java58
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/AllTests.java17
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java49
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AbstractExprTest.java93
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java40
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AttributeStepTests.java71
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/BooleanFunctionTests.java61
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/BuiltinStringFunctionsTests.java214
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ChildStepTests.java145
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DOMInspectorTests.java184
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java826
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EStructuralFeatureSettingTests.java113
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ExpandedNameTests.java88
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/LogicalOpTests.java54
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/NumberBinaryOpTests.java63
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/NumberFunctionTests.java39
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ParentStepTests.java84
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/RelOpTests.java156
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ResourceInspectorTests.java116
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/RootTests.java82
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/StringFunctionTests.java61
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/VariableTests.java86
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathInspectorManagerTests.java45
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverDOMTests.java113
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverEcoreTests.java44
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverEmfXmlXsdTests.java127
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathParserDefects.java35
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathParserTests.java768
-rw-r--r--tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathTokenScannerTests.java251
114 files changed, 9502 insertions, 0 deletions
diff --git a/plugins/org.eclipse.jet.ui/.classpath b/plugins/org.eclipse.jet.ui/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.jet.ui/.cvsignore b/plugins/org.eclipse.jet.ui/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/plugins/org.eclipse.jet.ui/.project b/plugins/org.eclipse.jet.ui/.project
new file mode 100644
index 0000000..337c3aa
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jet.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.jet.ui/.settings/org.eclipse.core.resources.prefs b/plugins/org.eclipse.jet.ui/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..0d55ce5
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Thu Feb 23 13:40:34 EST 2006
+eclipse.preferences.version=1
+encoding//src/org/eclipse/jet/internal/ui/l10n/messages.properties=8859_1
diff --git a/plugins/org.eclipse.jet.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.jet.ui/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..4e2b013
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/META-INF/MANIFEST.MF
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %pluginName
+Bundle-SymbolicName: org.eclipse.jet.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.jet.ui.Activator
+Bundle-Vendor: %providerName
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.resources,
+ org.eclipse.core.runtime,
+ org.eclipse.jet,
+ org.eclipse.debug.ui,
+ org.eclipse.debug.core,
+ org.eclipse.ui,
+ org.eclipse.ui.ide,
+ org.eclipse.jdt.core
+Eclipse-AutoStart: true
+Export-Package: org.eclipse.jet.ui.newproject
diff --git a/plugins/org.eclipse.jet.ui/about.html b/plugins/org.eclipse.jet.ui/about.html
new file mode 100644
index 0000000..1c0db85
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>February 22, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
+
+</body>
+</html>
+
diff --git a/plugins/org.eclipse.jet.ui/build.properties b/plugins/org.eclipse.jet.ui/build.properties
new file mode 100644
index 0000000..c52dd5f
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/build.properties
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml,\
+ icons/,\
+ plugin.properties,\
+ about.html
+src.includes = about.html
diff --git a/plugins/org.eclipse.jet.ui/icons/JET2File.gif b/plugins/org.eclipse.jet.ui/icons/JET2File.gif
new file mode 100644
index 0000000..9dda7ef
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/icons/JET2File.gif
Binary files differ
diff --git a/plugins/org.eclipse.jet.ui/icons/JET2LaunchIcon.gif b/plugins/org.eclipse.jet.ui/icons/JET2LaunchIcon.gif
new file mode 100644
index 0000000..9dda7ef
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/icons/JET2LaunchIcon.gif
Binary files differ
diff --git a/plugins/org.eclipse.jet.ui/icons/JET2Project.gif b/plugins/org.eclipse.jet.ui/icons/JET2Project.gif
new file mode 100644
index 0000000..1f2dd63
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/icons/JET2Project.gif
Binary files differ
diff --git a/plugins/org.eclipse.jet.ui/icons/JET2ProjectWizard.gif b/plugins/org.eclipse.jet.ui/icons/JET2ProjectWizard.gif
new file mode 100644
index 0000000..8d97ee5
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/icons/JET2ProjectWizard.gif
Binary files differ
diff --git a/plugins/org.eclipse.jet.ui/icons/JET2ProjectWizardBanner.gif b/plugins/org.eclipse.jet.ui/icons/JET2ProjectWizardBanner.gif
new file mode 100644
index 0000000..945a6f5
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/icons/JET2ProjectWizardBanner.gif
Binary files differ
diff --git a/plugins/org.eclipse.jet.ui/icons/JETRuntimeError.gif b/plugins/org.eclipse.jet.ui/icons/JETRuntimeError.gif
new file mode 100644
index 0000000..260d27f
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/icons/JETRuntimeError.gif
Binary files differ
diff --git a/plugins/org.eclipse.jet.ui/icons/sample.gif b/plugins/org.eclipse.jet.ui/icons/sample.gif
new file mode 100644
index 0000000..34fb3c9
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/icons/sample.gif
Binary files differ
diff --git a/plugins/org.eclipse.jet.ui/plugin.properties b/plugins/org.eclipse.jet.ui/plugin.properties
new file mode 100644
index 0000000..6cbf525
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/plugin.properties
@@ -0,0 +1,31 @@
+###############################################################################
+# Copyright (c) 2005, 2006 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+pluginName = JET Transforms UI Plug-in
+providerName = IBM
+
+newWizards.jet2Project.name = JET Transform Project
+newWizards.jet2Project.description = Create a JET Transform Project
+
+editors.jet2.name = JET Editor
+
+editorTemplates.name = JET Template
+
+preferencePages.jet2.name = JET Preferences
+preferencePages.templates.name = Templates
+
+javaElementFilters.javaInJET2Projects.name = Java elements from JET Transform projects
+javaElementFilters.javaInJET2Projects.description = Hide Java elements such as Java source folders and reference libraries from JET Transform projects
+
+popupMenus.group.jet2Debug = JET Debug
+popupMenus.action.unload = Unload
+
+launchShortcut.label = JET Transform
+launchShortcut.contextLabel = Input for JET Transform \ No newline at end of file
diff --git a/plugins/org.eclipse.jet.ui/plugin.xml b/plugins/org.eclipse.jet.ui/plugin.xml
new file mode 100644
index 0000000..2958e80
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/plugin.xml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+ <launchConfigurationTabGroup
+ class="org.eclipse.jet.internal.ui.launch.JET2TransformationTabGroup"
+ id="org.eclipse.jet.ui.launch.jet2Transformation.tabgroup"
+ type="org.eclipse.jet.jet2Transformation"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+ <launchConfigurationTypeImage
+ configTypeID="org.eclipse.jet.jet2Transformation"
+ icon="icons/JET2LaunchIcon.gif"
+ id="org.eclipse.jet.ui.launch.jet2Transformation.icon"/>
+ </extension>
+ <extension
+ point="org.eclipse.debug.ui.launchShortcuts">
+ <shortcut
+ class="org.eclipse.jet.internal.ui.launch.LaunchShortcut"
+ icon="icons/JET2LaunchIcon.gif"
+ id="org.eclipse.jet.ui.shortcut1"
+ label="%launchShortcut.label"
+ modes="run">
+ <contextualLaunch>
+ <contextLabel
+ label="%launchShortcut.contextLabel"
+ mode="run"/>
+ <enablement>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate operator="or">
+ <test
+ property="org.eclipse.debug.ui.matchesPattern"
+ value="*.xml"/>
+ </iterate>
+ </with>
+ </enablement>
+ </contextualLaunch>
+ <perspective id="org.eclipse.jdt.ui.JavaPerspective"/>
+ <perspective id="org.eclipse.ui.resourcePerspective"/>
+ </shortcut>
+ </extension>
+ <extension
+ point="org.eclipse.jdt.ui.javaElementFilters">
+ <filter
+ class="org.eclipse.jet.internal.ui.filters.JavaFilter"
+ description="%javaElementFilters.javaInJET2Projects.description"
+ enabled="true"
+ id="org.eclipse.jet.javafilter"
+ name="%javaElementFilters.javaInJET2Projects.name"
+ targetId="org.eclipse.jdt.ui.PackageExplorer"/>
+ </extension>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ category="org.eclipse.emf.codegen.ui.JETNewWizards"
+ class="org.eclipse.jet.ui.newproject.NewProjectWizard"
+ descriptionImage="icons/JET2ProjectWizardBanner.gif"
+ hasPages="true"
+ icon="icons/JET2ProjectWizard.gif"
+ id="org.eclipse.jet.ui.newJet2ProjectWizard"
+ name="%newWizards.jet2Project.name"
+ project="true">
+ <description>Create a JET2 Project</description>
+ </wizard>
+ </extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <objectContribution
+ adaptable="true"
+ id="org.eclipse.jet.ui.contribution1"
+ nameFilter="*"
+ objectClass="org.eclipse.core.resources.IProject">
+ <menu
+ id="org.eclipse.jet.ui.menu1"
+ label="%popupMenus.group.jet2Debug"
+ path="additions">
+ <separator name="group1"/>
+ </menu>
+ <action
+ class="org.eclipse.jet.internal.ui.popup.actions.UnloadAction"
+ enablesFor="1"
+ id="org.eclipse.jet.ui.newAction"
+ label="%popupMenus.action.unload"
+ menubarPath="org.eclipse.jet.ui.menu1/group1"/>
+ <visibility>
+ <objectState
+ name="nature"
+ value="org.eclipse.jet.jet2Nature"/>
+ </visibility>
+ </objectContribution>
+ </extension>
+
+
+</plugin>
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/filters/JavaFilter.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/filters/JavaFilter.java
new file mode 100644
index 0000000..160acc0
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/filters/JavaFilter.java
@@ -0,0 +1,77 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.internal.ui.filters;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jet.JET2Platform;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * Filter Java elements from the Package Explorer view for JET2 projects.
+ *
+ */
+public class JavaFilter extends ViewerFilter {
+
+ /**
+ *
+ */
+ public JavaFilter() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ final boolean isJET2Project = isJET2Project(parentElement);
+ // Note: ClassPathContainer is a JDT internal class - it doesn't implement
+ // any useful public interfacts (IAdapter and IWorkspaceAdapter only). To
+ // avoid a direct internal dependency, we check the class name instead of
+ // doing an instanceof. The risk is that JDT will refactor, and we will loose
+ // this feature.
+ if (element.getClass().getName().endsWith(".ClassPathContainer") && isJET2Project) { //$NON-NLS-1$
+ return false;
+ }
+ if(element instanceof IPackageFragmentRoot && isJET2Project) {
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * @param element
+ * @return
+ * @throws CoreException
+ */
+ private boolean isJET2Project(Object element) {
+ if(element instanceof IJavaProject) {
+ IJavaProject jp = (IJavaProject)element;
+ try {
+ return jp.getProject().hasNature(JET2Platform.JET2_NATURE_ID);
+ } catch (CoreException e) {
+ // No action required:
+ // only happens if the project doesn't exist. But we won't get here unless the project does
+ }
+ }
+ return false;
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/Messages.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/Messages.java
new file mode 100644
index 0000000..0f15ec2
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/Messages.java
@@ -0,0 +1,43 @@
+package org.eclipse.jet.internal.ui.l10n;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.jet.internal.ui.l10n.messages"; //$NON-NLS-1$
+
+ private Messages() {
+ }
+
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ public static String NewProjectWizard_WindowTitle;
+
+ public static String NewProjectWizard_ErrorCreatingProject;
+
+ public static String NewProjectWizard_MainPageTabText;
+
+ public static String NewProjectWizard_MainPageTitle;
+
+ public static String NewProjectWizard_MainPageDescription;
+
+ public static String LaunchWizard_MainTab_TransformIdText;
+
+ public static String LaunchWizard_MainTab_SourceText;
+
+ public static String LaunchWizard_MainTab_Name;
+
+ public static String JET2TemplateAccess_ErrorLoadingTemplateStore;
+
+ public static String UnloadAction_DialogTitle;
+
+ public static String UnloadAction_UnloadSuccessful;
+
+ public static String UnloadAction_UnloadFailed;
+
+ public static String UnloadAction_NotLoaded;
+
+ public static String NewProjectWizard_ErrorInJETTransform;
+}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/messages.properties b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/messages.properties
new file mode 100644
index 0000000..5028284
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/l10n/messages.properties
@@ -0,0 +1,27 @@
+###############################################################################
+# Copyright (c) 2005, 2006 IBM Corporation and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+# IBM Corporation - initial API and implementation
+###############################################################################
+NewProjectWizard_WindowTitle=New JET Transform Project
+NewProjectWizard_ErrorCreatingProject=Error attempting to create project
+NewProjectWizard_ErrorInJETTransform=The JET transform that creates the new project had execution errors
+NewProjectWizard_MainPageTabText=Main
+NewProjectWizard_MainPageTitle=JET Transform Project
+NewProjectWizard_MainPageDescription=Create a JET Transform Project in the workspace.
+
+LaunchWizard_MainTab_TransformIdText=Transform id:
+LaunchWizard_MainTab_SourceText=Source:
+LaunchWizard_MainTab_Name=Main
+
+JET2TemplateAccess_ErrorLoadingTemplateStore=Error loading editor template store.
+
+UnloadAction_DialogTitle=Unload JET Transform
+UnloadAction_UnloadSuccessful=Unloaded "{0}". Refresh the Plugins View to confirm success.
+UnloadAction_UnloadFailed=Failed to unloaded "{0}". Reason: {1}.
+UnloadAction_NotLoaded=Bundle is not loaded "{0}". No action was taken.
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformMainTab.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformMainTab.java
new file mode 100644
index 0000000..94519a7
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformMainTab.java
@@ -0,0 +1,166 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.internal.ui.launch;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.jet.JET2Platform;
+import org.eclipse.jet.internal.launch.JET2TransformationDelegate;
+import org.eclipse.jet.internal.ui.l10n.Messages;
+import org.eclipse.jet.ui.Activator;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Main tab for JET Transform Launch configuration
+ *
+ */
+public class JET2TransformMainTab extends AbstractLaunchConfigurationTab
+ implements ILaunchConfigurationTab {
+
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ private Text idText;
+ private Text sourceText;
+ private Image tabImage = null;
+
+ /**
+ *
+ */
+ public JET2TransformMainTab() {
+ super();
+ }
+
+ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
+ ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
+
+ IFile resource = null;
+
+ if(selection instanceof IStructuredSelection) {
+ IStructuredSelection iss = (IStructuredSelection) selection;
+ Object firstElement = iss.getFirstElement();
+ if(firstElement instanceof IFile) {
+ resource = (IFile)firstElement;
+ } else if (firstElement instanceof IAdaptable) {
+ resource = (IFile) ((IAdaptable)firstElement).getAdapter(IFile.class);
+ }
+ }
+ if(resource != null) {
+ configuration.setAttribute(JET2TransformationDelegate.SOURCE,
+ resource.getFullPath().toString());
+
+ try {
+ if(resource.getProject().hasNature(JET2Platform.JET2_NATURE_ID))
+ {
+ // XXX Slight hack. Should get the id, not the name.
+ configuration.setAttribute(JET2TransformationDelegate.ID, resource.getProject().getName());
+ }
+ } catch (CoreException e) {
+ // just ignore the error, we know the project exists and is open, we have a
+ // file in it!
+ }
+ }
+ configuration.setAttribute(JET2TransformationDelegate.ID, EMPTY_STRING);
+ }
+
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ configuration.setAttribute(JET2TransformationDelegate.ID, idText.getText());
+
+ configuration.setAttribute(JET2TransformationDelegate.SOURCE, sourceText.getText());
+
+ }
+
+ public void createControl(Composite parent) {
+ Composite comp = new Composite(parent, SWT.NONE);
+ setControl(comp);
+ FormLayout formLayout = new FormLayout();
+ formLayout.marginHeight = 3;
+ formLayout.marginWidth = 3;
+ comp.setLayout(formLayout);
+
+ Label label = new Label(comp, SWT.NONE);
+ label.setText(Messages.LaunchWizard_MainTab_TransformIdText);
+ FormData data = new FormData();
+
+ idText = new Text(comp, SWT.SINGLE|SWT.BORDER);
+ data = new FormData();
+ data.left = new FormAttachment(label);
+ data.right = new FormAttachment(100,0);
+ idText.setLayoutData(data);
+
+ Label label2 = new Label(comp, SWT.NONE);
+ label2.setText(Messages.LaunchWizard_MainTab_SourceText);
+ data = new FormData();
+ data.top = new FormAttachment(label);
+ label2.setLayoutData(data);
+
+ sourceText = new Text(comp, SWT.SINGLE|SWT.BORDER);
+ data = new FormData();
+ data.left = new FormAttachment(label2);
+ data.top = new FormAttachment(idText);
+ data.right = new FormAttachment(100,0);
+ sourceText.setLayoutData(data);
+ }
+
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ try {
+ idText.setText(configuration.getAttribute(JET2TransformationDelegate.ID, EMPTY_STRING));
+ } catch (CoreException e) {
+ idText.setText(EMPTY_STRING);
+ }
+ try {
+ sourceText.setText(configuration.getAttribute(JET2TransformationDelegate.SOURCE, EMPTY_STRING));
+ } catch (CoreException e) {
+ sourceText.setText(EMPTY_STRING);
+ }
+
+ }
+
+ public String getName() {
+ return Messages.LaunchWizard_MainTab_Name;
+ }
+
+ public Image getImage() {
+ if(tabImage == null) {
+ ImageDescriptor imageDescriptor = Activator.getImageDescriptor("icons/JET2LaunchIcon.gif"); //$NON-NLS-1$
+ tabImage = imageDescriptor.createImage();
+ }
+ return tabImage;
+ }
+
+ public void dispose() {
+ if(tabImage != null) {
+ tabImage.dispose();
+ }
+ super.dispose();
+ }
+}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformationTabGroup.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformationTabGroup.java
new file mode 100644
index 0000000..ca81371
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/JET2TransformationTabGroup.java
@@ -0,0 +1,48 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.internal.ui.launch;
+
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+
+/**
+ * @author pelder
+ *
+ */
+public class JET2TransformationTabGroup extends
+ AbstractLaunchConfigurationTabGroup {
+
+ /**
+ *
+ */
+ public JET2TransformationTabGroup() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
+ new JET2TransformMainTab(),
+ new CommonTab(),
+ };
+
+ setTabs(tabs);
+ }
+}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/LaunchShortcut.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/LaunchShortcut.java
new file mode 100644
index 0000000..4a57a22
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/launch/LaunchShortcut.java
@@ -0,0 +1,112 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.internal.ui.launch;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.jet.JET2Platform;
+import org.eclipse.jet.internal.launch.JET2TransformationDelegate;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * Launch shortcut for launching JET transforms on an XML document.
+ *
+ */
+public class LaunchShortcut implements ILaunchShortcut {
+
+ /**
+ *
+ */
+ public LaunchShortcut() {
+ super();
+ // TODO Auto-generated constructor stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String)
+ */
+ public void launch(ISelection selection, String mode) {
+ // TODO Auto-generated method stub
+ if(!(selection instanceof IStructuredSelection)) {
+ return;
+ }
+ IResource resource = (IResource) ((IStructuredSelection)selection).getFirstElement();
+ findAndLaunch(resource, mode);
+ }
+
+ /**
+ * @param resource
+ * @param mode
+ */
+ private void findAndLaunch(IResource resource, String mode) {
+ ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
+ try {
+ final ILaunchConfigurationType configurationType = getConfigurationType();
+ final ILaunchConfiguration[] configs = lm.getLaunchConfigurations(configurationType);
+ for (int i = 0; i < configs.length; i++) {
+ if(resource.getFullPath().toString().equals(configs[i].getAttribute(JET2TransformationDelegate.SOURCE, (String)null))){
+ DebugUITools.launch(configs[i], mode);
+ return;
+ }
+ }
+
+ String id = ""; //$NON-NLS-1$
+ if(resource.getProject().hasNature(JET2Platform.JET2_NATURE_ID)) {
+ // XXX Hack should get project id.
+ id = resource.getProject().getName();
+ }
+
+ final ILaunchConfigurationWorkingCopy wConfig = configurationType
+ .newInstance(null, lm
+ .generateUniqueLaunchConfigurationNameFrom(id + " " + resource.getName())); //$NON-NLS-1$
+ wConfig.setAttribute(JET2TransformationDelegate.ID, id);
+ wConfig.setAttribute(JET2TransformationDelegate.SOURCE, resource.getFullPath().toString());
+ final ILaunchConfiguration config = wConfig.doSave();
+ DebugUITools.launch(config, mode);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private ILaunchConfigurationType getConfigurationType() {
+ ILaunchManager lm= DebugPlugin.getDefault().getLaunchManager();
+ return lm.getLaunchConfigurationType(JET2TransformationDelegate.CONFIG_ID);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
+ */
+ public void launch(IEditorPart editor, String mode) {
+ // TODO Auto-generated method stub
+ final IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
+ findAndLaunch(resource, mode);
+
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/popup/actions/UnloadAction.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/popup/actions/UnloadAction.java
new file mode 100644
index 0000000..3cb648a
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/internal/ui/popup/actions/UnloadAction.java
@@ -0,0 +1,81 @@
+package org.eclipse.jet.internal.ui.popup.actions;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jet.internal.InternalJET2Platform;
+import org.eclipse.jet.internal.runtime.TemplateBundleManager;
+import org.eclipse.jet.internal.ui.l10n.Messages;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+import org.osgi.framework.Bundle;
+
+public class UnloadAction implements IObjectActionDelegate {
+
+ private String bundleName;
+ /**
+ * Constructor for Action1.
+ */
+ public UnloadAction() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+ }
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ Shell shell = new Shell();
+ final TemplateBundleManager mgr = InternalJET2Platform.getDefault().getTransformBundleManager();
+ Bundle bundle = Platform.getBundle(bundleName);
+ final String DialogTitle = Messages.UnloadAction_DialogTitle;
+ if(bundle != null) {
+ try {
+ mgr.uninstallBundle(bundle);
+ MessageDialog.openInformation(
+ shell,
+ DialogTitle,
+ MessageFormat.format(Messages.UnloadAction_UnloadSuccessful, new Object[] {bundleName}));
+ } catch (CoreException e) {
+ e.printStackTrace();
+ MessageDialog.openInformation(
+ shell,
+ DialogTitle,
+ MessageFormat.format(Messages.UnloadAction_UnloadFailed, new Object[] {bundleName, e.toString()}));
+ }}
+ else {
+ MessageDialog.openInformation(
+ shell,
+ DialogTitle,
+ MessageFormat.format(Messages.UnloadAction_NotLoaded, new Object[] {bundleName}));
+
+ }
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ IStructuredSelection se = (IStructuredSelection) selection;
+
+ final Object firstElement = se.getFirstElement();
+ if(firstElement instanceof IProject) {
+ IProject project = (IProject) firstElement;
+ bundleName = project.getName();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/Activator.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/Activator.java
new file mode 100644
index 0000000..db5f4bb
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/Activator.java
@@ -0,0 +1,55 @@
+package org.eclipse.jet.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ */
+public class Activator extends AbstractUIPlugin {
+
+ //The shared instance.
+ private static Activator plugin;
+
+ /**
+ * The constructor.
+ */
+ public Activator() {
+ plugin = this;
+ }
+
+ /**
+ * This method is called upon plug-in activation
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ }
+
+ /**
+ * This method is called when the plug-in is stopped
+ */
+ public void stop(BundleContext context) throws Exception {
+ super.stop(context);
+ plugin = null;
+ }
+
+ /**
+ * Returns the shared instance.
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path.
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return AbstractUIPlugin.imageDescriptorFromPlugin(getDefault()
+ .getBundle().getSymbolicName(), path);
+ }
+}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewProjectInfo.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewProjectInfo.java
new file mode 100644
index 0000000..e87f3ae
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewProjectInfo.java
@@ -0,0 +1,83 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.ui.newproject;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Represents information required to create a new JET2 Project
+ *
+ */
+public class NewProjectInfo {
+
+ private String projectName;
+ private Map otherInfo = null;
+ private static final String NL = System.getProperty("line.separator"); //$NON-NLS-1$
+ private static final String INDENT = " "; //$NON-NLS-1$
+
+ public NewProjectInfo() {
+ // nothing to do
+ }
+ /**
+ * Return the currently set project Name.
+ * @return the projectName or <code>null</code>
+ */
+ public final String getProjectName() {
+ return projectName;
+ }
+
+ /**
+ * Set the projectName.
+ * @param projectName the projectName to set
+ */
+ public final void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public String toXmlString() {
+ if(projectName == null) {
+ throw new IllegalStateException("projectName not set"); //$NON-NLS-1$
+ }
+ StringBuffer xml = new StringBuffer();
+ xml.append("<newProjectModel>").append(NL); //$NON-NLS-1$
+ xml.append(INDENT).append("<project name=\"" + projectName + "\"/>").append(NL); //$NON-NLS-1$ //$NON-NLS-2$
+ if(otherInfo != null) {
+ for (Iterator i = otherInfo.values().iterator(); i.hasNext();) {
+ String otherElement = (String) i.next();
+ xml.append(INDENT).append(otherElement).append(NL);
+ }
+ }
+ xml.append("</newProjectModel>").append(NL); //$NON-NLS-1$
+ return xml.toString();
+ }
+
+
+ public void setOtherInfo(String key, String xmlContent) {
+ if(otherInfo == null) {
+ otherInfo = new LinkedHashMap();
+ }
+ if(xmlContent != null) {
+ otherInfo.put(key, xmlContent);
+ } else {
+ otherInfo.remove(key);
+ }
+
+ }
+}
diff --git a/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewProjectWizard.java b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewProjectWizard.java
new file mode 100644
index 0000000..2d764e8
--- /dev/null
+++ b/plugins/org.eclipse.jet.ui/src/org/eclipse/jet/ui/newproject/NewProjectWizard.java
@@ -0,0 +1,102 @@
+/**
+ * <copyright>
+ *
+ * Copyright (c) 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM - Initial API and implementation
+ *
+ * </copyright>
+ *
+ * $Id$
+ */
+
+package org.eclipse.jet.ui.newproject;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jet.JET2Platform;
+import org.eclipse.jet.internal.InternalJET2Platform;
+import org.eclipse.jet.internal.ui.l10n.Messages;
+import org.eclipse.jet.ui.Activator;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+
+/**
+ * Implement New Project Wizard for JET2 transforms.
+ *
+ */
+public class NewProjectWizard extends Wizard implements INewWizard {
+
+ private static final String NEW_PROJECT_WIZARD_TX_ID = "org.eclipse.jet.transforms.newproject"; //$NON-NLS-1$
+ private WizardNewProjectCreationPage projectPage;
+
+ protected final NewProjectInfo newProjectInfo = new NewProjectInfo();
+
+ /**
+ *
+ */
+ public NewProjectWizard() {
+ super();
+ setWindowTitle(Messages.NewProjectWizard_WindowTitle);
+ setDefaultPageImageDescriptor(Activator.getImageDescriptor("/icons/JET2ProjectWizardBanner.gif")); //$NON-NLS-1$
+ setNeedsProgressMonitor(true);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ public boolean performFinish() {
+ try {
+ getContainer().run(false, false, new IRunnableWithProgress() {
+
+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
+ IStatus result = JET2Platform.execute(NEW_PROJECT_WIZARD_TX_ID, getBuildModel(), "xml", monitor); //$NON-NLS-1$
+ if(!result.isOK()) {
+ InternalJET2Platform.log(result);
+ new ErrorDialog(getShell(), NewProjectWizard.this.getWindowTitle(),
+ Messages.NewProjectWizard_ErrorInJETTransform,
+ result, IStatus.ERROR | IStatus.WARNING).open();
+ }
+ }});
+ } catch (InvocationTargetException e) {
+ InternalJET2Platform.logError(Messages.NewProjectWizard_ErrorCreatingProject, e);
+ } catch (InterruptedException e) {
+ // cancelled, nothing to do
+ }
+ return true;
+ }
+
+ protected final String getBuildModel() {
+ newProjectInfo.setProjectName(projectPage.getProjectName());
+ return newProjectInfo.toXmlString();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ // nothing to do here
+ }
+
+ public void addPages() {
+ super.addPages();
+
+ projectPage = new WizardNewProjectCreationPage(Messages.NewProjectWizard_MainPageTabText);
+ projectPage.setTitle(Messages.NewProjectWizard_MainPageTitle);
+ projectPage.setDescription(Messages.NewProjectWizard_MainPageDescription);
+ addPage(projectPage);
+
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/.classpath b/tests/org.eclipse.jet.tests/.classpath
new file mode 100644
index 0000000..751c8f2
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/org.eclipse.jet.tests/.cvsignore b/tests/org.eclipse.jet.tests/.cvsignore
new file mode 100644
index 0000000..ba077a4
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/.cvsignore
@@ -0,0 +1 @@
+bin
diff --git a/tests/org.eclipse.jet.tests/.project b/tests/org.eclipse.jet.tests/.project
new file mode 100644
index 0000000..b145280
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.jet.tests</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/org.eclipse.jet.tests/.settings/org.eclipse.core.resources.prefs b/tests/org.eclipse.jet.tests/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..68bb836
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,6 @@
+#Thu Jan 12 10:55:42 EST 2006
+eclipse.preferences.version=1
+encoding//data/alljet2.jet=UTF-8
+encoding//data/alljet2.jet.expected=UTF-8
+encoding//data/beans.xsd=UTF8
+encoding//data/dm-example.xsd=UTF8
diff --git a/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.core.prefs b/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..f32ef68
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,49 @@
+#Thu Feb 02 16:59:31 EST 2006
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
diff --git a/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e00ca65
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JET JUnit Test Plug-in
+Bundle-SymbolicName: org.eclipse.jet.tests;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.jet,
+ org.junit,
+ org.eclipse.emf.codegen,
+ org.eclipse.core.runtime,
+ org.eclipse.emf.ecore,
+ org.eclipse.emf.ecore.xmi,
+ org.eclipse.xsd
diff --git a/tests/org.eclipse.jet.tests/about.html b/tests/org.eclipse.jet.tests/about.html
new file mode 100644
index 0000000..1c0db85
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/about.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>February 22, 2006</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content.</p>
+
+</body>
+</html>
+
diff --git a/tests/org.eclipse.jet.tests/build.properties b/tests/org.eclipse.jet.tests/build.properties
new file mode 100644
index 0000000..e448631
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/build.properties
@@ -0,0 +1,8 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ data/,\
+ plugin.xml,\
+ about.html
+src.includes = about.html
diff --git a/tests/org.eclipse.jet.tests/data/DOMInspector.xml b/tests/org.eclipse.jet.tests/data/DOMInspector.xml
new file mode 100644
index 0000000..9095579
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/DOMInspector.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<root rootAttr="test">
+ <!-- a comment within root -->
+ <a name="foo">
+ <b>Some foo text.</b>
+ </a>
+ <a name="bar">
+ <b>Some bar text.</b>
+ </a>
+</root>
diff --git a/tests/org.eclipse.jet.tests/data/alljet2.jet b/tests/org.eclipse.jet.tests/data/alljet2.jet
new file mode 100644
index 0000000..241c44d
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/alljet2.jet
@@ -0,0 +1,34 @@
+<%@jet class="Foo" package="org.eclipse.emf.examples"%>
+Some top level text.
+<%= "An expression" %>
+<%!
+int foo() {
+ return 3;
+}
+%>
+<%
+if(foo() > 0) {
+ foo();
+}
+%>
+<%-- a comment --%>
+<test:container one="test one" two='test two'>
+ <test:empty/>
+ <test:container>
+ some text <nontest:text attributes="foo"/>
+ </test:container>
+</test:container>
+<%-- tags containing Java --%>
+<test:container>
+ <%= foo(); %>
+ <% if(foo() > 0) { %>
+ some text
+ <% } %>
+</test:container>
+<%-- Java container tags --%>
+<% if(foo() > 0) { %>
+ some text
+ <test:empty/>
+ <test:container>
+ </test:container>
+<% } %>
diff --git a/tests/org.eclipse.jet.tests/data/alljet2.jet.expected b/tests/org.eclipse.jet.tests/data/alljet2.jet.expected
new file mode 100644
index 0000000..c86b856
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/alljet2.jet.expected
@@ -0,0 +1,93 @@
+<directive name="jet" start="(0,0)" stop="(0,55)">
+ <attribute name="class">Foo</attribute>
+ <attribute name="package">org.eclipse.emf.examples</attribute>
+</directive>
+<data>
+Some top level text.
+</data>
+<expression start="(2,3)" stop="(2,20)"> "An expression" </expression>
+<data>
+</data>
+<declaration start="(3,3)" stop="(7,0)">
+int foo() {
+ return 3;
+}
+</declaration>
+<data>
+</data>
+<scriptlet start="(8,2)" stop="(12,0)">
+if(foo() > 0) {
+ foo();
+}
+</scriptlet>
+<data>
+</data>
+<comment start="(13,4)" stop="(13,15)"> a comment </comment>
+<data>
+</data>
+<tag name="test:container" start="(14,0)" stop="(14,46)">
+ <attribute name="one">test one</attribute>
+ <attribute name="two">test two</attribute>
+ <content>
+ <data>
+ </data>
+ <tag name="test:empty" start="(15,4)" stop="(15,17)">
+ </tag>
+ <data>
+ </data>
+ <tag name="test:container" start="(16,4)" stop="(16,20)">
+ <content>
+ <data>
+ some text <nontest:text attributes="foo"/>
+ </data>
+ </content>
+ </tag>
+ <data>
+</data>
+ </content>
+</tag>
+<data>
+</data>
+<comment start="(20,4)" stop="(20,26)"> tags containing Java </comment>
+<data>
+</data>
+<tag name="test:container" start="(21,0)" stop="(21,16)">
+ <content>
+ <data>
+ </data>
+ <expression start="(22,7)" stop="(22,15)"> foo(); </expression>
+ <data>
+ </data>
+ <scriptlet start="(23,6)" stop="(23,23)"> if(foo() > 0) { </scriptlet>
+ <data>
+ some text
+ </data>
+ <scriptlet start="(25,6)" stop="(25,9)"> } </scriptlet>
+ <data>
+</data>
+ </content>
+</tag>
+<data>
+</data>
+<comment start="(27,4)" stop="(27,25)"> Java container tags </comment>
+<data>
+</data>
+<scriptlet start="(28,2)" stop="(28,19)"> if(foo() > 0) { </scriptlet>
+<data>
+ some text
+ </data>
+<tag name="test:empty" start="(30,8)" stop="(30,21)">
+</tag>
+<data>
+ </data>
+<tag name="test:container" start="(31,8)" stop="(31,24)">
+ <content>
+ <data>
+ </data>
+ </content>
+</tag>
+<data>
+</data>
+<scriptlet start="(33,2)" stop="(33,5)"> } </scriptlet>
+<data>
+</data>
diff --git a/tests/org.eclipse.jet.tests/data/bean.model.sample.xml b/tests/org.eclipse.jet.tests/data/bean.model.sample.xml
new file mode 100644
index 0000000..c2367f2
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/bean.model.sample.xml
@@ -0,0 +1,22 @@
+<root>
+ <project name="test.beans">
+ <beanmodel name="Library" basePackage="base.pkg">
+ <bean name="Author" project="foo">
+ <attribute name="name" type="String" kind="FIELD"/>
+ <attribute name="books" type="Book" kind="LIST"/>
+ </bean>
+ <bean name="Book">
+ <attribute name="title" type="String" kind="FIELD">The book title</attribute>
+ <attribute name="pages" type="int" kind="FIELD"/>
+ <attribute name="authors" type="Book" kind="LIST"/>
+ </bean>
+ <bean name="Library">
+ <attribute name="name" type="String" kind="FIELD"/>
+ <attribute name="yearFounded" type="int" kind="FIELD"/>
+ <attribute name="authors" type="Author" kind="LIST"/>
+ <attribute name="books" type="Book" kind="LIST"/>
+ <attribute name="openSince" type="int" kind="DERIVED"/>
+ </bean>
+ </beanmodel>
+ </project>
+</root> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/beans.xsd b/tests/org.eclipse.jet.tests/data/beans.xsd
new file mode 100644
index 0000000..8635462
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/beans.xsd
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsd:schema xmlns="http://www.example.org/beans" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" targetNamespace="http://www.example.org/beans">
+ <xsd:complexType name="root">
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" name="project" type="project"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="project">
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" name="beanModel" type="beanModel"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="beanModel">
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" name="bean" type="bean"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="basePackage" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="bean">
+ <xsd:sequence>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" name="attribute" type="attribute"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="attribute">
+ <xsd:sequence>
+ <xsd:element maxOccurs="1" minOccurs="0" name="doc" type="xsd:string"/>
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ <xsd:attribute name="type" type="xsd:string"/>
+ <xsd:attribute name="kind" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:element name="root" type="root"/>
+
+</xsd:schema>
diff --git a/tests/org.eclipse.jet.tests/data/dm-example.xml b/tests/org.eclipse.jet.tests/data/dm-example.xml
new file mode 100644
index 0000000..f03f715
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/dm-example.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<?xml-stylesheet type="text/xsl" href="dm-example.xsl"?>
+<catalog xmlns="http://www.example.com/catalog"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.example.com/catalog
+ dm-example.xsd"
+ xml:lang="en"
+ version="0.1">
+
+<!-- This example is for data model illustration only.
+ It does not demonstrate good schema design. -->
+
+<tshirt code="T1534017" label=" Staind : Been Awhile "
+ xlink:href="http://example.com/0,,1655091,00.html"
+ sizes="M L XL">
+ <title> Staind: Been Awhile Tee Black (1-sided) </title>
+ <description>
+ <html:p>
+ Lyrics from the hit song 'It's Been Awhile'
+ are shown in white, beneath the large
+ 'Flock &amp; Weld' Staind logo.
+ </html:p>
+ </description>
+ <price> 25.00 </price>
+</tshirt>
+
+<album code="A1481344" label=" Staind : Its Been A While "
+ formats="CD">
+ <title> It's Been A While </title>
+ <description xsi:nil="true" />
+ <price currency="USD"> 10.99 </price>
+ <artist> Staind </artist>
+</album>
+
+</catalog> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/dm-example.xsd b/tests/org.eclipse.jet.tests/data/dm-example.xsd
new file mode 100644
index 0000000..0231cf3
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/dm-example.xsd
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:cat="http://www.example.com/catalog" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.example.com/catalog">
+
+<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
+
+<xs:import namespace="http://www.w3.org/1999/xlink" schemaLocation="http://www.cs.rpi.edu/~puninj/XGMML/xlinks-2001.xsd"/>
+
+<xs:element name="catalog">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element maxOccurs="unbounded" ref="cat:_item"/>
+ </xs:sequence>
+ <xs:attribute fixed="0.1" name="version" type="xs:string" use="required"/>
+ <xs:attribute ref="xml:base"/>
+ <xs:attribute ref="xml:lang"/>
+ </xs:complexType>
+</xs:element>
+
+<xs:element abstract="true" name="_item" type="cat:itemType"/>
+
+<xs:complexType name="itemType">
+ <xs:sequence>
+ <xs:element name="title" type="xs:token"/>
+ <xs:element name="description" nillable="true" type="cat:description"/>
+ <xs:element maxOccurs="unbounded" name="price" type="cat:price"/>
+ </xs:sequence>
+ <xs:attribute name="label" type="xs:token"/>
+ <xs:attribute name="code" type="xs:ID" use="required"/>
+ <xs:attributeGroup ref="xlink:simpleLink"/>
+</xs:complexType>
+
+<xs:element name="tshirt" substitutionGroup="cat:_item" type="cat:tshirtType"/>
+
+<xs:complexType name="tshirtType">
+ <xs:complexContent>
+ <xs:extension base="cat:itemType">
+ <xs:attribute name="sizes" type="cat:clothesSizes" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+</xs:complexType>
+
+<xs:simpleType name="clothesSizes">
+ <xs:union memberTypes="cat:sizeList">
+ <xs:simpleType>
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="oneSize"/>
+ </xs:restriction>
+ </xs:simpleType>
+ </xs:union>
+</xs:simpleType>
+
+<xs:simpleType name="sizeList">
+ <xs:restriction>
+ <xs:simpleType>
+ <xs:list itemType="cat:clothesSize"/>
+ </xs:simpleType>
+ <xs:minLength value="1"/>
+ </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="clothesSize">
+ <xs:union memberTypes="cat:numberedSize cat:categorySize"/>
+</xs:simpleType>
+
+<xs:simpleType name="numberedSize">
+ <xs:restriction base="xs:integer">
+ <xs:enumeration value="4"/>
+ <xs:enumeration value="6"/>
+ <xs:enumeration value="8"/>
+ <xs:enumeration value="10"/>
+ <xs:enumeration value="12"/>
+ <xs:enumeration value="14"/>
+ <xs:enumeration value="16"/>
+ <xs:enumeration value="18"/>
+ <xs:enumeration value="20"/>
+ <xs:enumeration value="22"/>
+ </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="categorySize">
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="XS"/>
+ <xs:enumeration value="S"/>
+ <xs:enumeration value="M"/>
+ <xs:enumeration value="L"/>
+ <xs:enumeration value="XL"/>
+ <xs:enumeration value="XXL"/>
+ </xs:restriction>
+</xs:simpleType>
+
+<xs:element name="album" substitutionGroup="cat:_item" type="cat:albumType"/>
+
+<xs:complexType name="albumType">
+ <xs:complexContent>
+ <xs:extension base="cat:itemType">
+ <xs:sequence>
+ <xs:element name="artist" type="xs:string"/>
+ </xs:sequence>
+ <xs:attribute name="formats" type="cat:formatsType" use="required"/>
+ </xs:extension>
+ </xs:complexContent>
+</xs:complexType>
+
+<xs:simpleType name="formatsType">
+ <xs:list itemType="cat:formatType"/>
+</xs:simpleType>
+
+<xs:simpleType name="formatType">
+ <xs:restriction base="xs:token">
+ <xs:enumeration value="CD"/>
+ <xs:enumeration value="MiniDisc"/>
+ <xs:enumeration value="tape"/>
+ <xs:enumeration value="vinyl"/>
+ </xs:restriction>
+</xs:simpleType>
+
+<xs:complexType mixed="true" name="description">
+ <xs:sequence>
+ <xs:any maxOccurs="unbounded" minOccurs="0" namespace="http://www.w3.org/1999/xhtml" processContents="lax"/>
+ </xs:sequence>
+ <xs:attribute ref="xml:lang"/>
+</xs:complexType>
+
+<xs:complexType name="price">
+ <xs:simpleContent>
+ <xs:extension base="cat:monetaryAmount">
+ <xs:attribute default="USD" name="currency" type="cat:currencyType"/>
+ </xs:extension>
+ </xs:simpleContent>
+</xs:complexType>
+
+<xs:simpleType name="currencyType">
+ <xs:restriction base="xs:token">
+ <xs:pattern value="[A-Z]{3}"/>
+ </xs:restriction>
+</xs:simpleType>
+
+<xs:simpleType name="monetaryAmount">
+ <xs:restriction base="xs:decimal">
+ <xs:fractionDigits value="3"/>
+ <xs:pattern value="\d+\.(\d{2})?"/>
+ </xs:restriction>
+</xs:simpleType>
+
+</xs:schema>
diff --git a/tests/org.eclipse.jet.tests/data/jetast.ecore b/tests/org.eclipse.jet.tests/data/jetast.ecore
new file mode 100644
index 0000000..7003325
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/jetast.ecore
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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="jetast"
+ nsURI="http:///org/eclipse/emf/jet2/compile/jetast.ecore" nsPrefix="org.eclipse.emf.jet2.compile.jetast">
+ <eClassifiers xsi:type="ecore:EClass" name="JET2AST"/>
+ <eClassifiers xsi:type="ecore:EClass" name="JET2ASTElement" abstract="true">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="line" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="start" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="end" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="ast" eType="#//JET2AST"
+ containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="parent" eType="#//JET2ASTElement"
+ containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Comment" eSuperTypes="#//JET2ASTElement">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="commentStart" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="commentEnd" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="comment" eType="#//JavaCharArray"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="JavaElement" abstract="true" eSuperTypes="#//JET2ASTElement">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="javaStart" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="javaEnd" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="javaContent" eType="#//JavaCharArray"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="JET2Declaration" eSuperTypes="#//JavaElement"/>
+ <eClassifiers xsi:type="ecore:EClass" name="JET2Expression" eSuperTypes="#//JavaElement"/>
+ <eClassifiers xsi:type="ecore:EClass" name="JET2Scriptlet" eSuperTypes="#//JavaElement"/>
+ <eClassifiers xsi:type="ecore:EClass" name="JET2CompilationUnit" eSuperTypes="#//JET2ASTElement">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="fileName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="javaOutputPackage" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="javaOutputClass" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="errors" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
+ changeable="false" derived="true"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="warnings" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EBoolean"
+ changeable="false" derived="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="problems" upperBound="-1"
+ eType="#//Problem" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="bodyElements" upperBound="-1"
+ eType="#//JET2ASTElement" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Problem">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="originatingFileName" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="lineNumber" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="start" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="end" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="message" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="msgArgs" eType="#//ObjectArray"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="severity" eType="#//Severity"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="#//ProblemId"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EEnum" name="Severity">
+ <eLiterals name="ERROR"/>
+ <eLiterals name="WARNING" value="1"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EEnum" name="ProblemId">
+ <eLiterals name="MissingXmlStartTag"/>
+ <eLiterals name="MissingXmlEndTag" value="1"/>
+ <eLiterals name="MissingRequiredAttribute" value="2"/>
+ <eLiterals name="DuplicateXMLNamespacePrefix" value="3"/>
+ <eLiterals name="UnknownTagLibrary" value="4"/>
+ <eLiterals name="UnknownAttributeInTag" value="5"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="JET2Directive" eSuperTypes="#//JET2ASTElement">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="attributes" upperBound="-1"
+ eType="#//Attribute" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="TextElement" eSuperTypes="#//JET2ASTElement">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="text" eType="#//JavaCharArray"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="XMLElement" abstract="true" eSuperTypes="#//JET2ASTElement">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="tagDefinition" eType="#//TagDefinition"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="XMLEmptyElement" eSuperTypes="#//XMLElement"/>
+ <eClassifiers xsi:type="ecore:EClass" name="XMLBodyElement" eSuperTypes="#//XMLElement">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="endTagStart" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="endTagEnd" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="attributes" upperBound="-1"
+ eType="#//Attribute" containment="true"/>
+ <eStructuralFeatures xsi:type="ecore:EReference" name="bodyElements" upperBound="-1"
+ eType="#//JET2ASTElement" containment="true"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Attribute" eSuperTypes="#//JET2ASTElement">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="nameStart" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="nameEnd" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="valueStart" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="valueEnd" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="equalsOffset" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EDataType" name="JavaCharArray" instanceClassName="char[]"/>
+ <eClassifiers xsi:type="ecore:EDataType" name="ObjectArray" instanceClassName="Object[]"/>
+ <eClassifiers xsi:type="ecore:EDataType" name="TagDefinition" instanceClassName="org.eclipse.emf.jet2.taglib.TagDefinition"/>
+</ecore:EPackage>
diff --git a/tests/org.eclipse.jet.tests/data/library.xml b/tests/org.eclipse.jet.tests/data/library.xml
new file mode 100644
index 0000000..51ba39c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/library.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:root xmlns:beans="http://www.example.org/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/beans beans.xsd ">
+ <project name="test.beans">
+ <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="authors" type="Author"/>
+ </bean>
+ <bean name="Author">
+ <attribute kind="FIELD" name="name" type="String">
+ <doc>doc for Author.name</doc>
+ </attribute>
+ <attribute kind="LIST" name="books" type="Book"/>
+ </bean>
+ </beanModel>
+ </project>
+</beans:root>
diff --git a/tests/org.eclipse.jet.tests/data/library.xml.indisguise b/tests/org.eclipse.jet.tests/data/library.xml.indisguise
new file mode 100644
index 0000000..bd34f57
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/library.xml.indisguise
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:root xmlns:beans="http://www.example.org/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/beans beans.xsd ">
+ <project name="test.beans">
+ <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="authors" type="Author"/>
+ </bean>
+ <bean name="Author">
+ <attribute kind="FIELD" name="name" type="String">
+ <doc>doc for Author.name</doc>
+ </attribute>
+ <attribute kind="LIST" name="books" type="Book"/>
+ </bean>
+ </beanModel>
+ </project>
+</beans:root>
diff --git a/tests/org.eclipse.jet.tests/data/sample.dataaccess b/tests/org.eclipse.jet.tests/data/sample.dataaccess
new file mode 100644
index 0000000..1a7865b
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/sample.dataaccess
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<dataAccess:Employee xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:dataAccess="http:///dataAccess.ecore" name="Bob Smith" address="123 Main St" employeeNumber="12345">
+ <customers name="Sam Brown" address="55 Bank St">
+ <orders orderNumber="101" date="2005-12-15T00:00:00.000-0500" quantity="25"/>
+ <orders orderNumber="13" date="2005-11-15T00:00:00.000-0500" quantity="55"/>
+ </customers>
+ <customers name="Tim Safari" address="18 Elephant Rd">
+ <orders orderNumber="77" date="2005-11-20T00:00:00.000-0500" quantity="3"/>
+ </customers>
+</dataAccess:Employee>
diff --git a/tests/org.eclipse.jet.tests/data/taglibs.jet b/tests/org.eclipse.jet.tests/data/taglibs.jet
new file mode 100644
index 0000000..2bc9dfc
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/taglibs.jet
@@ -0,0 +1,10 @@
+<%@taglib id="org.eclipse.jet.tests.TestLibrary" prefix="test" %>
+"isAllUpper", "nl", "other", "tokenize", "upper"
+
+<test:tokenize string="a,b,c,d,e,f,g" sep="," var="token">
+<test:other>some text</test:other>
+<test:isAllUpper var="token">
+</test:isAllUpper>
+<test:upper>foo</test:upper><test:nl/>
+<test:other/>
+</test:tokenize> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/taglibs.jet.astdump.expected b/tests/org.eclipse.jet.tests/data/taglibs.jet.astdump.expected
new file mode 100644
index 0000000..f1e0329
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/taglibs.jet.astdump.expected
@@ -0,0 +1,46 @@
+<directive name="taglib" start="0" stop="70">
+ <attribute name="prefix">test</attribute>
+ <attribute name="id">org.eclipse.jet.tests.TestLibrary</attribute>
+</directive>
+<data>
+"isAllUpper", "nl", "other", "tokenize", "upper"
+
+</data>
+<tag name="test:tokenize" start="123" stop="181">
+ <attribute name="sep">,</attribute>
+ <attribute name="var">token</attribute>
+ <attribute name="string">a,b,c,d,e,f,g</attribute>
+ <content>
+ <data>
+</data>
+ <tag name="test:other" start="183" stop="195">
+ <content>
+ <data>some text</data>
+ </content>
+ </tag>
+ <data>
+</data>
+ <tag name="test:isAllUpper" start="219" stop="248">
+ <attribute name="var">token</attribute>
+ <content>
+ <data>
+</data>
+ </content>
+ </tag>
+ <data>
+</data>
+ <tag name="test:upper" start="270" stop="282">
+ <content>
+ <data>foo</data>
+ </content>
+ </tag>
+ <tag name="test:nl" start="298" stop="308">
+ </tag>
+ <data>
+</data>
+ <tag name="test:other" start="310" stop="323">
+ </tag>
+ <data>
+</data>
+ </content>
+</tag>
diff --git a/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java b/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
new file mode 100644
index 0000000..2cfe073
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/taglibs.jet.expected.java
@@ -0,0 +1,94 @@
+package org.eclipse.jet.compiled;
+
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.taglib.RuntimeTagElement;
+import org.eclipse.jet.taglib.TagInfo;
+
+public class X implements JET2Template {
+
+ public static final String _jetns_test = "org.eclipse.jet.tests.TestLibrary";//$NON-NLS-1$
+
+
+
+
+ public X() {
+ super();
+ }
+
+ public void generate(JET2Context context, JET2Writer out) {
+
+ final TagInfo _jettd_test_tokenize_4_123_181 = new TagInfo( "test:tokenize", 4, 123, 181, new String[] {"sep", "var", "string", }, new String[] {",", "token", "a,b,c,d,e,f,g", });
+final TagInfo _jettd_test_other_5_183_195 = new TagInfo( "test:other", 5, 183, 195, new String[] {}, new String[] {});
+final TagInfo _jettd_test_isAllUpper_6_219_248 = new TagInfo( "test:isAllUpper", 6, 219, 248, new String[] {"var", }, new String[] {"token", });
+final TagInfo _jettd_test_upper_8_270_282 = new TagInfo( "test:upper", 8, 270, 282, new String[] {}, new String[] {});
+final TagInfo _jettd_test_nl_8_298_308 = new TagInfo( "test:nl", 8, 298, 308, new String[] {}, new String[] {});
+final TagInfo _jettd_test_other_9_310_323 = new TagInfo( "test:other", 9, 310, 323, new String[] {}, new String[] {});
+
+
+ out.write("\r\n\"isAllUpper\", \"nl\", \"other\", \"tokenize\", \"upper\"\r\n\r\n");
+ RuntimeTagElement _jettag_test_tokenize_4_123_181 = context.getTagFactory().createRuntimeTag(_jetns_test, "tokenize", "test:tokenize", _jettd_test_tokenize_4_123_181);
+ _jettag_test_tokenize_4_123_181.setRuntimeParent(null);
+ _jettag_test_tokenize_4_123_181.setTagInfo(_jettd_test_tokenize_4_123_181);
+ _jettag_test_tokenize_4_123_181.doStart(context, out);
+ while (_jettag_test_tokenize_4_123_181.okToProcessBody()) {
+
+out.write("\r\n");
+ RuntimeTagElement _jettag_test_other_5_183_195 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_5_183_195);
+ _jettag_test_other_5_183_195.setRuntimeParent(_jettag_test_tokenize_4_123_181);
+ _jettag_test_other_5_183_195.setTagInfo(_jettd_test_other_5_183_195);
+ _jettag_test_other_5_183_195.doStart(context, out);
+ while (_jettag_test_other_5_183_195.okToProcessBody()) {
+
+out.write("some text");
+ _jettag_test_other_5_183_195.handleBodyContent(out);
+ }
+ _jettag_test_other_5_183_195.doEnd();
+out.write("\r\n");
+ RuntimeTagElement _jettag_test_isAllUpper_6_219_248 = context.getTagFactory().createRuntimeTag(_jetns_test, "isAllUpper", "test:isAllUpper", _jettd_test_isAllUpper_6_219_248);
+ _jettag_test_isAllUpper_6_219_248.setRuntimeParent(_jettag_test_tokenize_4_123_181);
+ _jettag_test_isAllUpper_6_219_248.setTagInfo(_jettd_test_isAllUpper_6_219_248);
+ _jettag_test_isAllUpper_6_219_248.doStart(context, out);
+ while (_jettag_test_isAllUpper_6_219_248.okToProcessBody()) {
+
+out.write("\r\n");
+ _jettag_test_isAllUpper_6_219_248.handleBodyContent(out);
+ }
+ _jettag_test_isAllUpper_6_219_248.doEnd();
+out.write("\r\n");
+ RuntimeTagElement _jettag_test_upper_8_270_282 = context.getTagFactory().createRuntimeTag(_jetns_test, "upper", "test:upper", _jettd_test_upper_8_270_282);
+ _jettag_test_upper_8_270_282.setRuntimeParent(_jettag_test_tokenize_4_123_181);
+ _jettag_test_upper_8_270_282.setTagInfo(_jettd_test_upper_8_270_282);
+ _jettag_test_upper_8_270_282.doStart(context, out);
+ JET2Writer _jettag_test_upper_8_270_282_saved_out = out;
+ while (_jettag_test_upper_8_270_282.okToProcessBody()) {
+ out = out.newNestedContentWriter();
+
+out.write("foo");
+ _jettag_test_upper_8_270_282.handleBodyContent(out);
+ }
+ out = _jettag_test_upper_8_270_282_saved_out;
+ _jettag_test_upper_8_270_282.doEnd();
+ RuntimeTagElement _jettag_test_nl_8_298_308 = context.getTagFactory().createRuntimeTag(_jetns_test, "nl", "test:nl", _jettd_test_nl_8_298_308);
+ _jettag_test_nl_8_298_308.setRuntimeParent(_jettag_test_tokenize_4_123_181);
+ _jettag_test_nl_8_298_308.setTagInfo(_jettd_test_nl_8_298_308);
+ _jettag_test_nl_8_298_308.doStart(context, out);
+
+ _jettag_test_nl_8_298_308.doEnd();
+out.write("\r\n");
+ RuntimeTagElement _jettag_test_other_9_310_323 = context.getTagFactory().createRuntimeTag(_jetns_test, "other", "test:other", _jettd_test_other_9_310_323);
+ _jettag_test_other_9_310_323.setRuntimeParent(_jettag_test_tokenize_4_123_181);
+ _jettag_test_other_9_310_323.setTagInfo(_jettd_test_other_9_310_323);
+ _jettag_test_other_9_310_323.doStart(context, out);
+
+ _jettag_test_other_9_310_323.doEnd();
+out.write("\r\n");
+ _jettag_test_tokenize_4_123_181.handleBodyContent(out);
+ }
+ _jettag_test_tokenize_4_123_181.doEnd();
+
+ }
+
+}
+ \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/unclosedComment.jet b/tests/org.eclipse.jet.tests/data/unclosedComment.jet
new file mode 100644
index 0000000..ba01d6f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/unclosedComment.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<%-- String x = "Hello World!"; -%>
diff --git a/tests/org.eclipse.jet.tests/data/unclosedDeclaration.jet b/tests/org.eclipse.jet.tests/data/unclosedDeclaration.jet
new file mode 100644
index 0000000..a12518f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/unclosedDeclaration.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<%! public void foo() {} >
diff --git a/tests/org.eclipse.jet.tests/data/unclosedDirective.jet b/tests/org.eclipse.jet.tests/data/unclosedDirective.jet
new file mode 100644
index 0000000..c822dec
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/unclosedDirective.jet
@@ -0,0 +1 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/data/unclosedExpression.jet b/tests/org.eclipse.jet.tests/data/unclosedExpression.jet
new file mode 100644
index 0000000..b67abe9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/unclosedExpression.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<%= "Hello World!" >
diff --git a/tests/org.eclipse.jet.tests/data/unclosedScriplet.jet b/tests/org.eclipse.jet.tests/data/unclosedScriplet.jet
new file mode 100644
index 0000000..dd654a9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/unclosedScriplet.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<% String x = "Hello World!"; >
diff --git a/tests/org.eclipse.jet.tests/data/unclosedXMLEnd.jet b/tests/org.eclipse.jet.tests/data/unclosedXMLEnd.jet
new file mode 100644
index 0000000..188636c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/unclosedXMLEnd.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+</test:start
diff --git a/tests/org.eclipse.jet.tests/data/unclosedXMLStart.jet b/tests/org.eclipse.jet.tests/data/unclosedXMLStart.jet
new file mode 100644
index 0000000..d3e55e0
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/unclosedXMLStart.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<test:start attr="foo"
diff --git a/tests/org.eclipse.jet.tests/data/xmlEndWithAttributes.jet b/tests/org.eclipse.jet.tests/data/xmlEndWithAttributes.jet
new file mode 100644
index 0000000..a614208
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/xmlEndWithAttributes.jet
@@ -0,0 +1,3 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+</test:start attr="value">
diff --git a/tests/org.eclipse.jet.tests/data/xmlStartWithoutEnd.jet b/tests/org.eclipse.jet.tests/data/xmlStartWithoutEnd.jet
new file mode 100644
index 0000000..54760f5
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/data/xmlStartWithoutEnd.jet
@@ -0,0 +1,8 @@
+<%@jet package="org.eclipse.emf.examples.test" class="Foo" %>
+
+<test:start attr="value">
+
+<test:start2 attr="two">
+
+</test:start>
+</test:start2> \ No newline at end of file
diff --git a/tests/org.eclipse.jet.tests/model/dataAccess.ecore b/tests/org.eclipse.jet.tests/model/dataAccess.ecore
new file mode 100644
index 0000000..70725f8
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/model/dataAccess.ecore
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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="dataAccess"
+ nsURI="http:///dataAccess.ecore" nsPrefix="dataAccess">
+ <eClassifiers xsi:type="ecore:EClass" name="Customer" eSuperTypes="#//Person">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="orders" upperBound="-1"
+ eType="#//Order" containment="true" resolveProxies="false"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Employee" eSuperTypes="#//Person">
+ <eStructuralFeatures xsi:type="ecore:EReference" name="customers" upperBound="-1"
+ eType="#//Customer" containment="true" resolveProxies="false"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="employeeNumber" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Order">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="orderNumber" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="date" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EDate"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="quantity" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
+ </eClassifiers>
+ <eClassifiers xsi:type="ecore:EClass" name="Person">
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="name" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ <eStructuralFeatures xsi:type="ecore:EAttribute" name="address" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
+ </eClassifiers>
+</ecore:EPackage>
diff --git a/tests/org.eclipse.jet.tests/model/dataAccess.genmodel b/tests/org.eclipse.jet.tests/model/dataAccess.genmodel
new file mode 100644
index 0000000..583bb81
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/model/dataAccess.genmodel
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<genmodel:GenModel xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
+ xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel" modelDirectory="/org.eclipse.emf.test.jet2/src"
+ modelPluginID="zzz.dataAccess" modelName="DataAccess" importerID="org.eclipse.emf.importer.ecore">
+ <foreignModel>../../analysis/dataAccess.ecore</foreignModel>
+ <genPackages prefix="DataAccess" disposableProviderFactory="true" ecorePackage="dataAccess.ecore#/">
+ <genClasses ecoreClass="dataAccess.ecore#//Customer">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference dataAccess.ecore#//Customer/orders"/>
+ </genClasses>
+ <genClasses ecoreClass="dataAccess.ecore#//Employee">
+ <genFeatures property="None" children="true" createChild="true" ecoreFeature="ecore:EReference dataAccess.ecore#//Employee/customers"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute dataAccess.ecore#//Employee/employeeNumber"/>
+ </genClasses>
+ <genClasses ecoreClass="dataAccess.ecore#//Order">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute dataAccess.ecore#//Order/orderNumber"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute dataAccess.ecore#//Order/date"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute dataAccess.ecore#//Order/quantity"/>
+ </genClasses>
+ <genClasses ecoreClass="dataAccess.ecore#//Person">
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute dataAccess.ecore#//Person/name"/>
+ <genFeatures createChild="false" ecoreFeature="ecore:EAttribute dataAccess.ecore#//Person/address"/>
+ </genClasses>
+ </genPackages>
+</genmodel:GenModel>
diff --git a/tests/org.eclipse.jet.tests/plugin.properties b/tests/org.eclipse.jet.tests/plugin.properties
new file mode 100644
index 0000000..d4870c7
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/plugin.properties
@@ -0,0 +1,20 @@
+# <copyright>
+# </copyright>
+#
+# $Id$
+
+# ====================================================================
+# To code developer:
+# Do NOT change the properties between this line and the
+# "%%% END OF TRANSLATED PROPERTIES %%%" line.
+# Make a new property name, append to the end of the file and change
+# the code to use the new property.
+# ====================================================================
+
+# ====================================================================
+# %%% END OF TRANSLATED PROPERTIES %%%
+# ====================================================================
+
+pluginName = DataAccess Model
+providerName = www.example.org
+
diff --git a/tests/org.eclipse.jet.tests/plugin.xml b/tests/org.eclipse.jet.tests/plugin.xml
new file mode 100644
index 0000000..7a12008
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/plugin.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+ <extension
+ point="org.eclipse.jet.tagLibraries">
+ <tagLibrary
+ id="TestLibrary"
+ name="Test Library">
+ <functionTag
+ class="org.eclipse.emf.test.jet2.testTags.UpperTagElement"
+ name="upper"/>
+ <iteratingTag
+ class="org.eclipse.emf.test.jet2.testTags.TokenizeTagElement"
+ name="tokenize">
+ <attribute
+ name="string"
+ use="required"/>
+ <attribute
+ name="sep"
+ use="required"/>
+ <attribute
+ name="var"
+ use="required"/>
+ </iteratingTag>
+ <conditionalTag
+ class="org.eclipse.emf.test.jet2.testTags.IsAllUpperTagElement"
+ name="isAllUpper">
+ <attribute
+ name="var"
+ use="required"/>
+ </conditionalTag>
+ <emptyTag
+ class="org.eclipse.emf.test.jet2.testTags.NLTagElement"
+ name="nl"/>
+ <otherTag
+ class="org.eclipse.emf.test.jet2.testTags.OtherTagElement"
+ name="other"/>
+ </tagLibrary>
+ </extension>
+ <extension
+ point="org.eclipse.emf.ecore.generated_package">
+ <package
+ uri = "http:///dataAccess.ecore"
+ class = "dataAccess.DataAccessPackage"
+ genModel = "model/dataAccess.genmodel" />
+ </extension>
+
+</plugin>
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/Customer.java b/tests/org.eclipse.jet.tests/src/dataAccess/Customer.java
new file mode 100644
index 0000000..fe93ddf
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/Customer.java
@@ -0,0 +1,44 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess;
+
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Customer</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link dataAccess.Customer#getOrders <em>Orders</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see dataAccess.DataAccessPackage#getCustomer()
+ * @model
+ * @generated
+ */
+public interface Customer extends Person {
+ /**
+ * Returns the value of the '<em><b>Orders</b></em>' containment reference list.
+ * The list contents are of type {@link dataAccess.Order}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Orders</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Orders</em>' containment reference list.
+ * @see dataAccess.DataAccessPackage#getCustomer_Orders()
+ * @model type="dataAccess.Order" containment="true" resolveProxies="false"
+ * @generated
+ */
+ EList getOrders();
+
+} // Customer
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/DataAccessFactory.java b/tests/org.eclipse.jet.tests/src/dataAccess/DataAccessFactory.java
new file mode 100644
index 0000000..8a8059e
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/DataAccessFactory.java
@@ -0,0 +1,73 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess;
+
+import org.eclipse.emf.ecore.EFactory;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @see dataAccess.DataAccessPackage
+ * @generated
+ */
+public interface DataAccessFactory extends EFactory {
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ DataAccessFactory eINSTANCE = dataAccess.impl.DataAccessFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Customer</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Customer</em>'.
+ * @generated
+ */
+ Customer createCustomer();
+
+ /**
+ * Returns a new object of class '<em>Employee</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Employee</em>'.
+ * @generated
+ */
+ Employee createEmployee();
+
+ /**
+ * Returns a new object of class '<em>Order</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Order</em>'.
+ * @generated
+ */
+ Order createOrder();
+
+ /**
+ * Returns a new object of class '<em>Person</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Person</em>'.
+ * @generated
+ */
+ Person createPerson();
+
+ /**
+ * Returns the package supported by this factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the package supported by this factory.
+ * @generated
+ */
+ DataAccessPackage getDataAccessPackage();
+
+} //DataAccessFactory
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/DataAccessPackage.java b/tests/org.eclipse.jet.tests/src/dataAccess/DataAccessPackage.java
new file mode 100644
index 0000000..3fbc798
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/DataAccessPackage.java
@@ -0,0 +1,503 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Package</b> for the model.
+ * It contains accessors for the meta objects to represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @see dataAccess.DataAccessFactory
+ * @model kind="package"
+ * @generated
+ */
+public interface DataAccessPackage extends EPackage {
+ /**
+ * The package name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNAME = "dataAccess";
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_URI = "http:///dataAccess.ecore";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ String eNS_PREFIX = "dataAccess";
+
+ /**
+ * The singleton instance of the package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ DataAccessPackage eINSTANCE = dataAccess.impl.DataAccessPackageImpl.init();
+
+ /**
+ * The meta object id for the '{@link dataAccess.impl.PersonImpl <em>Person</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see dataAccess.impl.PersonImpl
+ * @see dataAccess.impl.DataAccessPackageImpl#getPerson()
+ * @generated
+ */
+ int PERSON = 3;
+
+ /**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int PERSON__NAME = 0;
+
+ /**
+ * The feature id for the '<em><b>Address</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int PERSON__ADDRESS = 1;
+
+ /**
+ * The number of structural features of the '<em>Person</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int PERSON_FEATURE_COUNT = 2;
+
+ /**
+ * The meta object id for the '{@link dataAccess.impl.CustomerImpl <em>Customer</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see dataAccess.impl.CustomerImpl
+ * @see dataAccess.impl.DataAccessPackageImpl#getCustomer()
+ * @generated
+ */
+ int CUSTOMER = 0;
+
+ /**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CUSTOMER__NAME = PERSON__NAME;
+
+ /**
+ * The feature id for the '<em><b>Address</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CUSTOMER__ADDRESS = PERSON__ADDRESS;
+
+ /**
+ * The feature id for the '<em><b>Orders</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CUSTOMER__ORDERS = PERSON_FEATURE_COUNT + 0;
+
+ /**
+ * The number of structural features of the '<em>Customer</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int CUSTOMER_FEATURE_COUNT = PERSON_FEATURE_COUNT + 1;
+
+ /**
+ * The meta object id for the '{@link dataAccess.impl.EmployeeImpl <em>Employee</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see dataAccess.impl.EmployeeImpl
+ * @see dataAccess.impl.DataAccessPackageImpl#getEmployee()
+ * @generated
+ */
+ int EMPLOYEE = 1;
+
+ /**
+ * The feature id for the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int EMPLOYEE__NAME = PERSON__NAME;
+
+ /**
+ * The feature id for the '<em><b>Address</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int EMPLOYEE__ADDRESS = PERSON__ADDRESS;
+
+ /**
+ * The feature id for the '<em><b>Customers</b></em>' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int EMPLOYEE__CUSTOMERS = PERSON_FEATURE_COUNT + 0;
+
+ /**
+ * The feature id for the '<em><b>Employee Number</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int EMPLOYEE__EMPLOYEE_NUMBER = PERSON_FEATURE_COUNT + 1;
+
+ /**
+ * The number of structural features of the '<em>Employee</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int EMPLOYEE_FEATURE_COUNT = PERSON_FEATURE_COUNT + 2;
+
+ /**
+ * The meta object id for the '{@link dataAccess.impl.OrderImpl <em>Order</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see dataAccess.impl.OrderImpl
+ * @see dataAccess.impl.DataAccessPackageImpl#getOrder()
+ * @generated
+ */
+ int ORDER = 2;
+
+ /**
+ * The feature id for the '<em><b>Order Number</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int ORDER__ORDER_NUMBER = 0;
+
+ /**
+ * The feature id for the '<em><b>Date</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int ORDER__DATE = 1;
+
+ /**
+ * The feature id for the '<em><b>Quantity</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int ORDER__QUANTITY = 2;
+
+ /**
+ * The number of structural features of the '<em>Order</em>' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ int ORDER_FEATURE_COUNT = 3;
+
+
+ /**
+ * Returns the meta object for class '{@link dataAccess.Customer <em>Customer</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Customer</em>'.
+ * @see dataAccess.Customer
+ * @generated
+ */
+ EClass getCustomer();
+
+ /**
+ * Returns the meta object for the containment reference list '{@link dataAccess.Customer#getOrders <em>Orders</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference list '<em>Orders</em>'.
+ * @see dataAccess.Customer#getOrders()
+ * @see #getCustomer()
+ * @generated
+ */
+ EReference getCustomer_Orders();
+
+ /**
+ * Returns the meta object for class '{@link dataAccess.Employee <em>Employee</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Employee</em>'.
+ * @see dataAccess.Employee
+ * @generated
+ */
+ EClass getEmployee();
+
+ /**
+ * Returns the meta object for the containment reference list '{@link dataAccess.Employee#getCustomers <em>Customers</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the containment reference list '<em>Customers</em>'.
+ * @see dataAccess.Employee#getCustomers()
+ * @see #getEmployee()
+ * @generated
+ */
+ EReference getEmployee_Customers();
+
+ /**
+ * Returns the meta object for the attribute '{@link dataAccess.Employee#getEmployeeNumber <em>Employee Number</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Employee Number</em>'.
+ * @see dataAccess.Employee#getEmployeeNumber()
+ * @see #getEmployee()
+ * @generated
+ */
+ EAttribute getEmployee_EmployeeNumber();
+
+ /**
+ * Returns the meta object for class '{@link dataAccess.Order <em>Order</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Order</em>'.
+ * @see dataAccess.Order
+ * @generated
+ */
+ EClass getOrder();
+
+ /**
+ * Returns the meta object for the attribute '{@link dataAccess.Order#getOrderNumber <em>Order Number</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Order Number</em>'.
+ * @see dataAccess.Order#getOrderNumber()
+ * @see #getOrder()
+ * @generated
+ */
+ EAttribute getOrder_OrderNumber();
+
+ /**
+ * Returns the meta object for the attribute '{@link dataAccess.Order#getDate <em>Date</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Date</em>'.
+ * @see dataAccess.Order#getDate()
+ * @see #getOrder()
+ * @generated
+ */
+ EAttribute getOrder_Date();
+
+ /**
+ * Returns the meta object for the attribute '{@link dataAccess.Order#getQuantity <em>Quantity</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Quantity</em>'.
+ * @see dataAccess.Order#getQuantity()
+ * @see #getOrder()
+ * @generated
+ */
+ EAttribute getOrder_Quantity();
+
+ /**
+ * Returns the meta object for class '{@link dataAccess.Person <em>Person</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for class '<em>Person</em>'.
+ * @see dataAccess.Person
+ * @generated
+ */
+ EClass getPerson();
+
+ /**
+ * Returns the meta object for the attribute '{@link dataAccess.Person#getName <em>Name</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Name</em>'.
+ * @see dataAccess.Person#getName()
+ * @see #getPerson()
+ * @generated
+ */
+ EAttribute getPerson_Name();
+
+ /**
+ * Returns the meta object for the attribute '{@link dataAccess.Person#getAddress <em>Address</em>}'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the meta object for the attribute '<em>Address</em>'.
+ * @see dataAccess.Person#getAddress()
+ * @see #getPerson()
+ * @generated
+ */
+ EAttribute getPerson_Address();
+
+ /**
+ * Returns the factory that creates the instances of the model.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the factory that creates the instances of the model.
+ * @generated
+ */
+ DataAccessFactory getDataAccessFactory();
+
+ /**
+ * <!-- begin-user-doc -->
+ * Defines literals for the meta objects that represent
+ * <ul>
+ * <li>each class,</li>
+ * <li>each feature of each class,</li>
+ * <li>each enum,</li>
+ * <li>and each data type</li>
+ * </ul>
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ interface Literals {
+ /**
+ * The meta object literal for the '{@link dataAccess.impl.CustomerImpl <em>Customer</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see dataAccess.impl.CustomerImpl
+ * @see dataAccess.impl.DataAccessPackageImpl#getCustomer()
+ * @generated
+ */
+ EClass CUSTOMER = eINSTANCE.getCustomer();
+
+ /**
+ * The meta object literal for the '<em><b>Orders</b></em>' containment reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference CUSTOMER__ORDERS = eINSTANCE.getCustomer_Orders();
+
+ /**
+ * The meta object literal for the '{@link dataAccess.impl.EmployeeImpl <em>Employee</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see dataAccess.impl.EmployeeImpl
+ * @see dataAccess.impl.DataAccessPackageImpl#getEmployee()
+ * @generated
+ */
+ EClass EMPLOYEE = eINSTANCE.getEmployee();
+
+ /**
+ * The meta object literal for the '<em><b>Customers</b></em>' containment reference list feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EReference EMPLOYEE__CUSTOMERS = eINSTANCE.getEmployee_Customers();
+
+ /**
+ * The meta object literal for the '<em><b>Employee Number</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute EMPLOYEE__EMPLOYEE_NUMBER = eINSTANCE.getEmployee_EmployeeNumber();
+
+ /**
+ * The meta object literal for the '{@link dataAccess.impl.OrderImpl <em>Order</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see dataAccess.impl.OrderImpl
+ * @see dataAccess.impl.DataAccessPackageImpl#getOrder()
+ * @generated
+ */
+ EClass ORDER = eINSTANCE.getOrder();
+
+ /**
+ * The meta object literal for the '<em><b>Order Number</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute ORDER__ORDER_NUMBER = eINSTANCE.getOrder_OrderNumber();
+
+ /**
+ * The meta object literal for the '<em><b>Date</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute ORDER__DATE = eINSTANCE.getOrder_Date();
+
+ /**
+ * The meta object literal for the '<em><b>Quantity</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute ORDER__QUANTITY = eINSTANCE.getOrder_Quantity();
+
+ /**
+ * The meta object literal for the '{@link dataAccess.impl.PersonImpl <em>Person</em>}' class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see dataAccess.impl.PersonImpl
+ * @see dataAccess.impl.DataAccessPackageImpl#getPerson()
+ * @generated
+ */
+ EClass PERSON = eINSTANCE.getPerson();
+
+ /**
+ * The meta object literal for the '<em><b>Name</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute PERSON__NAME = eINSTANCE.getPerson_Name();
+
+ /**
+ * The meta object literal for the '<em><b>Address</b></em>' attribute feature.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ EAttribute PERSON__ADDRESS = eINSTANCE.getPerson_Address();
+
+ }
+
+} //DataAccessPackage
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/Employee.java b/tests/org.eclipse.jet.tests/src/dataAccess/Employee.java
new file mode 100644
index 0000000..fb499c5
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/Employee.java
@@ -0,0 +1,71 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess;
+
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Employee</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link dataAccess.Employee#getCustomers <em>Customers</em>}</li>
+ * <li>{@link dataAccess.Employee#getEmployeeNumber <em>Employee Number</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see dataAccess.DataAccessPackage#getEmployee()
+ * @model
+ * @generated
+ */
+public interface Employee extends Person {
+ /**
+ * Returns the value of the '<em><b>Customers</b></em>' containment reference list.
+ * The list contents are of type {@link dataAccess.Customer}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Customers</em>' containment reference list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Customers</em>' containment reference list.
+ * @see dataAccess.DataAccessPackage#getEmployee_Customers()
+ * @model type="dataAccess.Customer" containment="true" resolveProxies="false"
+ * @generated
+ */
+ EList getCustomers();
+
+ /**
+ * Returns the value of the '<em><b>Employee Number</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Employee Number</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Employee Number</em>' attribute.
+ * @see #setEmployeeNumber(int)
+ * @see dataAccess.DataAccessPackage#getEmployee_EmployeeNumber()
+ * @model
+ * @generated
+ */
+ int getEmployeeNumber();
+
+ /**
+ * Sets the value of the '{@link dataAccess.Employee#getEmployeeNumber <em>Employee Number</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Employee Number</em>' attribute.
+ * @see #getEmployeeNumber()
+ * @generated
+ */
+ void setEmployeeNumber(int value);
+
+} // Employee
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/Order.java b/tests/org.eclipse.jet.tests/src/dataAccess/Order.java
new file mode 100644
index 0000000..f705a7d
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/Order.java
@@ -0,0 +1,110 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess;
+
+import java.util.Date;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Order</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link dataAccess.Order#getOrderNumber <em>Order Number</em>}</li>
+ * <li>{@link dataAccess.Order#getDate <em>Date</em>}</li>
+ * <li>{@link dataAccess.Order#getQuantity <em>Quantity</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see dataAccess.DataAccessPackage#getOrder()
+ * @model
+ * @generated
+ */
+public interface Order extends EObject {
+ /**
+ * Returns the value of the '<em><b>Order Number</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Order Number</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Order Number</em>' attribute.
+ * @see #setOrderNumber(int)
+ * @see dataAccess.DataAccessPackage#getOrder_OrderNumber()
+ * @model
+ * @generated
+ */
+ int getOrderNumber();
+
+ /**
+ * Sets the value of the '{@link dataAccess.Order#getOrderNumber <em>Order Number</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Order Number</em>' attribute.
+ * @see #getOrderNumber()
+ * @generated
+ */
+ void setOrderNumber(int value);
+
+ /**
+ * Returns the value of the '<em><b>Date</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Date</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Date</em>' attribute.
+ * @see #setDate(Date)
+ * @see dataAccess.DataAccessPackage#getOrder_Date()
+ * @model
+ * @generated
+ */
+ Date getDate();
+
+ /**
+ * Sets the value of the '{@link dataAccess.Order#getDate <em>Date</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Date</em>' attribute.
+ * @see #getDate()
+ * @generated
+ */
+ void setDate(Date value);
+
+ /**
+ * Returns the value of the '<em><b>Quantity</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Quantity</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Quantity</em>' attribute.
+ * @see #setQuantity(int)
+ * @see dataAccess.DataAccessPackage#getOrder_Quantity()
+ * @model
+ * @generated
+ */
+ int getQuantity();
+
+ /**
+ * Sets the value of the '{@link dataAccess.Order#getQuantity <em>Quantity</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Quantity</em>' attribute.
+ * @see #getQuantity()
+ * @generated
+ */
+ void setQuantity(int value);
+
+} // Order
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/Person.java b/tests/org.eclipse.jet.tests/src/dataAccess/Person.java
new file mode 100644
index 0000000..ca85dc4
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/Person.java
@@ -0,0 +1,81 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Person</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link dataAccess.Person#getName <em>Name</em>}</li>
+ * <li>{@link dataAccess.Person#getAddress <em>Address</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @see dataAccess.DataAccessPackage#getPerson()
+ * @model
+ * @generated
+ */
+public interface Person extends EObject {
+ /**
+ * Returns the value of the '<em><b>Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Name</em>' attribute.
+ * @see #setName(String)
+ * @see dataAccess.DataAccessPackage#getPerson_Name()
+ * @model
+ * @generated
+ */
+ String getName();
+
+ /**
+ * Sets the value of the '{@link dataAccess.Person#getName <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Name</em>' attribute.
+ * @see #getName()
+ * @generated
+ */
+ void setName(String value);
+
+ /**
+ * Returns the value of the '<em><b>Address</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Address</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Address</em>' attribute.
+ * @see #setAddress(String)
+ * @see dataAccess.DataAccessPackage#getPerson_Address()
+ * @model
+ * @generated
+ */
+ String getAddress();
+
+ /**
+ * Sets the value of the '{@link dataAccess.Person#getAddress <em>Address</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Address</em>' attribute.
+ * @see #getAddress()
+ * @generated
+ */
+ void setAddress(String value);
+
+} // Person
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/impl/CustomerImpl.java b/tests/org.eclipse.jet.tests/src/dataAccess/impl/CustomerImpl.java
new file mode 100644
index 0000000..39219ee
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/impl/CustomerImpl.java
@@ -0,0 +1,147 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess.impl;
+
+import dataAccess.Customer;
+import dataAccess.DataAccessPackage;
+import dataAccess.Order;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Customer</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link dataAccess.impl.CustomerImpl#getOrders <em>Orders</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class CustomerImpl extends PersonImpl implements Customer {
+ /**
+ * The cached value of the '{@link #getOrders() <em>Orders</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getOrders()
+ * @generated
+ * @ordered
+ */
+ protected EList orders = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected CustomerImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EClass eStaticClass() {
+ return DataAccessPackage.Literals.CUSTOMER;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList getOrders() {
+ if (orders == null) {
+ orders = new EObjectContainmentEList(Order.class, this, DataAccessPackage.CUSTOMER__ORDERS);
+ }
+ return orders;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case DataAccessPackage.CUSTOMER__ORDERS:
+ return ((InternalEList)getOrders()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case DataAccessPackage.CUSTOMER__ORDERS:
+ return getOrders();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case DataAccessPackage.CUSTOMER__ORDERS:
+ getOrders().clear();
+ getOrders().addAll((Collection)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case DataAccessPackage.CUSTOMER__ORDERS:
+ getOrders().clear();
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case DataAccessPackage.CUSTOMER__ORDERS:
+ return orders != null && !orders.isEmpty();
+ }
+ return super.eIsSet(featureID);
+ }
+
+} //CustomerImpl
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/impl/DataAccessFactoryImpl.java b/tests/org.eclipse.jet.tests/src/dataAccess/impl/DataAccessFactoryImpl.java
new file mode 100644
index 0000000..579e852
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/impl/DataAccessFactoryImpl.java
@@ -0,0 +1,130 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess.impl;
+
+import dataAccess.*;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+
+import org.eclipse.emf.ecore.impl.EFactoryImpl;
+
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class DataAccessFactoryImpl extends EFactoryImpl implements DataAccessFactory {
+ /**
+ * Creates the default factory implementation.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static DataAccessFactory init() {
+ try {
+ DataAccessFactory theDataAccessFactory = (DataAccessFactory)EPackage.Registry.INSTANCE.getEFactory("http:///dataAccess.ecore");
+ if (theDataAccessFactory != null) {
+ return theDataAccessFactory;
+ }
+ }
+ catch (Exception exception) {
+ EcorePlugin.INSTANCE.log(exception);
+ }
+ return new DataAccessFactoryImpl();
+ }
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DataAccessFactoryImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EObject create(EClass eClass) {
+ switch (eClass.getClassifierID()) {
+ case DataAccessPackage.CUSTOMER: return createCustomer();
+ case DataAccessPackage.EMPLOYEE: return createEmployee();
+ case DataAccessPackage.ORDER: return createOrder();
+ case DataAccessPackage.PERSON: return createPerson();
+ default:
+ throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Customer createCustomer() {
+ CustomerImpl customer = new CustomerImpl();
+ return customer;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Employee createEmployee() {
+ EmployeeImpl employee = new EmployeeImpl();
+ return employee;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Order createOrder() {
+ OrderImpl order = new OrderImpl();
+ return order;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Person createPerson() {
+ PersonImpl person = new PersonImpl();
+ return person;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DataAccessPackage getDataAccessPackage() {
+ return (DataAccessPackage)getEPackage();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @deprecated
+ * @generated
+ */
+ public static DataAccessPackage getPackage() {
+ return DataAccessPackage.eINSTANCE;
+ }
+
+} //DataAccessFactoryImpl
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/impl/DataAccessPackageImpl.java b/tests/org.eclipse.jet.tests/src/dataAccess/impl/DataAccessPackageImpl.java
new file mode 100644
index 0000000..03d9bec
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/impl/DataAccessPackageImpl.java
@@ -0,0 +1,327 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess.impl;
+
+import dataAccess.Customer;
+import dataAccess.DataAccessFactory;
+import dataAccess.DataAccessPackage;
+import dataAccess.Employee;
+import dataAccess.Order;
+import dataAccess.Person;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Package</b>.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class DataAccessPackageImpl extends EPackageImpl implements DataAccessPackage {
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass customerEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass employeeEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass orderEClass = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private EClass personEClass = null;
+
+ /**
+ * Creates an instance of the model <b>Package</b>, registered with
+ * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
+ * package URI value.
+ * <p>Note: the correct way to create the package is via the static
+ * factory method {@link #init init()}, which also performs
+ * initialization of the package, or returns the registered package,
+ * if one already exists.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see org.eclipse.emf.ecore.EPackage.Registry
+ * @see dataAccess.DataAccessPackage#eNS_URI
+ * @see #init()
+ * @generated
+ */
+ private DataAccessPackageImpl() {
+ super(eNS_URI, DataAccessFactory.eINSTANCE);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private static boolean isInited = false;
+
+ /**
+ * Creates, registers, and initializes the <b>Package</b> for this
+ * model, and for any others upon which it depends. Simple
+ * dependencies are satisfied by calling this method on all
+ * dependent packages before doing anything else. This method drives
+ * initialization for interdependent packages directly, in parallel
+ * with this package, itself.
+ * <p>Of this package and its interdependencies, all packages which
+ * have not yet been registered by their URI values are first created
+ * and registered. The packages are then initialized in two steps:
+ * meta-model objects for all of the packages are created before any
+ * are initialized, since one package's meta-model objects may refer to
+ * those of another.
+ * <p>Invocation of this method will not affect any packages that have
+ * already been initialized.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #eNS_URI
+ * @see #createPackageContents()
+ * @see #initializePackageContents()
+ * @generated
+ */
+ public static DataAccessPackage init() {
+ if (isInited) return (DataAccessPackage)EPackage.Registry.INSTANCE.getEPackage(DataAccessPackage.eNS_URI);
+
+ // Obtain or create and register package
+ DataAccessPackageImpl theDataAccessPackage = (DataAccessPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof DataAccessPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new DataAccessPackageImpl());
+
+ isInited = true;
+
+ // Create package meta-data objects
+ theDataAccessPackage.createPackageContents();
+
+ // Initialize created meta-data
+ theDataAccessPackage.initializePackageContents();
+
+ // Mark meta-data to indicate it can't be changed
+ theDataAccessPackage.freeze();
+
+ return theDataAccessPackage;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getCustomer() {
+ return customerEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getCustomer_Orders() {
+ return (EReference)customerEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getEmployee() {
+ return employeeEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EReference getEmployee_Customers() {
+ return (EReference)employeeEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getEmployee_EmployeeNumber() {
+ return (EAttribute)employeeEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getOrder() {
+ return orderEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getOrder_OrderNumber() {
+ return (EAttribute)orderEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getOrder_Date() {
+ return (EAttribute)orderEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getOrder_Quantity() {
+ return (EAttribute)orderEClass.getEStructuralFeatures().get(2);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EClass getPerson() {
+ return personEClass;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getPerson_Name() {
+ return (EAttribute)personEClass.getEStructuralFeatures().get(0);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EAttribute getPerson_Address() {
+ return (EAttribute)personEClass.getEStructuralFeatures().get(1);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DataAccessFactory getDataAccessFactory() {
+ return (DataAccessFactory)getEFactoryInstance();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isCreated = false;
+
+ /**
+ * Creates the meta-model objects for the package. This method is
+ * guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void createPackageContents() {
+ if (isCreated) return;
+ isCreated = true;
+
+ // Create classes and their features
+ customerEClass = createEClass(CUSTOMER);
+ createEReference(customerEClass, CUSTOMER__ORDERS);
+
+ employeeEClass = createEClass(EMPLOYEE);
+ createEReference(employeeEClass, EMPLOYEE__CUSTOMERS);
+ createEAttribute(employeeEClass, EMPLOYEE__EMPLOYEE_NUMBER);
+
+ orderEClass = createEClass(ORDER);
+ createEAttribute(orderEClass, ORDER__ORDER_NUMBER);
+ createEAttribute(orderEClass, ORDER__DATE);
+ createEAttribute(orderEClass, ORDER__QUANTITY);
+
+ personEClass = createEClass(PERSON);
+ createEAttribute(personEClass, PERSON__NAME);
+ createEAttribute(personEClass, PERSON__ADDRESS);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ private boolean isInitialized = false;
+
+ /**
+ * Complete the initialization of the package and its meta-model. This
+ * method is guarded to have no affect on any invocation but its first.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void initializePackageContents() {
+ if (isInitialized) return;
+ isInitialized = true;
+
+ // Initialize package
+ setName(eNAME);
+ setNsPrefix(eNS_PREFIX);
+ setNsURI(eNS_URI);
+
+ // Add supertypes to classes
+ customerEClass.getESuperTypes().add(this.getPerson());
+ employeeEClass.getESuperTypes().add(this.getPerson());
+
+ // Initialize classes and features; add operations and parameters
+ initEClass(customerEClass, Customer.class, "Customer", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getCustomer_Orders(), this.getOrder(), null, "orders", null, 0, -1, Customer.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(employeeEClass, Employee.class, "Employee", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEReference(getEmployee_Customers(), this.getCustomer(), null, "customers", null, 0, -1, Employee.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getEmployee_EmployeeNumber(), ecorePackage.getEInt(), "employeeNumber", null, 0, 1, Employee.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(orderEClass, Order.class, "Order", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getOrder_OrderNumber(), ecorePackage.getEInt(), "orderNumber", null, 0, 1, Order.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getOrder_Date(), ecorePackage.getEDate(), "date", null, 0, 1, Order.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getOrder_Quantity(), ecorePackage.getEInt(), "quantity", null, 0, 1, Order.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ initEClass(personEClass, Person.class, "Person", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
+ initEAttribute(getPerson_Name(), ecorePackage.getEString(), "name", null, 0, 1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+ initEAttribute(getPerson_Address(), ecorePackage.getEString(), "address", null, 0, 1, Person.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
+
+ // Create resource
+ createResource(eNS_URI);
+ }
+
+} //DataAccessPackageImpl
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/impl/EmployeeImpl.java b/tests/org.eclipse.jet.tests/src/dataAccess/impl/EmployeeImpl.java
new file mode 100644
index 0000000..bcedc36
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/impl/EmployeeImpl.java
@@ -0,0 +1,217 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess.impl;
+
+import dataAccess.Customer;
+import dataAccess.DataAccessPackage;
+import dataAccess.Employee;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.NotificationChain;
+
+import org.eclipse.emf.common.util.EList;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.InternalEObject;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+
+import org.eclipse.emf.ecore.util.EObjectContainmentEList;
+import org.eclipse.emf.ecore.util.InternalEList;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Employee</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link dataAccess.impl.EmployeeImpl#getCustomers <em>Customers</em>}</li>
+ * <li>{@link dataAccess.impl.EmployeeImpl#getEmployeeNumber <em>Employee Number</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class EmployeeImpl extends PersonImpl implements Employee {
+ /**
+ * The cached value of the '{@link #getCustomers() <em>Customers</em>}' containment reference list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getCustomers()
+ * @generated
+ * @ordered
+ */
+ protected EList customers = null;
+
+ /**
+ * The default value of the '{@link #getEmployeeNumber() <em>Employee Number</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getEmployeeNumber()
+ * @generated
+ * @ordered
+ */
+ protected static final int EMPLOYEE_NUMBER_EDEFAULT = 0;
+
+ /**
+ * The cached value of the '{@link #getEmployeeNumber() <em>Employee Number</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getEmployeeNumber()
+ * @generated
+ * @ordered
+ */
+ protected int employeeNumber = EMPLOYEE_NUMBER_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EmployeeImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EClass eStaticClass() {
+ return DataAccessPackage.Literals.EMPLOYEE;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public EList getCustomers() {
+ if (customers == null) {
+ customers = new EObjectContainmentEList(Customer.class, this, DataAccessPackage.EMPLOYEE__CUSTOMERS);
+ }
+ return customers;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public int getEmployeeNumber() {
+ return employeeNumber;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setEmployeeNumber(int newEmployeeNumber) {
+ int oldEmployeeNumber = employeeNumber;
+ employeeNumber = newEmployeeNumber;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, DataAccessPackage.EMPLOYEE__EMPLOYEE_NUMBER, oldEmployeeNumber, employeeNumber));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
+ switch (featureID) {
+ case DataAccessPackage.EMPLOYEE__CUSTOMERS:
+ return ((InternalEList)getCustomers()).basicRemove(otherEnd, msgs);
+ }
+ return super.eInverseRemove(otherEnd, featureID, msgs);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case DataAccessPackage.EMPLOYEE__CUSTOMERS:
+ return getCustomers();
+ case DataAccessPackage.EMPLOYEE__EMPLOYEE_NUMBER:
+ return new Integer(getEmployeeNumber());
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case DataAccessPackage.EMPLOYEE__CUSTOMERS:
+ getCustomers().clear();
+ getCustomers().addAll((Collection)newValue);
+ return;
+ case DataAccessPackage.EMPLOYEE__EMPLOYEE_NUMBER:
+ setEmployeeNumber(((Integer)newValue).intValue());
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case DataAccessPackage.EMPLOYEE__CUSTOMERS:
+ getCustomers().clear();
+ return;
+ case DataAccessPackage.EMPLOYEE__EMPLOYEE_NUMBER:
+ setEmployeeNumber(EMPLOYEE_NUMBER_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case DataAccessPackage.EMPLOYEE__CUSTOMERS:
+ return customers != null && !customers.isEmpty();
+ case DataAccessPackage.EMPLOYEE__EMPLOYEE_NUMBER:
+ return employeeNumber != EMPLOYEE_NUMBER_EDEFAULT;
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (employeeNumber: ");
+ result.append(employeeNumber);
+ result.append(')');
+ return result.toString();
+ }
+
+} //EmployeeImpl
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/impl/OrderImpl.java b/tests/org.eclipse.jet.tests/src/dataAccess/impl/OrderImpl.java
new file mode 100644
index 0000000..95c473f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/impl/OrderImpl.java
@@ -0,0 +1,271 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess.impl;
+
+import dataAccess.DataAccessPackage;
+import dataAccess.Order;
+
+import java.util.Date;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.ecore.EClass;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Order</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link dataAccess.impl.OrderImpl#getOrderNumber <em>Order Number</em>}</li>
+ * <li>{@link dataAccess.impl.OrderImpl#getDate <em>Date</em>}</li>
+ * <li>{@link dataAccess.impl.OrderImpl#getQuantity <em>Quantity</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class OrderImpl extends EObjectImpl implements Order {
+ /**
+ * The default value of the '{@link #getOrderNumber() <em>Order Number</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getOrderNumber()
+ * @generated
+ * @ordered
+ */
+ protected static final int ORDER_NUMBER_EDEFAULT = 0;
+
+ /**
+ * The cached value of the '{@link #getOrderNumber() <em>Order Number</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getOrderNumber()
+ * @generated
+ * @ordered
+ */
+ protected int orderNumber = ORDER_NUMBER_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getDate() <em>Date</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDate()
+ * @generated
+ * @ordered
+ */
+ protected static final Date DATE_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getDate() <em>Date</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDate()
+ * @generated
+ * @ordered
+ */
+ protected Date date = DATE_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getQuantity() <em>Quantity</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getQuantity()
+ * @generated
+ * @ordered
+ */
+ protected static final int QUANTITY_EDEFAULT = 0;
+
+ /**
+ * The cached value of the '{@link #getQuantity() <em>Quantity</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getQuantity()
+ * @generated
+ * @ordered
+ */
+ protected int quantity = QUANTITY_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected OrderImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EClass eStaticClass() {
+ return DataAccessPackage.Literals.ORDER;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public int getOrderNumber() {
+ return orderNumber;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setOrderNumber(int newOrderNumber) {
+ int oldOrderNumber = orderNumber;
+ orderNumber = newOrderNumber;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, DataAccessPackage.ORDER__ORDER_NUMBER, oldOrderNumber, orderNumber));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Date getDate() {
+ return date;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setDate(Date newDate) {
+ Date oldDate = date;
+ date = newDate;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, DataAccessPackage.ORDER__DATE, oldDate, date));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public int getQuantity() {
+ return quantity;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setQuantity(int newQuantity) {
+ int oldQuantity = quantity;
+ quantity = newQuantity;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, DataAccessPackage.ORDER__QUANTITY, oldQuantity, quantity));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case DataAccessPackage.ORDER__ORDER_NUMBER:
+ return new Integer(getOrderNumber());
+ case DataAccessPackage.ORDER__DATE:
+ return getDate();
+ case DataAccessPackage.ORDER__QUANTITY:
+ return new Integer(getQuantity());
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case DataAccessPackage.ORDER__ORDER_NUMBER:
+ setOrderNumber(((Integer)newValue).intValue());
+ return;
+ case DataAccessPackage.ORDER__DATE:
+ setDate((Date)newValue);
+ return;
+ case DataAccessPackage.ORDER__QUANTITY:
+ setQuantity(((Integer)newValue).intValue());
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case DataAccessPackage.ORDER__ORDER_NUMBER:
+ setOrderNumber(ORDER_NUMBER_EDEFAULT);
+ return;
+ case DataAccessPackage.ORDER__DATE:
+ setDate(DATE_EDEFAULT);
+ return;
+ case DataAccessPackage.ORDER__QUANTITY:
+ setQuantity(QUANTITY_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case DataAccessPackage.ORDER__ORDER_NUMBER:
+ return orderNumber != ORDER_NUMBER_EDEFAULT;
+ case DataAccessPackage.ORDER__DATE:
+ return DATE_EDEFAULT == null ? date != null : !DATE_EDEFAULT.equals(date);
+ case DataAccessPackage.ORDER__QUANTITY:
+ return quantity != QUANTITY_EDEFAULT;
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (orderNumber: ");
+ result.append(orderNumber);
+ result.append(", date: ");
+ result.append(date);
+ result.append(", quantity: ");
+ result.append(quantity);
+ result.append(')');
+ return result.toString();
+ }
+
+} //OrderImpl
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/impl/PersonImpl.java b/tests/org.eclipse.jet.tests/src/dataAccess/impl/PersonImpl.java
new file mode 100644
index 0000000..9bb175b
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/impl/PersonImpl.java
@@ -0,0 +1,215 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess.impl;
+
+import dataAccess.DataAccessPackage;
+import dataAccess.Person;
+
+import org.eclipse.emf.common.notify.Notification;
+
+import org.eclipse.emf.ecore.EClass;
+
+import org.eclipse.emf.ecore.impl.ENotificationImpl;
+import org.eclipse.emf.ecore.impl.EObjectImpl;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Person</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link dataAccess.impl.PersonImpl#getName <em>Name</em>}</li>
+ * <li>{@link dataAccess.impl.PersonImpl#getAddress <em>Address</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @generated
+ */
+public class PersonImpl extends EObjectImpl implements Person {
+ /**
+ * The default value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected static final String NAME_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getName()
+ * @generated
+ * @ordered
+ */
+ protected String name = NAME_EDEFAULT;
+
+ /**
+ * The default value of the '{@link #getAddress() <em>Address</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getAddress()
+ * @generated
+ * @ordered
+ */
+ protected static final String ADDRESS_EDEFAULT = null;
+
+ /**
+ * The cached value of the '{@link #getAddress() <em>Address</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getAddress()
+ * @generated
+ * @ordered
+ */
+ protected String address = ADDRESS_EDEFAULT;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected PersonImpl() {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected EClass eStaticClass() {
+ return DataAccessPackage.Literals.PERSON;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setName(String newName) {
+ String oldName = name;
+ name = newName;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, DataAccessPackage.PERSON__NAME, oldName, name));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setAddress(String newAddress) {
+ String oldAddress = address;
+ address = newAddress;
+ if (eNotificationRequired())
+ eNotify(new ENotificationImpl(this, Notification.SET, DataAccessPackage.PERSON__ADDRESS, oldAddress, address));
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object eGet(int featureID, boolean resolve, boolean coreType) {
+ switch (featureID) {
+ case DataAccessPackage.PERSON__NAME:
+ return getName();
+ case DataAccessPackage.PERSON__ADDRESS:
+ return getAddress();
+ }
+ return super.eGet(featureID, resolve, coreType);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eSet(int featureID, Object newValue) {
+ switch (featureID) {
+ case DataAccessPackage.PERSON__NAME:
+ setName((String)newValue);
+ return;
+ case DataAccessPackage.PERSON__ADDRESS:
+ setAddress((String)newValue);
+ return;
+ }
+ super.eSet(featureID, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void eUnset(int featureID) {
+ switch (featureID) {
+ case DataAccessPackage.PERSON__NAME:
+ setName(NAME_EDEFAULT);
+ return;
+ case DataAccessPackage.PERSON__ADDRESS:
+ setAddress(ADDRESS_EDEFAULT);
+ return;
+ }
+ super.eUnset(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean eIsSet(int featureID) {
+ switch (featureID) {
+ case DataAccessPackage.PERSON__NAME:
+ return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
+ case DataAccessPackage.PERSON__ADDRESS:
+ return ADDRESS_EDEFAULT == null ? address != null : !ADDRESS_EDEFAULT.equals(address);
+ }
+ return super.eIsSet(featureID);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String toString() {
+ if (eIsProxy()) return super.toString();
+
+ StringBuffer result = new StringBuffer(super.toString());
+ result.append(" (name: ");
+ result.append(name);
+ result.append(", address: ");
+ result.append(address);
+ result.append(')');
+ return result.toString();
+ }
+
+} //PersonImpl
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/util/DataAccessAdapterFactory.java b/tests/org.eclipse.jet.tests/src/dataAccess/util/DataAccessAdapterFactory.java
new file mode 100644
index 0000000..4ebb4e4
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/util/DataAccessAdapterFactory.java
@@ -0,0 +1,171 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess.util;
+
+import dataAccess.*;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+
+import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
+
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Adapter Factory</b> for the model.
+ * It provides an adapter <code>createXXX</code> method for each class of the model.
+ * <!-- end-user-doc -->
+ * @see dataAccess.DataAccessPackage
+ * @generated
+ */
+public class DataAccessAdapterFactory extends AdapterFactoryImpl {
+ /**
+ * The cached model package.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static DataAccessPackage modelPackage;
+
+ /**
+ * Creates an instance of the adapter factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DataAccessAdapterFactory() {
+ if (modelPackage == null) {
+ modelPackage = DataAccessPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Returns whether this factory is applicable for the type of the object.
+ * <!-- begin-user-doc -->
+ * This implementation returns <code>true</code> if the object is either the model's package or is an instance object of the model.
+ * <!-- end-user-doc -->
+ * @return whether this factory is applicable for the type of the object.
+ * @generated
+ */
+ public boolean isFactoryForType(Object object) {
+ if (object == modelPackage) {
+ return true;
+ }
+ if (object instanceof EObject) {
+ return ((EObject)object).eClass().getEPackage() == modelPackage;
+ }
+ return false;
+ }
+
+ /**
+ * The switch the delegates to the <code>createXXX</code> methods.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected DataAccessSwitch modelSwitch =
+ new DataAccessSwitch() {
+ public Object caseCustomer(Customer object) {
+ return createCustomerAdapter();
+ }
+ public Object caseEmployee(Employee object) {
+ return createEmployeeAdapter();
+ }
+ public Object caseOrder(Order object) {
+ return createOrderAdapter();
+ }
+ public Object casePerson(Person object) {
+ return createPersonAdapter();
+ }
+ public Object defaultCase(EObject object) {
+ return createEObjectAdapter();
+ }
+ };
+
+ /**
+ * Creates an adapter for the <code>target</code>.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param target the object to adapt.
+ * @return the adapter for the <code>target</code>.
+ * @generated
+ */
+ public Adapter createAdapter(Notifier target) {
+ return (Adapter)modelSwitch.doSwitch((EObject)target);
+ }
+
+
+ /**
+ * Creates a new adapter for an object of class '{@link dataAccess.Customer <em>Customer</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see dataAccess.Customer
+ * @generated
+ */
+ public Adapter createCustomerAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link dataAccess.Employee <em>Employee</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see dataAccess.Employee
+ * @generated
+ */
+ public Adapter createEmployeeAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link dataAccess.Order <em>Order</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see dataAccess.Order
+ * @generated
+ */
+ public Adapter createOrderAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for an object of class '{@link dataAccess.Person <em>Person</em>}'.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null so that we can easily ignore cases;
+ * it's useful to ignore a case when inheritance will catch all the cases anyway.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @see dataAccess.Person
+ * @generated
+ */
+ public Adapter createPersonAdapter() {
+ return null;
+ }
+
+ /**
+ * Creates a new adapter for the default case.
+ * <!-- begin-user-doc -->
+ * This default implementation returns null.
+ * <!-- end-user-doc -->
+ * @return the new adapter.
+ * @generated
+ */
+ public Adapter createEObjectAdapter() {
+ return null;
+ }
+
+} //DataAccessAdapterFactory
diff --git a/tests/org.eclipse.jet.tests/src/dataAccess/util/DataAccessSwitch.java b/tests/org.eclipse.jet.tests/src/dataAccess/util/DataAccessSwitch.java
new file mode 100644
index 0000000..95a0779
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/dataAccess/util/DataAccessSwitch.java
@@ -0,0 +1,195 @@
+/**
+ * <copyright>
+ * </copyright>
+ *
+ * $Id$
+ */
+package dataAccess.util;
+
+import dataAccess.*;
+
+import java.util.List;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Switch</b> for the model's inheritance hierarchy.
+ * It supports the call {@link #doSwitch(EObject) doSwitch(object)}
+ * to invoke the <code>caseXXX</code> method for each class of the model,
+ * starting with the actual class of the object
+ * and proceeding up the inheritance hierarchy
+ * until a non-null result is returned,
+ * which is the result of the switch.
+ * <!-- end-user-doc -->
+ * @see dataAccess.DataAccessPackage
+ * @generated
+ */
+public class DataAccessSwitch {
+ /**
+ * The cached model package
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ protected static DataAccessPackage modelPackage;
+
+ /**
+ * Creates an instance of the switch.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DataAccessSwitch() {
+ if (modelPackage == null) {
+ modelPackage = DataAccessPackage.eINSTANCE;
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ public Object doSwitch(EObject theEObject) {
+ return doSwitch(theEObject.eClass(), theEObject);
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected Object doSwitch(EClass theEClass, EObject theEObject) {
+ if (theEClass.eContainer() == modelPackage) {
+ return doSwitch(theEClass.getClassifierID(), theEObject);
+ }
+ else {
+ List eSuperTypes = theEClass.getESuperTypes();
+ return
+ eSuperTypes.isEmpty() ?
+ defaultCase(theEObject) :
+ doSwitch((EClass)eSuperTypes.get(0), theEObject);
+ }
+ }
+
+ /**
+ * Calls <code>caseXXX</code> for each class of the model until one returns a non null result; it yields that result.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return the first non-null result returned by a <code>caseXXX</code> call.
+ * @generated
+ */
+ protected Object doSwitch(int classifierID, EObject theEObject) {
+ switch (classifierID) {
+ case DataAccessPackage.CUSTOMER: {
+ Customer customer = (Customer)theEObject;
+ Object result = caseCustomer(customer);
+ if (result == null) result = casePerson(customer);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case DataAccessPackage.EMPLOYEE: {
+ Employee employee = (Employee)theEObject;
+ Object result = caseEmployee(employee);
+ if (result == null) result = casePerson(employee);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case DataAccessPackage.ORDER: {
+ Order order = (Order)theEObject;
+ Object result = caseOrder(order);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ case DataAccessPackage.PERSON: {
+ Person person = (Person)theEObject;
+ Object result = casePerson(person);
+ if (result == null) result = defaultCase(theEObject);
+ return result;
+ }
+ default: return defaultCase(theEObject);
+ }
+ }
+
+ /**
+ * Returns the result of interpretting the object as an instance of '<em>Customer</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpretting the object as an instance of '<em>Customer</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public Object caseCustomer(Customer object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpretting the object as an instance of '<em>Employee</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpretting the object as an instance of '<em>Employee</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public Object caseEmployee(Employee object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpretting the object as an instance of '<em>Order</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpretting the object as an instance of '<em>Order</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public Object caseOrder(Order object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpretting the object as an instance of '<em>Person</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpretting the object as an instance of '<em>Person</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
+ * @generated
+ */
+ public Object casePerson(Person object) {
+ return null;
+ }
+
+ /**
+ * Returns the result of interpretting the object as an instance of '<em>EObject</em>'.
+ * <!-- begin-user-doc -->
+ * This implementation returns null;
+ * returning a non-null result will terminate the switch, but this is the last case anyway.
+ * <!-- end-user-doc -->
+ * @param object the target of the switch.
+ * @return the result of interpretting the object as an instance of '<em>EObject</em>'.
+ * @see #doSwitch(org.eclipse.emf.ecore.EObject)
+ * @generated
+ */
+ public Object defaultCase(EObject object) {
+ return null;
+ }
+
+} //DataAccessSwitch
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java
new file mode 100644
index 0000000..5ef908c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/AllTests.java
@@ -0,0 +1,22 @@
+package org.eclipse.jet.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("Test for org.eclipse.jet.tests");
+ suite.addTest(org.eclipse.jet.tests.compiler.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.runtime.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.taglib.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.xpath.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.model.load.AllTests.suite());
+ suite.addTest(org.eclipse.jet.tests.taglib.control.AllTests.suite());
+ //$JUnit-BEGIN$
+
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/AllTests.java
new file mode 100644
index 0000000..9f21b0a
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/AllTests.java
@@ -0,0 +1,18 @@
+package org.eclipse.jet.tests.compiler;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.compiler");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TestJET2Parser.class);
+ suite.addTestSuite(TestJETParser.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
new file mode 100644
index 0000000..200bfde
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJET2Parser.java
@@ -0,0 +1,245 @@
+package org.eclipse.jet.tests.compiler;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.CharBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.charset.Charset;
+import java.util.Iterator;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jet.compiler.Comment;
+import org.eclipse.jet.compiler.JET2ASTVisitor;
+import org.eclipse.jet.compiler.JET2CompilationUnit;
+import org.eclipse.jet.compiler.JET2Compiler;
+import org.eclipse.jet.compiler.JET2Declaration;
+import org.eclipse.jet.compiler.JET2Directive;
+import org.eclipse.jet.compiler.JET2Expression;
+import org.eclipse.jet.compiler.JET2Scriptlet;
+import org.eclipse.jet.compiler.TextElement;
+import org.eclipse.jet.compiler.XMLBodyElement;
+import org.eclipse.jet.compiler.XMLEmptyElement;
+import org.eclipse.jet.internal.compiler.templates.JET2JavaGenerator;
+
+public class TestJET2Parser extends TestCase {
+
+ /**
+ * @author pelder
+ *
+ */
+ public static class DumpAST implements JET2ASTVisitor {
+
+ private final StringBuffer buffer = new StringBuffer();
+ private int indent = 0;
+ private final String NL = System.getProperty("line.separator");
+
+ private void doIndent() {
+ for(int i = 0; i < indent; i++) {
+ buffer.append(" ");
+ }
+ }
+
+ public String getLog() {
+ return buffer.toString();
+ }
+
+
+ /**
+ *
+ */
+ public DumpAST() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2CompilationUnit)
+ */
+ public void visit(JET2CompilationUnit compilationUnit) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#endVisit(org.eclipse.jet.compiler.JET2CompilationUnit)
+ */
+ public void endVisit(JET2CompilationUnit compilationUnit) {
+ // TODO Auto-generated method stub
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Declaration)
+ */
+ public void visit(JET2Declaration declaration) {
+ doIndent();
+ buffer.append("<declaration start=\"" + declaration.getStart() + "\" stop=\"" + declaration.getEnd() + "\">");
+ buffer.append(declaration.getJavaContent());
+ buffer.append("</declaration>").append(NL);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Directive)
+ */
+ public void visit(JET2Directive directive) {
+ doIndent();
+ buffer.append("<directive name=\"" + directive.getName() + "\" start=\"" + directive.getStart() + "\" stop=\"" + directive.getEnd() + "\">").append(NL);
+ indent++;
+ for (Iterator i = directive.getAttributes().entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">");
+ buffer.append(entry.getValue()).append("</attribute>").append(NL);
+
+ }
+ indent--;
+ doIndent();
+ buffer.append("</directive>").append(NL);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Expression)
+ */
+ public void visit(JET2Expression expression) {
+ doIndent();
+ buffer.append("<expression start=\"" + expression.getStart() + "\" stop=\"" + expression.getEnd() + "\">");
+ buffer.append(expression.getJavaContent());
+ buffer.append("</expression>").append(NL);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.JET2Scriptlet)
+ */
+ public void visit(JET2Scriptlet scriptlet) {
+ doIndent();
+ buffer.append("<scriptlet start=\"" + scriptlet.getStart() + "\" stop=\"" + scriptlet.getEnd() + "\">");
+ buffer.append(scriptlet.getJavaContent());
+ buffer.append("</scriptlet>").append(NL);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.TextElement)
+ */
+ public void visit(TextElement text) {
+ doIndent();
+ buffer.append("<data>").append(text.getText()).append("</data>").append(NL);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.XMLEmptyElement)
+ */
+ public void visit(XMLEmptyElement xmlEmptyElement) {
+ doIndent();
+ buffer.append("<tag name=\"" + xmlEmptyElement.getName() + "\" start=\"" + xmlEmptyElement.getStart() + "\" stop=\"" + xmlEmptyElement.getEnd() + "\">").append(NL);
+ indent++;
+ for (Iterator i = xmlEmptyElement.getAttributes().entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">" + entry.getValue() + "</attribute>").append(NL);
+ }
+ indent--;
+ doIndent();
+ buffer.append("</tag>").append(NL);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#visit(org.eclipse.jet.compiler.XMLBodyElement)
+ */
+ public void visit(XMLBodyElement xmlBodyElement) {
+ doIndent();
+ buffer.append("<tag name=\"" + xmlBodyElement.getName() + "\" start=\"" + xmlBodyElement.getStart() + "\" stop=\"" + xmlBodyElement.getEnd() + "\">").append(NL);
+ indent++;
+ for (Iterator i = xmlBodyElement.getAttributes().entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">" + entry.getValue() + "</attribute>").append(NL);
+ }
+ doIndent();
+ buffer.append("<content>").append(NL);
+ indent++;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jet.compiler.JET2ASTVisitor#endVisit(org.eclipse.jet.compiler.XMLBodyElement)
+ */
+ public void endVisit(XMLBodyElement xmlBodyElement) {
+ indent--;
+ doIndent();
+ buffer.append("</content>").append(NL);
+ indent--;
+ doIndent();
+ buffer.append("</tag>").append(NL);
+ }
+
+ public void visit(Comment comment) {
+ doIndent();
+ buffer.append("<comment start=\"" + comment.getStart() + "\" stop=\"" + comment.getEnd() + "\">");
+ buffer.append(comment.getCommentText());
+ buffer.append("</comment>").append(NL);
+ }
+
+ }
+
+ private String getFileContents(String urlString) throws Exception {
+ FileInputStream inputStream = getFileContentsAsStream(urlString);
+ FileChannel channel = inputStream.getChannel();
+ MappedByteBuffer mapBuffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
+ Charset utf8Decoder = Charset.forName("UTF-8");
+ CharBuffer charBuffer = utf8Decoder.decode(mapBuffer);
+ String contents = charBuffer.toString();
+ channel.close();
+ inputStream.close();
+ return contents;
+ }
+
+ private FileInputStream getFileContentsAsStream(String urlString) throws IOException, MalformedURLException, FileNotFoundException {
+ String fileName = Platform.resolve(new URL(urlString)).getFile();
+ FileInputStream inputStream = new FileInputStream(new File(fileName));
+ return inputStream;
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.compiler.JET2Parser.compile(String, InputStream, String)'
+ */
+ public void testCompile() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/taglibs.jet";
+
+ InputStream is = getFileContentsAsStream(urlString);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ DumpAST astDumper = new DumpAST();
+ cu.accept(astDumper);
+
+ assertEquals(getFileContents(urlString + ".astdump.expected"), astDumper.getLog());
+
+ }
+
+ public void testCodeGen() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/taglibs.jet";
+
+ InputStream is = getFileContentsAsStream(urlString);
+
+ JET2CompilationUnit cu = new JET2CompilationUnit();
+ cu.parse(is, "UTF-8");
+
+ JET2JavaGenerator writer = new JET2JavaGenerator();
+
+ cu.setOutputJavaPackage(JET2Compiler.DEFAULT_COMPILED_TEMPLATE_PACKAGE);
+ cu.setOutputJavaClassName("X");
+ String result = writer.generate(cu);
+
+ assertEquals(getFileContents(urlString + ".expected.java"), result);
+
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java
new file mode 100644
index 0000000..fec9e49
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/compiler/TestJETParser.java
@@ -0,0 +1,391 @@
+package org.eclipse.jet.tests.compiler;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.CharBuffer;
+import java.nio.MappedByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.emf.codegen.jet.JETException;
+import org.eclipse.jet.compiler.Problem;
+import org.eclipse.jet.internal.compiler.CommentElementDelegate;
+import org.eclipse.jet.internal.compiler.DeclarationElementDelegate;
+import org.eclipse.jet.internal.compiler.XMLElementDelegate;
+import org.eclipse.jet.internal.parser.JETCoreElement;
+import org.eclipse.jet.internal.parser.JETMark;
+import org.eclipse.jet.internal.parser.JETParseEventListener2;
+import org.eclipse.jet.internal.parser.JETParser;
+import org.eclipse.jet.internal.parser.JETReader;
+import org.eclipse.jet.internal.parser.ParseProblemSeverity;
+
+public class TestJETParser extends TestCase {
+
+
+ private static class SavedProblem {
+
+ private final ParseProblemSeverity severity;
+ private final int problemId;
+ private final String message;
+ private final Object[] msgArgs;
+ private final int start;
+ private final int end;
+ private final int line;
+
+ public SavedProblem(ParseProblemSeverity severity, int problemId, String message, Object[] msgArgs, int start, int end, int line) {
+ this.severity = severity;
+ this.problemId = problemId;
+ this.message = message;
+ this.msgArgs = msgArgs;
+ this.start = start;
+ this.end = end;
+ this.line = line;
+ }
+
+ /**
+ * @return Returns the end.
+ */
+ public final int getEnd() {
+ return end;
+ }
+
+ /**
+ * @return Returns the line.
+ */
+ public final int getLine() {
+ return line;
+ }
+
+ /**
+ * @return Returns the message.
+ */
+ public final String getMessage() {
+ return message;
+ }
+
+ /**
+ * @return Returns the msgArgs.
+ */
+ public final Object[] getMsgArgs() {
+ return msgArgs;
+ }
+
+ /**
+ * @return Returns the problemId.
+ */
+ public final int getProblemId() {
+ return problemId;
+ }
+
+ /**
+ * @return Returns the severity.
+ */
+ public final ParseProblemSeverity getSeverity() {
+ return severity;
+ }
+
+ /**
+ * @return Returns the start.
+ */
+ public final int getStart() {
+ return start;
+ }
+
+ }
+
+ private static class AllJET2SyntaxListener implements JETParseEventListener2 {
+
+ private final StringBuffer buffer = new StringBuffer();
+ private int indent = 0;
+ private final String NL = System.getProperty("line.separator");
+ private final JETReader reader;
+ private final List problems = new ArrayList();
+
+
+ public AllJET2SyntaxListener(JETReader reader) {
+ this.reader = reader;
+ }
+
+ public void beginPageProcessing() throws JETException {
+ doIndent();
+ buffer.append("<jet2>").append(NL);
+ indent++;
+ }
+
+ private void doIndent() {
+ for(int i = 0; i < indent; i++) {
+ buffer.append(" ");
+ }
+ }
+
+ public void endPageProcessing() throws JETException {
+ doIndent();
+ buffer.append("</jet2>").append(NL);
+ }
+
+ public String getLog() {
+ return buffer.toString();
+ }
+
+ public void handleCharData(char[] chars) throws JETException {
+ doIndent();
+ buffer.append("<data>").append(chars).append("</data>").append(NL);
+ }
+
+ public void handleComment(JETMark start, JETMark stop) {
+ doIndent();
+ buffer.append("<comment start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">");
+ buffer.append(reader.getChars(start,stop));
+ buffer.append("</comment>").append(NL);
+
+ }
+
+ public void handleDeclaration(JETMark start, JETMark stop) {
+ doIndent();
+ buffer.append("<declaration start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">");
+ buffer.append(reader.getChars(start,stop));
+ buffer.append("</declaration>").append(NL);
+
+ }
+
+ public void handleDirective(String directive, JETMark start,
+ JETMark stop, Map attributes) throws JETException {
+ doIndent();
+ buffer.append("<directive name=\"" + directive + "\" start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">").append(NL);
+ indent++;
+ for (Iterator i = attributes.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">");
+ buffer.append(entry.getValue()).append("</attribute>").append(NL);
+
+ }
+ indent--;
+ doIndent();
+ buffer.append("</directive>").append(NL);
+ }
+
+ public void handleExpression(JETMark start, JETMark stop, Map attributes)
+ throws JETException {
+ doIndent();
+ buffer.append("<expression start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">");
+ buffer.append(reader.getChars(start,stop));
+ buffer.append("</expression>").append(NL);
+ }
+
+ public void handleScriptlet(JETMark start, JETMark stop, Map attributes)
+ throws JETException {
+ doIndent();
+ buffer.append("<scriptlet start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">");
+ buffer.append(reader.getChars(start,stop));
+ buffer.append("</scriptlet>").append(NL);
+ }
+
+ public void handleXMLEmptyTag(String tagName, JETMark start, JETMark stop, Map attributeMap) {
+ doIndent();
+ buffer.append("<tag name=\"" + tagName + "\" start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">").append(NL);
+ indent++;
+ for (Iterator i = attributeMap.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">" + entry.getValue() + "</attribute>").append(NL);
+ }
+ indent--;
+ doIndent();
+ buffer.append("</tag>").append(NL);
+ }
+
+ public void handleXMLEndTag(String tagName, JETMark start, JETMark stop) {
+ indent--;
+ doIndent();
+ buffer.append("</content>").append(NL);
+ indent--;
+ doIndent();
+ buffer.append("</tag>").append(NL);
+ }
+
+ public void handleXMLStartTag(String tagName, JETMark start, JETMark stop, Map attributeMap) {
+ doIndent();
+ buffer.append("<tag name=\"" + tagName + "\" start=\"" + start.toShortString() + "\" stop=\"" + stop.toShortString() + "\">").append(NL);
+ indent++;
+ for (Iterator i = attributeMap.entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ doIndent();
+ buffer.append("<attribute name=\"" + entry.getKey() + "\">" + entry.getValue() + "</attribute>").append(NL);
+ }
+ doIndent();
+ buffer.append("<content>").append(NL);
+ indent++;
+ }
+
+ public boolean isKnownTag(String tagName) {
+ return tagName.startsWith("test:");
+ }
+
+ /**
+ * @return Returns the problems.
+ */
+ public final List getProblems() {
+ return problems;
+ }
+
+ public void recordProblem(ParseProblemSeverity severity, int problemId, String message, Object[] msgArgs, int start, int end, int line) {
+ problems.add(new SavedProblem(severity, problemId, message, msgArgs, start, end, line));
+
+ }
+ }
+
+ private AllJET2SyntaxListener doJET2Parse(String urlString) throws IOException, MalformedURLException, FileNotFoundException, JETException {
+ String fileName = Platform.resolve(new URL(urlString)).getFile();
+
+ FileInputStream inputStream = new FileInputStream(new File(fileName));
+ JETReader reader = new JETReader(urlString, inputStream, "UTF8");
+ AllJET2SyntaxListener listener = new AllJET2SyntaxListener(reader);
+ JETParser.Directive directive = new JETParser.Directive();
+ directive.getDirectives().add("jet");
+
+ JETCoreElement[] coreElements = new JETCoreElement[] {
+ directive,
+ new JETParser.Expression(),
+ new CommentElementDelegate(),
+ new DeclarationElementDelegate(),
+ new JETParser.Scriptlet(),
+ new XMLElementDelegate(),
+ };
+ JETParser parser = new JETParser(reader, listener, coreElements);
+
+ parser.parse();
+ return listener;
+ }
+
+ private void doUnclosedElementTest(String urlString, String openChars, int expectedProblemId) throws IOException, MalformedURLException, FileNotFoundException, JETException {
+ final AllJET2SyntaxListener listener = doJET2Parse(urlString);
+ final List problems = listener.getProblems();
+ assertEquals(1, problems.size());
+ SavedProblem problem = (SavedProblem) problems.get(0);
+ assertEquals(ParseProblemSeverity.ERROR, problem.getSeverity());
+ assertEquals(expectedProblemId, problem.getProblemId());
+ }
+
+ private String getFileContents(String urlString) throws Exception {
+ String fileName = Platform.resolve(new URL(urlString)).getFile();
+ FileInputStream inputStream = new FileInputStream(new File(fileName));
+ FileChannel channel = inputStream.getChannel();
+ MappedByteBuffer mapBuffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
+ Charset utf8Decoder = Charset.forName("UTF-8");
+ CharBuffer charBuffer = utf8Decoder.decode(mapBuffer);
+ String contents = charBuffer.toString();
+ channel.close();
+ inputStream.close();
+ return contents;
+ }
+
+ public void testAllJET2Syntax() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/alljet2.jet";
+ AllJET2SyntaxListener listener = doJET2Parse(urlString);
+
+ assertEquals(getFileContents(urlString + ".expected"), listener.getLog());
+ }
+
+ public void testUnclosedComment() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedComment.jet";
+ String openChars = "<%--";
+
+ try {
+ doUnclosedElementTest(urlString, openChars, 0);
+ fail();
+ } catch(JETException e) {
+ // success.
+ }
+
+
+ }
+
+ public void testUnclosedDeclaration() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedDeclaration.jet";
+ String openChars = "<%!";
+
+ try {
+ doUnclosedElementTest(urlString, openChars, 0);
+ fail();
+ } catch(JETException e) {
+ // success.
+ }
+ }
+
+ public void testUnclosedDirective() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedDirective.jet";
+ String openChars = "<%@";
+
+ try {
+ doUnclosedElementTest(urlString, openChars, 0);
+ fail();
+ } catch(JETException e) {
+ // success.
+ }
+ }
+
+ public void testUnclosedExpression() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedExpression.jet";
+ String openChars = "<%=";
+
+ try {
+ doUnclosedElementTest(urlString, openChars, 0);
+ fail();
+ } catch(JETException e) {
+ // success.
+ }
+ }
+
+ public void testUnclosedScriptlet() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedScriplet.jet";
+ String openChars = "<%";
+
+ try {
+ doUnclosedElementTest(urlString, openChars, 0);
+ fail();
+ } catch(JETException e) {
+ // success.
+ }
+ }
+
+ public void testUnclosedXMLStart() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedXMLStart.jet";
+ String openChars = "<";
+
+ doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
+ }
+
+ public void testUnclosedXMLEnd() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/unclosedXMLEnd.jet";
+ String openChars = "</";
+
+ doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
+ }
+
+ public void testXMLEndWithAttributes() throws Exception {
+ String urlString = "platform:/plugin/org.eclipse.jet.tests/data/xmlEndWithAttributes.jet";
+ String openChars = "</";
+
+ doUnclosedElementTest(urlString, openChars, Problem.UnterminatedXMLTag);
+ }
+
+ // this error is not detected by the parser, but by post parse processing.
+// public void testXMLStartWithoutEnd() throws Exception {
+// String urlString = "platform:/plugin/org.eclipse.jet.tests/data/xmlStartWithoutEnd.jet";
+// String openChars = "<test:start>";
+//
+// doUnclosedElementTest(urlString, openChars, Problem.MissingXmlEndTag);
+// }
+}
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
new file mode 100644
index 0000000..f2d2180
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/AllTests.java
@@ -0,0 +1,18 @@
+package org.eclipse.jet.tests.model.load;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.model.load");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(EmfModelLoaderTests.class);
+ suite.addTestSuite(WorkspaceContextTests.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/EmfModelLoaderTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/EmfModelLoaderTests.java
new file mode 100644
index 0000000..220e838
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/EmfModelLoaderTests.java
@@ -0,0 +1,82 @@
+package org.eclipse.jet.tests.model.load;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot;
+import org.eclipse.jet.internal.runtime.model.EMFModelLoader;
+import org.eclipse.jet.runtime.model.IModelLoader;
+
+public class EmfModelLoaderTests extends TestCase {
+
+ private IModelLoader emfLoader;
+ private URL baseURL;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ emfLoader = new EMFModelLoader();
+ baseURL = new URL("platform:/plugin/org.eclipse.jet.tests/data/");
+ }
+ /*
+ * Test method for 'org.eclipse.jet.internal.runtime.model.EMFModelLoader.load(URL)'
+ */
+ public void testLoad_generic_xml() throws Exception {
+ final Object model = emfLoader.load(new URL(baseURL, "DOMInspector.xml"));
+
+ assertNotNull("Loaded model is null", model);
+
+ assertTrue("instanceof XmlDocumentRoot", model instanceof XMLTypeDocumentRoot);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.runtime.model.EMFModelLoader.load(URL)'
+ */
+ public void testLoad_xsd() throws Exception {
+ final Object model = emfLoader.load(new URL(baseURL, "library.xml"));
+
+ assertNotNull("Loaded model is null", model);
+
+ assertTrue("instanceof EObject", model instanceof EObject);
+ assertEquals("DocumentRoot", ((EObject)model).eClass().getName());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.runtime.model.EMFModelLoader.load(URL)'
+ */
+ public void testLoad_ecore() throws Exception {
+ final Object model = emfLoader.load(new URL(baseURL, "sample.dataaccess"));
+
+ assertNotNull("Loaded model is null", model);
+
+ assertTrue("instanceof Resource", model instanceof Resource);
+ Resource resource = (Resource) model;
+ EObject first = (EObject) resource.getContents().get(0);
+ assertEquals("Employee", first.eClass().getName());
+ }
+ /*
+ * Test method for 'org.eclipse.jet.internal.runtime.model.EMFModelLoader.loadFromString(String)'
+ */
+ public void testLoadFromString() throws Exception {
+ String document = "<root><a><b/><b/></a><a><c/></a></root>";
+ final Object model = emfLoader.loadFromString(document, "xml");
+
+ assertNotNull("Loaded model is null", model);
+
+ assertTrue("instanceof XmlDocumentRoot", model instanceof XMLTypeDocumentRoot);
+ }
+
+ public void testLoad_URL_String() throws Exception {
+ final Object model = emfLoader.load(new URL(baseURL, "library.xml.indisguise"), "xml");
+
+ assertNotNull("Loaded model is null", model);
+
+ assertTrue("instanceof EObject", model instanceof EObject);
+ assertEquals("DocumentRoot", ((EObject)model).eClass().getName());
+ }
+
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/WorkspaceContextTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/WorkspaceContextTests.java
new file mode 100644
index 0000000..a6b8471
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/model/load/WorkspaceContextTests.java
@@ -0,0 +1,37 @@
+package org.eclipse.jet.tests.model.load;
+
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.runtime.model.WorkspaceLoadContext;
+import org.eclipse.jet.runtime.model.ILoadContext;
+
+public class WorkspaceContextTests extends TestCase {
+
+ private ILoadContext definedContext;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ definedContext = new WorkspaceLoadContext();
+ }
+ /*
+ * Test method for 'org.eclipse.jet.internal.runtime.model.WorkspaceLoadContext.getName()'
+ */
+ public void testGetName() {
+ final String name = definedContext.getName();
+
+ assertEquals("workspace", name);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.runtime.model.WorkspaceLoadContext.getContextUrl()'
+ */
+ public void testGetContextUrl() {
+ final URL contextUrl = definedContext.getContextUrl();
+
+ assertEquals("platform:/resource/", contextUrl.toExternalForm());
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/AllTests.java
new file mode 100644
index 0000000..0debdf6
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/AllTests.java
@@ -0,0 +1,17 @@
+package org.eclipse.jet.tests.runtime;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.runtime");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TestBundleLoading.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleLoading.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleLoading.java
new file mode 100644
index 0000000..fa37fc9
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/runtime/TestBundleLoading.java
@@ -0,0 +1,31 @@
+package org.eclipse.jet.tests.runtime;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.jet.JET2Template;
+import org.eclipse.jet.JET2TemplateLoader;
+import org.eclipse.jet.internal.InternalJET2Platform;
+import org.eclipse.jet.internal.runtime.IJET2Runnable;
+import org.eclipse.jet.transform.IJETBundle;
+
+public class TestBundleLoading extends TestCase {
+
+ public void testLoadSimpleBundle() throws Exception {
+ IJETBundle tx = InternalJET2Platform.getDefault().getTemplateBundle("org.eclipse.jet.transforms.newproject", null);
+
+ assertNotNull(tx);
+
+ tx.execute(new IJET2Runnable() {
+
+ public Diagnostic run(JET2TemplateLoader loader) {
+ JET2Template template = loader.getTemplate("templates/control.jet");
+
+ assertNotNull(template);
+
+ return Diagnostic.OK_INSTANCE;
+ }});
+
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/AllTests.java
new file mode 100644
index 0000000..3f0f0ea
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/AllTests.java
@@ -0,0 +1,17 @@
+package org.eclipse.jet.tests.taglib;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.taglib");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(TestTagLibManager.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/TestTagLibManager.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/TestTagLibManager.java
new file mode 100644
index 0000000..b118c60
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/TestTagLibManager.java
@@ -0,0 +1,58 @@
+package org.eclipse.jet.tests.taglib;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.taglib.InternalTagLibManager;
+import org.eclipse.jet.taglib.TagLibrary;
+
+public class TestTagLibManager extends TestCase {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.taglib.InternalTagLibManager.getTagLibrary(String)'
+ */
+ public void testGetTagLibrary() {
+ InternalTagLibManager manager = new InternalTagLibManager();
+ manager.startup();
+ try {
+ String libraryId = "org.eclipse.jet.tests.TestLibrary";
+ TagLibrary tagLibrary = manager.getTagLibrary(libraryId);
+ assertNotNull(tagLibrary);
+ assertEquals(libraryId, tagLibrary.getLibraryId());
+ } finally {
+ manager.shutdown();
+ }
+ }
+
+ public void testGetTagLibrary_invalidId() {
+ InternalTagLibManager manager = new InternalTagLibManager();
+ manager.startup();
+ try {
+ String libraryId = "org.eclipse.jet.tests.TestLibrary-invalid";
+ TagLibrary tagLibrary = manager.getTagLibrary(libraryId);
+ assertNull(tagLibrary);
+ } finally {
+ manager.shutdown();
+ }
+ }
+
+ public void testTagLibrary_getTagsNames() {
+ InternalTagLibManager manager = new InternalTagLibManager();
+ manager.startup();
+ try {
+ String libraryId = "org.eclipse.jet.tests.TestLibrary";
+ String[] expectedTagNames = new String[] {
+ "isAllUpper", "nl", "other", "tokenize", "upper",
+ };
+ TagLibrary tagLibrary = manager.getTagLibrary(libraryId);
+ assertNotNull(tagLibrary);
+ String[] tagNames = tagLibrary.getTagNames();
+ assertEquals(5, tagNames.length);
+ for (int i = 0; i < tagNames.length; i++) {
+ assertEquals(expectedTagNames[i], tagNames[i]);
+ }
+ } finally {
+ manager.shutdown();
+ }
+
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/AllTests.java
new file mode 100644
index 0000000..f426e2c
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/AllTests.java
@@ -0,0 +1,17 @@
+package org.eclipse.jet.tests.taglib.control;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.taglib.control");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(LoadTagTests.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java
new file mode 100644
index 0000000..48f10ec
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/taglib/control/LoadTagTests.java
@@ -0,0 +1,49 @@
+package org.eclipse.jet.tests.taglib.control;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jet.BodyContentWriter;
+import org.eclipse.jet.JET2Context;
+import org.eclipse.jet.JET2Writer;
+import org.eclipse.jet.XPathContextExtender;
+import org.eclipse.jet.internal.InternalJET2Platform;
+import org.eclipse.jet.internal.taglib.control.LoadTag;
+import org.eclipse.jet.taglib.JET2TagException;
+import org.eclipse.jet.taglib.TagInfo;
+import org.eclipse.jet.transform.IJETBundle;
+import org.eclipse.jet.transform.TransformContextExtender;
+
+import junit.framework.TestCase;
+
+public class LoadTagTests extends TestCase {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.taglib.control.LoadTag.doAction(TagInfo, JET2Context, JET2Writer)'
+ */
+ public void testDoAction() throws JET2TagException, CoreException {
+
+ final String id = "org.eclipse.jet.transforms.newproject";
+ JET2Context context = new JET2Context((Object)null);
+ TransformContextExtender tce = new TransformContextExtender(context);
+
+ final IJETBundle templateBundle = InternalJET2Platform.getDefault().getTemplateBundle(id, null);
+ tce.setId(id);
+ tce.setTransform(templateBundle);
+
+ LoadTag tag = new LoadTag();
+ TagInfo td = new TagInfo("", 0, 0, 0,
+ new String[] { "url", "var", "type" },
+ new String[] { "templates/project/sample.xml.jet", "root", "xml" });
+ tag.setTagInfo(td);
+ tag.setContext(context);
+ tag.setParent(null);
+
+ JET2Writer out = new BodyContentWriter();
+
+ tag.doAction(td, context, out);
+
+ assertEquals("", out.getDocument().get());
+ final Object loadedDocument = new XPathContextExtender(context).resolveVariable("root");
+ assertNotNull("loaded document", loadedDocument);
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AbstractExprTest.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AbstractExprTest.java
new file mode 100644
index 0000000..92a2cd4
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AbstractExprTest.java
@@ -0,0 +1,93 @@
+/**
+ *
+ */
+package org.eclipse.jet.tests.xpath;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import junit.framework.TestCase;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
+
+/**
+ * @author pelder
+ *
+ */
+public abstract class AbstractExprTest extends TestCase{
+
+ protected Document document;
+ protected static final String EXPECTED_ATTR_TEXT = "test";
+ protected static final String EXPECTED_COMMENT_TEXT = " a comment within root ";
+ protected static final String EXPECTED_PI_TEXT = "version=\"3.0\"";
+ protected static final String EXPECTED_B_TEXT = "Some foo text.";
+ protected static final String EXPECTED_A_TEXT = "\n\t\t" + EXPECTED_B_TEXT + "\n\t";
+ protected static final String EXPECTED_OTHER_A_TEXT = "\n\t\t" + "Some bar text." + "\n\t";
+ protected static final String EXPECTED_OTHER_B_TEXT = "Some bar text.";
+ protected static final String EXPECTED_DOC_TEXT = "\n\t" + "\n\t" + EXPECTED_A_TEXT
+ + "\n\t" + EXPECTED_OTHER_A_TEXT + "\n";
+
+ private void loadDocument() {
+ InputStream inputStream = null;
+ try {
+ URL dataURL = new URL(
+ "platform:/plugin/org.eclipse.jet.tests/data/DOMInspector.xml");
+ inputStream = dataURL.openStream();
+ DocumentBuilderFactory factory = DocumentBuilderFactory
+ .newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+
+ document = builder.parse(inputStream, "UTF-8");
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } catch (ParserConfigurationException e) {
+ throw new RuntimeException(e);
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ // do nothing
+ }
+ }
+ }
+ }
+
+ protected Element rootElement;
+ protected Element elementA;
+ protected Element elementB;
+ protected Attr attr;
+ protected Node bText;
+ protected Node pi;
+ protected Node comment;
+
+ /**
+ *
+ */
+ public AbstractExprTest() {
+ super();
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ loadDocument();
+ rootElement = document.getDocumentElement();
+ elementA = (Element) rootElement.getElementsByTagName("a").item(0);
+ elementB = (Element) elementA.getElementsByTagName("b").item(0);
+ bText = elementB.getFirstChild();
+ attr = rootElement.getAttributeNode("rootAttr");
+ pi = document.getFirstChild();
+ comment = rootElement.getFirstChild().getNextSibling();
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java
new file mode 100644
index 0000000..de9fbff
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AllTests.java
@@ -0,0 +1,40 @@
+package org.eclipse.jet.tests.xpath;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.eclipse.jet.tests.xpath");
+ //$JUnit-BEGIN$
+ suite.addTestSuite(StringFunctionTests.class);
+ suite.addTestSuite(AttributeStepTests.class);
+ suite.addTestSuite(RelOpTests.class);
+ suite.addTestSuite(BooleanFunctionTests.class);
+ suite.addTestSuite(BuiltinStringFunctionsTests.class);
+ suite.addTestSuite(XPathOverEmfXmlXsdTests.class);
+ suite.addTestSuite(EStructuralFeatureSettingTests.class);
+ suite.addTestSuite(XPathParserTests.class);
+ suite.addTestSuite(ChildStepTests.class);
+ suite.addTestSuite(XPathInspectorManagerTests.class);
+ suite.addTestSuite(NumberFunctionTests.class);
+ suite.addTestSuite(DOMInspectorTests.class);
+ suite.addTestSuite(XPathOverDOMTests.class);
+ suite.addTestSuite(LogicalOpTests.class);
+ suite.addTestSuite(ParentStepTests.class);
+ suite.addTestSuite(XPathTokenScannerTests.class);
+ suite.addTestSuite(ExpandedNameTests.class);
+ suite.addTestSuite(EObjectInspectorTests.class);
+ suite.addTestSuite(XPathOverEcoreTests.class);
+ suite.addTestSuite(VariableTests.class);
+ suite.addTestSuite(RootTests.class);
+ suite.addTestSuite(ResourceInspectorTests.class);
+ suite.addTestSuite(NumberBinaryOpTests.class);
+ suite.addTestSuite(XPathParserDefects.class);
+ //$JUnit-END$
+ return suite;
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AttributeStepTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AttributeStepTests.java
new file mode 100644
index 0000000..1376a2e
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/AttributeStepTests.java
@@ -0,0 +1,71 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Set;
+
+import org.eclipse.jet.internal.xpath.ast.Axis;
+import org.eclipse.jet.internal.xpath.ast.NodeTest;
+import org.eclipse.jet.internal.xpath.ast.Root;
+import org.eclipse.jet.internal.xpath.ast.Step;
+import org.eclipse.jet.xpath.Context;
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+import org.eclipse.jet.xpath.inspector.INodeInspector.NodeKind;
+
+public class AttributeStepTests extends AbstractExprTest {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ast.Step.evalAsNodeSet(Context, INodeInspector)'
+ */
+ public void testEvalAsNodeSet_attribute_all() {
+ Step stepExpr = new Step(
+ new Step(new Root(), Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("root"))),
+ Axis.attributeAxis(),
+ NodeTest.nameTest(NodeKind.ATTRIBUTE, new ExpandedName("*"))
+ );
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(attr));
+
+ }
+
+ public void testEvalAsNodeSet_attribute_foo() {
+ Step stepExpr = new Step(
+ new Step(new Root(), Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("root"))),
+ Axis.attributeAxis(),
+ NodeTest.nameTest(NodeKind.ATTRIBUTE, new ExpandedName("foo"))
+ );
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(0, resultSet.size());
+
+ }
+
+ public void testEvalAsNodeSet_attribute_rootAttr() {
+ Step stepExpr = new Step(
+ new Step(new Root(), Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("root"))),
+ Axis.attributeAxis(),
+ NodeTest.nameTest(NodeKind.ATTRIBUTE, new ExpandedName("rootAttr"))
+ );
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(attr));
+
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/BooleanFunctionTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/BooleanFunctionTests.java
new file mode 100644
index 0000000..6d449d1
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/BooleanFunctionTests.java
@@ -0,0 +1,61 @@
+package org.eclipse.jet.tests.xpath;
+
+
+import org.eclipse.jet.internal.xpath.NodeSetImpl;
+import org.eclipse.jet.internal.xpath.functions.BooleanFunction;
+
+public class BooleanFunctionTests extends AbstractExprTest {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.functions.BooleanFunction.evaluate(Object)'
+ */
+ public void testEvaluateObject_String_nonempty() {
+ boolean result = BooleanFunction.evaluate("hello");
+ assertTrue(result);
+ }
+ public void testEvaluateObject_String_empty() {
+ boolean result = BooleanFunction.evaluate("");
+ assertFalse(result);
+ }
+
+ public void testEvaluateObject_Number_false() {
+ boolean result1 = BooleanFunction.evaluate(new Double(Double.NaN));
+ assertFalse(result1);
+
+ boolean result2 = BooleanFunction.evaluate(new Double(0.0));
+ assertFalse(result2);
+
+ boolean result3 = BooleanFunction.evaluate(new Double(-0.0));
+ assertFalse(result3);
+ }
+
+ public void testEvaluateObject_Number_true() {
+ boolean result1 = BooleanFunction.evaluate(new Double(Double.NEGATIVE_INFINITY));
+ assertTrue(result1);
+
+ boolean result2 = BooleanFunction.evaluate(new Double(Double.POSITIVE_INFINITY));
+ assertTrue(result2);
+
+ boolean result3 = BooleanFunction.evaluate(new Double(0.001));
+ assertTrue(result3);
+
+ boolean result4 = BooleanFunction.evaluate(new Double(-0.01));
+ assertTrue(result4);
+ }
+
+ public void testEvaluateObject_Nodeset() {
+ NodeSetImpl ns = new NodeSetImpl();
+
+ assertFalse(BooleanFunction.evaluate(ns));
+
+ ns.add(elementA);
+
+ assertTrue(BooleanFunction.evaluate(ns));
+
+ ns.add(elementB);
+
+ assertTrue(BooleanFunction.evaluate(ns));
+
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/BuiltinStringFunctionsTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/BuiltinStringFunctionsTests.java
new file mode 100644
index 0000000..566151a
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/BuiltinStringFunctionsTests.java
@@ -0,0 +1,214 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jet.internal.xpath.ast.ExprNode;
+import org.eclipse.jet.internal.xpath.ast.Function;
+import org.eclipse.jet.internal.xpath.ast.NumberLiteral;
+import org.eclipse.jet.internal.xpath.ast.StringLiteral;
+import org.eclipse.jet.internal.xpath.functions.BuiltinXPathFunctionResolver;
+import org.eclipse.jet.xpath.Context;
+
+public class BuiltinStringFunctionsTests extends AbstractExprTest {
+
+ public void testConcat() {
+ List args = new ArrayList();
+ args.add(new StringLiteral("one"));
+ args.add(new StringLiteral("two"));
+ args.add(new StringLiteral("three"));
+ String functionName = "concat";
+ Object result = runFunction(functionName, args);
+
+ assertTrue(result instanceof String);
+ assertEquals("onetwothree", (String)result);
+
+ }
+
+ private Object runFunction(String functionName, List args, Context context) {
+ ExprNode expr = new Function(functionName, BuiltinXPathFunctionResolver.getInstance()
+ .resolveFunction(functionName, args.size()), args);
+ Object result = expr.evalAsObject(context);
+ return result;
+
+ }
+ /**
+ * @param functionName
+ * @param args
+ * @return
+ */
+ private Object runFunction(String functionName, List args) {
+ return runFunction(functionName, args, null);
+ }
+
+ public void testStartsWith() {
+ List args = new ArrayList();
+ args.add(new StringLiteral("abcde"));
+ args.add(new StringLiteral("abc"));
+
+ Object result = runFunction("starts-with", args);
+ assertTrue(result instanceof Boolean);
+ assertTrue(((Boolean)result).booleanValue());
+
+ args.clear();
+ args.add(new StringLiteral("abc"));
+ args.add(new StringLiteral("abcde"));
+
+ result = runFunction("starts-with", args);
+ assertTrue(result instanceof Boolean);
+ assertFalse(((Boolean)result).booleanValue());
+ }
+
+ public void testContains() {
+ List args = new ArrayList();
+ args.add(new StringLiteral("abcde"));
+ args.add(new StringLiteral("abc"));
+
+ Object result = runFunction("contains", args);
+ assertTrue(result instanceof Boolean);
+ assertTrue(((Boolean)result).booleanValue());
+
+ args.clear();
+ args.add(new StringLiteral("abc"));
+ args.add(new StringLiteral("abcde"));
+
+ result = runFunction("contains", args);
+ assertTrue(result instanceof Boolean);
+ assertFalse(((Boolean)result).booleanValue());
+
+ args.clear();
+ args.add(new StringLiteral("abcde"));
+ args.add(new StringLiteral("bc"));
+
+ result = runFunction("contains", args);
+ assertTrue(result instanceof Boolean);
+ assertTrue(((Boolean)result).booleanValue());
+
+ args.clear();
+ args.add(new StringLiteral("abc"));
+ args.add(new StringLiteral(""));
+
+ result = runFunction("contains", args);
+ assertTrue(result instanceof Boolean);
+ assertTrue(((Boolean)result).booleanValue());
+
+ }
+
+ public void testSubstringBefore() {
+ List args = new ArrayList();
+ args.add(new StringLiteral("1999/04/01"));
+ args.add(new StringLiteral("/"));
+
+ Object result = runFunction("substring-before", args);
+ assertTrue(result instanceof String);
+ assertEquals("1999", (String)result);
+
+
+ args.clear();
+ args.add(new StringLiteral("1999/04/01"));
+ args.add(new StringLiteral(";"));
+
+ result = runFunction("substring-before", args);
+ assertTrue(result instanceof String);
+ assertEquals("", (String)result);
+
+ }
+
+ public void testSubstringAfter() {
+ List args = new ArrayList();
+ args.add(new StringLiteral("1999/04/01"));
+ args.add(new StringLiteral("/"));
+
+ Object result = runFunction("substring-after", args);
+ assertTrue(result instanceof String);
+ assertEquals("04/01", (String)result);
+
+ args.clear();
+ args.add(new StringLiteral("1999/04/01"));
+ args.add(new StringLiteral(";"));
+
+ result = runFunction("substring-after", args);
+ assertTrue(result instanceof String);
+ assertEquals("", (String)result);
+ }
+
+ public void testSubstring() {
+ List args = new ArrayList();
+ args.add(new StringLiteral("12345"));
+ args.add(new NumberLiteral(1.5));
+ args.add(new NumberLiteral(2.6));
+
+ Object result = runFunction("substring", args);
+ assertTrue(result instanceof String);
+ assertEquals("234", (String)result);
+
+ args.clear();
+ args.add(new StringLiteral("12345"));
+ args.add(new NumberLiteral(0));
+ args.add(new NumberLiteral(3));
+
+ result = runFunction("substring", args);
+ assertTrue(result instanceof String);
+ assertEquals("12", (String)result);
+
+ args.clear();
+ args.add(new StringLiteral("12345"));
+ args.add(new NumberLiteral(0d / 0d));
+ args.add(new NumberLiteral(3));
+
+ result = runFunction("substring", args);
+ assertTrue(result instanceof String);
+ assertEquals("", (String)result);
+
+ args.clear();
+ args.add(new StringLiteral("12345"));
+ args.add(new NumberLiteral(1));
+ args.add(new NumberLiteral(0d / 0d));
+
+ result = runFunction("substring", args);
+ assertTrue(result instanceof String);
+ assertEquals("", (String)result);
+
+ args.clear();
+ args.add(new StringLiteral("12345"));
+ args.add(new NumberLiteral(-42));
+ args.add(new NumberLiteral(1d / 0d));
+
+ result = runFunction("substring", args);
+ assertTrue(result instanceof String);
+ assertEquals("12345", (String)result);
+
+ args.clear();
+ args.add(new StringLiteral("12345"));
+ args.add(new NumberLiteral(-1d / 0d));
+ args.add(new NumberLiteral(1d / 0d));
+
+ result = runFunction("substring", args);
+ assertTrue(result instanceof String);
+ assertEquals("", (String)result);
+
+ args.clear();
+ args.add(new StringLiteral("12345"));
+ args.add(new NumberLiteral(2));
+
+ result = runFunction("substring", args);
+ assertTrue(result instanceof String);
+ assertEquals("2345", (String)result);
+ }
+
+ public void testStringLength() {
+ List args = new ArrayList();
+ args.add(new StringLiteral("12345"));
+
+ Object result = runFunction("string-length", args);
+ assertTrue(result instanceof Number);
+ assertEquals(5, ((Number)result).doubleValue(), 0);
+
+ args.clear();
+ Context c = new Context(elementB, null);
+ result = runFunction("string-length", args, c);
+ assertTrue(result instanceof Number);
+ assertEquals(EXPECTED_B_TEXT.length(), ((Number)result).doubleValue(), 0);
+
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ChildStepTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ChildStepTests.java
new file mode 100644
index 0000000..e69e589
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ChildStepTests.java
@@ -0,0 +1,145 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Set;
+
+import org.eclipse.jet.internal.xpath.ast.Axis;
+import org.eclipse.jet.internal.xpath.ast.NodeTest;
+import org.eclipse.jet.internal.xpath.ast.Root;
+import org.eclipse.jet.internal.xpath.ast.Step;
+import org.eclipse.jet.xpath.Context;
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+import org.eclipse.jet.xpath.inspector.INodeInspector.NodeKind;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class ChildStepTests extends AbstractExprTest {
+
+ public void testEvalAsNodeSet_root_element_root() {
+ Step stepExpr = new Step(new Root(), Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("root")));
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(rootElement));
+
+ }
+
+ public void testEvalAsNodeSet_root_element_all() {
+ Step stepExpr = new Step(new Root(), Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("*")));
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(rootElement));
+
+ }
+
+ public void testEvalAsNodeSet_root_a_elements() {
+ Step stepExpr = new Step(
+ new Step(new Root(), Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("root"))),
+ Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("a")));
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(2, resultSet.size());
+ Node elementA2 = (Element) rootElement.getElementsByTagName("a").item(1);
+
+ assertTrue(resultSet.contains(elementA));
+ assertTrue(resultSet.contains(elementA2));
+ }
+
+ public void testEvalAsNodeSet_root_a_b_elements() {
+ Step stepExpr = new Step(
+ new Step(
+ new Step(new Root(), Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("root"))),
+ Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("a"))),
+ Axis.childAxis(),
+ NodeTest.nameTest(NodeKind.ELEMENT, new ExpandedName("b"))
+ );
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(2, resultSet.size());
+ Element elementA2 = (Element) rootElement.getElementsByTagName("a").item(1);
+ Node elementB2 = (Element) elementA2.getElementsByTagName("b").item(0);
+
+ assertTrue(resultSet.contains(elementB));
+ assertTrue(resultSet.contains(elementB2));
+ }
+
+ public void testEvalAsNodeSet_root_all() {
+ Step stepExpr = new Step(new Root(), Axis.childAxis(),
+ NodeTest.allNodes());
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(2, resultSet.size());
+ assertTrue(resultSet.contains(rootElement));
+ assertTrue(resultSet.contains(pi));
+
+ }
+
+ public void testEvalAsNodeSet_root_pi_all() {
+ Step stepExpr = new Step(new Root(), Axis.childAxis(),
+ NodeTest.allProcessingInstructionNodes());
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(pi));
+
+ }
+
+ public void testEvalAsNodeSet_root_pi_eclipse() {
+ Step stepExpr = new Step(new Root(), Axis.childAxis(),
+ NodeTest.processingInstructionNodes("eclipse"));
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(pi));
+
+ }
+
+ public void testEvalAsNodeSet_root_pi_foo() {
+ Step stepExpr = new Step(new Root(), Axis.childAxis(),
+ NodeTest.processingInstructionNodes("foo"));
+
+ Context context = new Context(document, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(0, resultSet.size());
+
+ }
+
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DOMInspectorTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DOMInspectorTests.java
new file mode 100644
index 0000000..e62fd77
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/DOMInspectorTests.java
@@ -0,0 +1,184 @@
+package org.eclipse.jet.tests.xpath;
+
+import org.eclipse.jet.internal.xpath.inspectors.DOMInspector;
+import org.eclipse.jet.xpath.inspector.CopyElementException;
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+import org.eclipse.jet.xpath.inspector.INodeInspector.NodeKind;
+
+public class DOMInspectorTests extends AbstractExprTest {
+
+ private DOMInspector inspector;
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.inspector = new DOMInspector();
+ }
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.DOMInspector.getNodeKind(Object)'
+ */
+ public void testGetNodeKind() {
+
+ assertEquals(NodeKind.ROOT, inspector.getNodeKind(document));
+ assertEquals(NodeKind.ELEMENT, inspector.getNodeKind(rootElement));
+ assertEquals(NodeKind.ATTRIBUTE, inspector.getNodeKind(attr));
+ assertEquals(NodeKind.PROCESSING_INSTRUCTION, inspector.getNodeKind(pi));
+ assertEquals(NodeKind.TEXT, inspector.getNodeKind(bText));
+ assertEquals(NodeKind.COMMENT, inspector.getNodeKind(comment));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.DOMInspector.getParent(Object)'
+ */
+ public void testGetParent() {
+ assertNull(inspector.getParent(document));
+ assertEquals(document, inspector.getParent(rootElement));
+ assertEquals(rootElement, inspector.getParent(attr));
+ assertEquals(rootElement, inspector.getParent(elementA));
+ assertEquals(elementA, inspector.getParent(elementB));
+ assertEquals(elementB, inspector.getParent(bText));
+ assertEquals(document, inspector.getParent(pi));
+ assertEquals(rootElement, inspector.getParent(comment));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.DOMInspector.stringValueOf(Object)'
+ */
+ public void testStringValueOf() {
+ assertEquals(EXPECTED_ATTR_TEXT, inspector.stringValueOf(attr));
+ assertEquals(EXPECTED_A_TEXT, inspector.stringValueOf(elementA));
+ assertEquals(EXPECTED_B_TEXT, inspector.stringValueOf(elementB));
+ assertEquals(EXPECTED_B_TEXT, inspector.stringValueOf(bText));
+ assertEquals(EXPECTED_DOC_TEXT, inspector.stringValueOf(document));
+ assertEquals(EXPECTED_DOC_TEXT, inspector.stringValueOf(rootElement));
+ assertEquals(EXPECTED_PI_TEXT, inspector.stringValueOf(pi));
+ assertEquals(EXPECTED_COMMENT_TEXT, inspector.stringValueOf(comment));
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.DOMInspector.expandedNameOf(Object)'
+ */
+ public void testExpandedNameOf() {
+ assertNull(inspector.expandedNameOf(document));
+ assertEquals(new ExpandedName("root"), inspector.expandedNameOf(rootElement));
+ assertEquals(new ExpandedName("a"), inspector.expandedNameOf(elementA));
+ assertEquals(new ExpandedName("b"), inspector.expandedNameOf(elementB));
+ assertNull(inspector.expandedNameOf(bText));
+ assertEquals(new ExpandedName("rootAttr"), inspector.expandedNameOf(attr));
+ assertEquals(new ExpandedName("eclipse"), inspector.expandedNameOf(pi));
+ assertNull(inspector.expandedNameOf(comment));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.DOMInspector.getAttributes(Object)'
+ */
+ public void testGetAttributes() {
+
+ assertEquals(0, inspector.getAttributes(document).length);
+ assertEquals(0, inspector.getAttributes(bText).length);
+ assertEquals(0, inspector.getAttributes(attr).length);
+ assertEquals(0, inspector.getAttributes(pi).length);
+ assertEquals(0, inspector.getAttributes(comment).length);
+
+ assertEquals(0, inspector.getAttributes(elementB).length);
+
+ Object[] aAttributes = inspector.getAttributes(elementA);
+ assertNotNull(aAttributes);
+ assertEquals(1, aAttributes.length);
+ assertEquals("name", inspector.expandedNameOf(aAttributes[0]).toString());
+ assertEquals("foo", inspector.stringValueOf(aAttributes[0]));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.DOMInspector.getDocumentRoot(Object)'
+ */
+ public void testGetDocumentRoot() {
+ assertEquals(document, inspector.getDocumentRoot(document));
+ assertEquals(document, inspector.getDocumentRoot(rootElement));
+ assertEquals(document, inspector.getDocumentRoot(elementA));
+ assertEquals(document, inspector.getDocumentRoot(elementB));
+ assertEquals(document, inspector.getDocumentRoot(bText));
+ assertEquals(document, inspector.getDocumentRoot(attr));
+ assertEquals(document, inspector.getDocumentRoot(pi));
+ assertEquals(document, inspector.getDocumentRoot(comment));
+ }
+
+ public void testGetChildren() {
+ assertEquals(0, inspector.getChildren(bText).length);
+ assertEquals(0, inspector.getChildren(attr).length);
+ assertEquals(0, inspector.getChildren(pi).length);
+ assertEquals(0, inspector.getChildren(comment).length);
+
+ Object[] aChildren = inspector.getChildren(elementA);
+ assertNotNull(aChildren);
+ assertEquals(3, aChildren.length);
+ assertEquals(NodeKind.TEXT, inspector.getNodeKind(aChildren[0]));
+ assertEquals(NodeKind.ELEMENT, inspector.getNodeKind(aChildren[1]));
+ assertEquals(NodeKind.TEXT, inspector.getNodeKind(aChildren[2]));
+
+ Object[] bChildren = inspector.getChildren(elementB);
+ assertNotNull(bChildren);
+ assertEquals(1, bChildren.length);
+ assertEquals(NodeKind.TEXT, inspector.getNodeKind(bChildren[0]));
+
+ Object[] rootChildren = inspector.getChildren(rootElement);
+ assertNotNull(rootChildren);
+ assertEquals(7, rootChildren.length);
+ assertEquals(NodeKind.TEXT, inspector.getNodeKind(rootChildren[0]));
+ assertEquals(NodeKind.COMMENT, inspector.getNodeKind(rootChildren[1]));
+ assertEquals(NodeKind.TEXT, inspector.getNodeKind(rootChildren[2]));
+ assertEquals(NodeKind.ELEMENT, inspector.getNodeKind(rootChildren[3]));
+ assertEquals(NodeKind.TEXT, inspector.getNodeKind(rootChildren[4]));
+ assertEquals(NodeKind.ELEMENT, inspector.getNodeKind(rootChildren[5]));
+ assertEquals(NodeKind.TEXT, inspector.getNodeKind(rootChildren[6]));
+
+ Object[] docChildren = inspector.getChildren(document);
+ assertNotNull(docChildren);
+ assertEquals(2, docChildren.length);
+ assertEquals(NodeKind.PROCESSING_INSTRUCTION, inspector.getNodeKind(docChildren[0]));
+ assertEquals(NodeKind.ELEMENT, inspector.getNodeKind(docChildren[1]));
+ }
+
+ public void testAddElement() {
+ Object[] allChildren = inspector.getChildren(rootElement);
+
+ int childCount = allChildren.length;
+
+ final Object newElement = inspector.addElement(rootElement, new ExpandedName("bob"), null);
+
+ assertNotNull(newElement);
+ assertTrue("instanceof org.w3c.dom.Element", newElement instanceof org.w3c.dom.Element);
+
+ allChildren = inspector.getChildren(rootElement);
+ assertEquals(childCount + 1, allChildren.length);
+ assertEquals(newElement, allChildren[childCount]);
+ }
+
+ public void testRemoveElement() {
+ final Object[] beforeChildren = inspector.getChildren(rootElement);
+
+ inspector.removeElement(elementA);
+
+ final Object[] children = inspector.getChildren(rootElement);
+ assertEquals(beforeChildren.length - 1, children.length);
+
+ for (int i = 0; i < children.length; i++) {
+ assertTrue("elementA not in children", elementA !=children[i]);
+
+ }
+ }
+
+ public void testCopyElement() throws CopyElementException {
+ final Object[] beforeChildren = inspector.getChildren(rootElement);
+
+ final Object newElement = inspector.copyElement(rootElement, elementA, "a", true);
+
+ assertEquals(EXPECTED_A_TEXT, inspector.stringValueOf(newElement));
+
+ final Object[] afterChildren = inspector.getChildren(rootElement);
+ assertEquals(beforeChildren.length + 1, afterChildren.length);
+
+ assertEquals(newElement, afterChildren[afterChildren.length - 1]);
+
+
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java
new file mode 100644
index 0000000..958cf61
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EObjectInspectorTests.java
@@ -0,0 +1,826 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.Resource.Factory;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.xmi.impl.GenericXMLResourceFactoryImpl;
+import org.eclipse.emf.ecore.xml.type.AnyType;
+import org.eclipse.emf.ecore.xml.type.XMLTypeDocumentRoot;
+import org.eclipse.jet.internal.xpath.inspectors.AnyAttributeSetting;
+import org.eclipse.jet.internal.xpath.inspectors.EMFEAttrAsElementWrapper;
+import org.eclipse.jet.internal.xpath.inspectors.EObjectInspector;
+import org.eclipse.jet.xpath.inspector.AddElementException;
+import org.eclipse.jet.xpath.inspector.CopyElementException;
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+import org.eclipse.jet.xpath.inspector.InvalidChildException;
+import org.eclipse.jet.xpath.inspector.INodeInspector.NodeKind;
+
+import dataAccess.Customer;
+import dataAccess.Employee;
+
+public class EObjectInspectorTests extends TestCase {
+
+ protected Resource xsdResource;
+ protected EObject xsdDocumentRoot;
+ protected EObject xsdRootElement;
+
+ protected void xsdSetUp() throws Exception {
+
+ URI fileURI = URI.createURI("platform:/plugin/org.eclipse.jet.tests/data/library.xml");
+ Factory factory = new GenericXMLResourceFactoryImpl();
+
+ xsdResource = factory.createResource(fileURI);
+ xsdResource.load(null);
+
+ xsdDocumentRoot = (EObject) xsdResource.getContents().get(0);
+ xsdRootElement = (EObject) xsdDocumentRoot.eContents().get(0);
+ }
+
+ protected Resource xmlResource;
+ protected XMLTypeDocumentRoot xmlDocumentRoot;
+ protected Resource emfResource;
+ protected EObject emfRoot;
+ protected EObjectInspector inspector;
+ protected AnyType xmlRootElement;
+
+ protected void xmlSetUp() throws Exception {
+
+ URI fileURI = URI.createURI("platform:/plugin/org.eclipse.jet.tests/data/DOMInspector.xml");
+ Factory factory = new GenericXMLResourceFactoryImpl();
+
+ xmlResource = factory.createResource(fileURI);
+ xmlResource.load(null);
+
+ xmlDocumentRoot = (XMLTypeDocumentRoot) xmlResource.getContents().get(0);
+ xmlRootElement = (AnyType) xmlDocumentRoot.getMixed().getValue(0);
+ }
+
+ protected void emfSetUp() throws Exception {
+
+ URI fileURI = URI.createURI("platform:/plugin/org.eclipse.jet.tests/data/sample.dataaccess");
+ Factory factory = Resource.Factory.Registry.INSTANCE.getFactory(fileURI);
+
+ emfResource = factory.createResource(fileURI);
+ emfResource.load(null);
+
+ emfRoot = (EObject) emfResource.getContents().get(0);
+
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ xmlSetUp();
+ emfSetUp();
+ xsdSetUp();
+
+ inspector = new EObjectInspector();
+ }
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getAttributes(Object)'
+ */
+ public void testGetAttributes_emf() {
+ Object[] attributes = inspector.getAttributes(emfRoot);
+
+ assertNotNull(attributes);
+ assertEquals(3, attributes.length);
+ String[] expectedAttributeNames = new String[] {
+ "name", "address", "employeeNumber",
+ };
+ String[] expectedAttributeValues = new String[] {
+ "Bob Smith", "123 Main St", "12345",
+ };
+ for (int i = 0; i < attributes.length; i++) {
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting) attributes[i];
+ assertEquals("name[" + i + "]", expectedAttributeNames[i], setting.getEStructuralFeature().getName());
+ assertEquals("value[" + i + "]", expectedAttributeValues[i], setting.get(true).toString());
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getAttributes(Object)'
+ */
+ public void testGetAttributes_xml() {
+ Object[] attributes = inspector.getAttributes(xmlRootElement);
+
+ assertNotNull(attributes);
+ assertEquals(1, attributes.length);
+ String[] expectedAttributeNames = new String[] {
+ "rootAttr",
+ };
+ String[] expectedAttributeValues = new String[] {
+ "test",
+ };
+ for (int i = 0; i < attributes.length; i++) {
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting) attributes[i];
+ assertEquals("name[" + i + "]", expectedAttributeNames[i], setting.getEStructuralFeature().getName());
+ assertEquals("value[" + i + "]", expectedAttributeValues[i], setting.get(true).toString());
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getAttributes(Object)'
+ */
+ public void testGetAttributes_xsd() {
+ Object[] attributes = inspector.getAttributes(xsdRootElement.eContents().get(0));
+
+ assertNotNull(attributes);
+ assertEquals(1, attributes.length);
+ String[] expectedAttributeNames = new String[] {
+ "name",
+ };
+ String[] expectedAttributeValues = new String[] {
+ "test.beans",
+ };
+ for (int i = 0; i < attributes.length; i++) {
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting) attributes[i];
+ assertEquals("name[" + i + "]", expectedAttributeNames[i], setting.getEStructuralFeature().getName());
+ assertEquals("value[" + i + "]", expectedAttributeValues[i], setting.get(true).toString());
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getAttributes(Object)'
+ */
+ public void testGetAttributes_xsd_simpleElement() {
+ // testing the the <doc> element underneath attributeElement DOES NOT
+ // show up
+ EObject projectElement = (EObject) xsdRootElement.eContents().get(0);
+ EObject beanModelElement = (EObject) projectElement.eContents().get(0);
+ EObject thirdBeanElement = (EObject) beanModelElement.eContents().get(2);
+ EObject attributeElement = (EObject) thirdBeanElement.eContents().get(0);
+ // verify that there is indeed a fourth EAttribute, but that we won't see it.
+ assertEquals(4, attributeElement.eClass().getEAttributes().size());
+ Object[] attributes = inspector.getAttributes(attributeElement);
+
+ assertNotNull(attributes);
+ String[] expectedAttributeNames = new String[] {
+ "kind", "name", "type",
+ };
+ String[] expectedAttributeValues = new String[] {
+ "FIELD", "name", "String",
+ };
+ assertEquals(expectedAttributeNames.length, attributes.length);
+ for (int i = 0; i < attributes.length; i++) {
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting) attributes[i];
+ assertEquals("name[" + i + "]", expectedAttributeNames[i], setting.getEStructuralFeature().getName());
+ assertEquals("value[" + i + "]", expectedAttributeValues[i], setting.get(true).toString());
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNamedAttribute(Object, ExpandedName)'
+ */
+ public void testGetNamedAttribute_emf() {
+ Object attribute = inspector.getNamedAttribute(emfRoot, new ExpandedName("name"));
+
+ assertNotNull(attribute);
+ assertTrue("instanceof EStructuralFeature.Setting", attribute instanceof EStructuralFeature.Setting);
+
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting)attribute;
+ assertEquals("name", setting.getEStructuralFeature().getName());
+ assertEquals("Bob Smith", setting.get(true));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNamedAttribute(Object, ExpandedName)'
+ */
+ public void testGetNamedAttribute_emf_ns() {
+ Object attribute = inspector.getNamedAttribute(emfRoot, new ExpandedName("http:///dataAccess.ecore", "name"));
+
+ assertNotNull(attribute);
+ assertTrue("instanceof EStructuralFeature.Setting", attribute instanceof EStructuralFeature.Setting);
+
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting)attribute;
+ assertEquals("name", setting.getEStructuralFeature().getName());
+ assertEquals("Bob Smith", setting.get(true));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNamedAttribute(Object, ExpandedName)'
+ */
+ public void testGetNamedAttribute_xml() {
+ Object rootAttr = inspector.getNamedAttribute(xmlRootElement, new ExpandedName("rootAttr"));
+ assertNotNull(rootAttr);
+ assertTrue("instanceof EStructuralFeature.Setting", rootAttr instanceof EStructuralFeature.Setting);
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting)rootAttr;
+ assertEquals("rootAttr", setting.getEStructuralFeature().getName());
+ assertEquals("test", setting.get(true));
+
+ Object failAttr = inspector.getNamedAttribute(xmlRootElement, new ExpandedName("fail"));
+ assertNull(failAttr);
+
+ Object elementA1 = xmlRootElement.getAny().getValue(0);
+ Object a1Name = inspector.getNamedAttribute(elementA1, new ExpandedName("name"));
+ assertNotNull(a1Name);
+ assertTrue("instanceof EStructuralFeature.Setting", a1Name instanceof EStructuralFeature.Setting);
+ setting = (EStructuralFeature.Setting)a1Name;
+ assertEquals("name", setting.getEStructuralFeature().getName());
+ assertEquals("foo", setting.get(true));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNamedAttribute(Object, ExpandedName)'
+ */
+ public void testGetNamedAttribute_xsd() {
+ Object projectElement = xsdRootElement.eContents().get(0);
+ Object attribute = inspector.getNamedAttribute(projectElement, new ExpandedName("name"));
+
+ assertNotNull(attribute);
+ assertTrue("instanceof EStructuralFeature.Setting", attribute instanceof EStructuralFeature.Setting);
+
+ EStructuralFeature.Setting setting = (EStructuralFeature.Setting)attribute;
+ assertEquals("name", setting.getEStructuralFeature().getName());
+ assertEquals("test.beans", setting.get(true));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.createAttribute(Object, String, String)'
+ */
+ public void testCreateAttribute_emf() {
+ assertFalse("createAttribute", inspector.createAttribute(emfRoot, "test", "hello"));
+
+ final Object testAttribute = inspector.getNamedAttribute(emfRoot, new ExpandedName("test"));
+ assertNull("testAttribute", testAttribute);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.createAttribute(Object, String, String)'
+ */
+ public void testCreateAttribute_xml() {
+ assertTrue(inspector.createAttribute(xmlRootElement, "test", "hello"));
+
+ Object testAttribute2 = inspector.getNamedAttribute(xmlRootElement, new ExpandedName("test"));
+ assertNotNull(testAttribute2);
+ assertTrue("instanceof AnyAttributeSetting", testAttribute2 instanceof AnyAttributeSetting);
+ assertEquals("hello", ((AnyAttributeSetting)testAttribute2).get(true));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.createAttribute(Object, String, String)'
+ */
+ public void testCreateAttribute_xsd() {
+ assertFalse("createAttribute", inspector.createAttribute(xsdRootElement, "test", "hello"));
+
+ Object testAttribute = inspector.getNamedAttribute(xsdRootElement, new ExpandedName("test"));
+ assertNull(testAttribute);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNodeKind(Object)'
+ */
+ public void testGetNodeKind_emf() {
+ NodeKind result = inspector.getNodeKind(emfRoot);
+ assertEquals(NodeKind.ELEMENT, result);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNodeKind(Object)'
+ */
+ public void testGetNodeKind_xml() {
+ NodeKind result = inspector.getNodeKind(xmlRootElement);
+ assertEquals(NodeKind.ELEMENT, result);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getParent(Object)'
+ */
+ public void testGetParent_emf() {
+ Object result = inspector.getParent(emfRoot);
+ assertEquals(emfResource, result);
+
+ for (Iterator i = emfRoot.eAllContents(); i.hasNext();) {
+ EObject obj = (EObject) i.next();
+ Object parent = inspector.getParent(obj);
+ assertEquals(obj.eContainer(), parent);
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getParent(Object)'
+ */
+ public void testGetParent_xml() {
+ Object result = inspector.getParent(xmlRootElement);
+ assertEquals(xmlDocumentRoot, result);
+
+ for (Iterator i = xmlRootElement.eAllContents(); i.hasNext();) {
+ EObject obj = (EObject) i.next();
+ Object parent = inspector.getParent(obj);
+ assertEquals(obj.eContainer(), parent);
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.stringValueOf(Object)'
+ */
+ public void testStringValueOf_emf() {
+ assertEquals("", inspector.stringValueOf(emfRoot));
+ for (Iterator i = emfRoot.eAllContents(); i.hasNext();) {
+ EObject obj = (EObject) i.next();
+ assertEquals("", inspector.stringValueOf(obj));
+
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.stringValueOf(Object)'
+ */
+ public void testStringValueOf_xml() {
+ assertEquals("\n\t\n\t\n\t\tSome foo text.\n\t\n\t\n\t\tSome bar text.\n\t\n", inspector.stringValueOf(xmlDocumentRoot));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.stringValueOf(Object)'
+ */
+ public void testStringValueOf_xsd() {
+ assertEquals("doc for Author.name", inspector.stringValueOf(xsdDocumentRoot));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.expandedNameOf(Object)'
+ */
+ public void testExpandedNameOf_emf() {
+ ExpandedName enEmfRoot = inspector.expandedNameOf(emfRoot);
+ assertEquals("contents", enEmfRoot.toString());
+
+ ExpandedName enCustomer = inspector.expandedNameOf(((Employee)emfRoot).getCustomers().get(0));
+ assertEquals("customers", enCustomer.toString());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.expandedNameOf(Object)'
+ */
+ public void testExpandedNameOf_xml() {
+ ExpandedName enEmfRoot = inspector.expandedNameOf(xmlRootElement);
+ assertEquals("root", enEmfRoot.toString());
+
+ ExpandedName enCustomer = inspector.expandedNameOf(xmlRootElement.getAny().getValue(0));
+ assertEquals("a", enCustomer.toString());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.expandedNameOf(Object)'
+ */
+ public void testExpandedNameOf_xsd() {
+ ExpandedName enEmfRoot = inspector.expandedNameOf(xsdRootElement);
+ assertEquals("http://www.example.org/beans:root", enEmfRoot.toString());
+
+ ExpandedName enProject = inspector.expandedNameOf(xsdRootElement.eContents().get(0));
+ assertEquals("project", enProject.toString());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getDocumentRoot(Object)'
+ */
+ public void testGetDocumentRoot_emf() {
+ assertEquals(emfResource, inspector.getDocumentRoot(emfRoot));
+
+ assertEquals(emfResource, inspector.getDocumentRoot(((Employee)emfRoot).getCustomers().get(0)));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getDocumentRoot(Object)'
+ */
+ public void testGetDocumentRoot_xml() {
+ assertEquals(xmlDocumentRoot, inspector.getDocumentRoot(xmlRootElement));
+
+ assertEquals(xmlDocumentRoot, inspector.getDocumentRoot(xmlRootElement.getAny().getValue(0)));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getDocumentRoot(Object)'
+ */
+ public void testGetDocumentRoot_xsd() {
+ assertEquals(xsdDocumentRoot, inspector.getDocumentRoot(xsdDocumentRoot));
+
+ assertEquals(xsdDocumentRoot, inspector.getDocumentRoot(xsdRootElement.eContents().get(0)));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getChildren(Object)'
+ */
+ public void testGetChildren_emf() {
+ Object[] children = inspector.getChildren(emfRoot);
+ assertEquals(2, children.length);
+ for (int i = 0; i < children.length; i++) {
+ EObject child = (EObject) children[i];
+ assertEquals("Customer", child.eClass().getName());
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getChildren(Object)'
+ */
+ public void testGetChildren_xml() {
+ Object[] rootChildren = inspector.getChildren(xmlRootElement);
+ assertNotNull(rootChildren);
+
+ String[] expectedClass = new String[] {
+ "EMFXMLNodeWrapper",
+ "EMFXMLNodeWrapper",
+ "EMFXMLNodeWrapper",
+ "AnyTypeImpl",
+ "EMFXMLNodeWrapper",
+ "AnyTypeImpl",
+ "EMFXMLNodeWrapper",
+
+ };
+ assertEquals(expectedClass.length, rootChildren.length);
+ for (int i = 0; i < rootChildren.length; i++) {
+ String className = rootChildren[i].getClass().getName();
+ assertEquals(expectedClass[i], className.substring(className.lastIndexOf('.')+1));
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getChildren(Object)'
+ */
+ public void testGetChildren_xsd() {
+ final Object[] rootChildren = inspector.getChildren(xsdRootElement);
+ String expectedNames[] = new String[] { "Project" };
+ assertEquals(expectedNames.length, rootChildren.length);
+ for (int i = 0; i < expectedNames.length; i++) {
+ assertEquals(expectedNames[i], ((EObject)rootChildren[i]).eClass().getName());
+ }
+ Object beanModel = inspector.getChildren(rootChildren[0])[0];
+ assertEquals("BeanModel", ((EObject)beanModel).eClass().getName());
+
+ Object thirdBean = inspector.getChildren(beanModel)[2];
+ assertEquals("Bean", ((EObject)thirdBean).eClass().getName());
+
+ Object[] beanAttributes = inspector.getChildren(thirdBean);
+ expectedNames = new String[] { "Attribute", "Attribute", };
+ for (int i = 0; i < expectedNames.length; i++) {
+ assertEquals(expectedNames[i], ((EObject)beanAttributes[i]).eClass().getName());
+ }
+
+ Object[] doc = inspector.getChildren(beanAttributes[0]);
+ assertEquals(1, doc.length);
+ assertTrue("instanceof EMFEAttrAsElementWrapper", doc[0] instanceof EMFEAttrAsElementWrapper);
+ EMFEAttrAsElementWrapper wrapper = (EMFEAttrAsElementWrapper) doc[0];
+ assertEquals("doc for Author.name", wrapper.getSetting().get(true));
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.nameOf(Object)'
+ */
+ public void testNameOf_emf() {
+ assertEquals("contents", inspector.nameOf(emfRoot));
+ for (Iterator i = emfRoot.eAllContents(); i.hasNext();) {
+ EObject obj = (EObject) i.next();
+ String result = inspector.nameOf(obj);
+ assertEquals("dataAccess:" + obj.eContainingFeature().getName(), result);
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.nameOf(Object)'
+ */
+ public void testNameOf_xml() {
+ assertEquals("root", inspector.nameOf(xmlRootElement));
+ for (Iterator i = xmlRootElement.getAny().iterator(); i.hasNext();) {
+ FeatureMap.Entry obj = (FeatureMap.Entry) i.next();
+ String result = inspector.nameOf(obj.getValue());
+ assertEquals(obj.getEStructuralFeature().getName(), result);
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.nameOf(Object)'
+ */
+ public void testNameOf_xsd() {
+ assertEquals("beans:root", inspector.nameOf(xsdRootElement));
+ for (Iterator i = xsdRootElement.eAllContents(); i.hasNext();) {
+ EObject obj = (EObject) i.next();
+ String result = inspector.nameOf(obj);
+ assertEquals(obj.eContainingFeature().getName(), result);
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNamedChildren(Object, ExpandedName)'
+ */
+ public void testGetNamedChildren_emf() {
+ Object[] namedChildren = inspector.getNamedChildren(emfRoot, new ExpandedName("customers"));
+ assertEquals(2, namedChildren.length);
+ for (int i = 0; i < namedChildren.length; i++) {
+ EObject child = (EObject) namedChildren[i];
+ assertEquals("Customer", child.eClass().getName());
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNamedChildren(Object, ExpandedName)'
+ */
+ public void testGetNamedChildren_emf_eClassName() {
+ Object[] namedChildren = inspector.getNamedChildren(emfRoot, new ExpandedName("Customer"));
+ assertEquals(2, namedChildren.length);
+ for (int i = 0; i < namedChildren.length; i++) {
+ EObject child = (EObject) namedChildren[i];
+ assertEquals("Customer", child.eClass().getName());
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNamedChildren(Object, ExpandedName)'
+ */
+ public void testGetNamedChildren_xml() {
+ Object[] namedChildren = inspector.getNamedChildren(xmlRootElement, new ExpandedName("a"));
+ assertEquals(2, namedChildren.length);
+ for (int i = 0; i < namedChildren.length; i++) {
+ EObject child = (EObject) namedChildren[i];
+ assertEquals("org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl", child.getClass().getName());
+ }
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.inspectors.EObjectInspector2.getNamedChildren(Object, ExpandedName)'
+ */
+ public void testGetNamedChildren_xsd() {
+ Object[] rootChildren = inspector.getNamedChildren(xsdDocumentRoot, new ExpandedName("http://www.example.org/beans", "root"));
+ assertEquals(1, rootChildren.length);
+ assertEquals(xsdRootElement, rootChildren[0]);
+
+ Object[] namedChildren = inspector.getNamedChildren(xsdRootElement, new ExpandedName("project"));
+ assertEquals(1, namedChildren.length);
+ for (int i = 0; i < namedChildren.length; i++) {
+ EObject child = (EObject) namedChildren[i];
+ assertEquals("Project", ((EObject)child).eClass().getName());
+ }
+ namedChildren = inspector.getNamedChildren(namedChildren[0], new ExpandedName("beanModel"));
+ assertEquals(1, namedChildren.length);
+ for (int i = 0; i < namedChildren.length; i++) {
+ EObject child = (EObject) namedChildren[i];
+ assertEquals("BeanModel", ((EObject)child).eClass().getName());
+ }
+ namedChildren = inspector.getNamedChildren(namedChildren[0], new ExpandedName("bean"));
+ assertEquals(3, namedChildren.length);
+ for (int i = 0; i < namedChildren.length; i++) {
+ EObject child = (EObject) namedChildren[i];
+ assertEquals("Bean", ((EObject)child).eClass().getName());
+ }
+ namedChildren = inspector.getNamedChildren(namedChildren[2], new ExpandedName("attribute"));
+ assertEquals(2, namedChildren.length);
+ for (int i = 0; i < namedChildren.length; i++) {
+ EObject child = (EObject) namedChildren[i];
+ assertEquals("Attribute", ((EObject)child).eClass().getName());
+ }
+ namedChildren = inspector.getNamedChildren(namedChildren[0], new ExpandedName("doc"));
+ assertEquals(1, namedChildren.length);
+ for (int i = 0; i < namedChildren.length; i++) {
+ EMFEAttrAsElementWrapper child = (EMFEAttrAsElementWrapper) namedChildren[i];
+ assertEquals("doc for Author.name", child.getSetting().get(true));
+ }
+ }
+
+ public void testAddElement_emf() throws Exception {
+ Object[] namedChildren = inspector.getNamedChildren(emfRoot, new ExpandedName("customers"));
+ int childCount = namedChildren.length;
+
+ final Object newElement = inspector.addElement(emfRoot, new ExpandedName("customers"), null);
+
+ assertNotNull(newElement);
+ assertEquals("dataAccess.impl.CustomerImpl", newElement.getClass().getName());
+
+ namedChildren = inspector.getNamedChildren(emfRoot, new ExpandedName("customers"));
+ assertEquals(childCount + 1, namedChildren.length);
+ assertEquals(newElement, namedChildren[childCount]);
+ }
+
+ public void testAddElement_emf_before() throws Exception {
+ Object[] namedChildren = inspector.getNamedChildren(emfRoot, new ExpandedName("customers"));
+ int childCount = namedChildren.length;
+
+ final Object newElement = inspector.addElement(emfRoot, new ExpandedName("customers"), namedChildren[0]);
+
+ assertNotNull(newElement);
+ assertEquals("dataAccess.impl.CustomerImpl", newElement.getClass().getName());
+
+ namedChildren = inspector.getNamedChildren(emfRoot, new ExpandedName("customers"));
+ assertEquals(childCount + 1, namedChildren.length);
+ assertEquals(newElement, namedChildren[0]);
+ }
+
+ public void testAddElement_xml() throws Exception {
+ Object[] allChildren = inspector.getChildren(xmlRootElement);
+
+ int childCount = allChildren.length;
+
+ final Object newElement = inspector.addElement(xmlRootElement, new ExpandedName("bob"), null);
+
+ assertNotNull(newElement);
+ assertEquals("org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl", newElement.getClass().getName());
+
+ allChildren = inspector.getChildren(xmlRootElement);
+ assertEquals(childCount + 1, allChildren.length);
+ assertEquals(newElement, allChildren[childCount]);
+ }
+
+ public void testAddElement_xml_before() throws Exception {
+ Object fildChild = xmlRootElement.getAny().getValue(0);
+ int childCount = xmlRootElement.getAny().size();
+
+ final Object newElement = inspector.addElement(xmlRootElement, new ExpandedName("a"), fildChild);
+
+ assertNotNull(newElement);
+ assertEquals("org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl", newElement.getClass().getName());
+
+ assertEquals(childCount + 1, xmlRootElement.getAny().size());
+ assertEquals(newElement, xmlRootElement.getAny().getValue(0));
+ }
+
+ public void testAddElement_xml_before_fail() throws Exception {
+ Object[] allChildren = inspector.getChildren(xmlRootElement);
+ try {
+ inspector.addElement(xmlRootElement, new ExpandedName("bob"), allChildren[0]);
+ fail();
+ } catch(InvalidChildException e) {
+ // success
+ }
+
+ }
+
+ public void testAddElement_xsd() throws Exception {
+ int childCount = xsdRootElement.eContents().size();
+ final Object newElement = inspector.addElement(xsdRootElement, new ExpandedName("project"), null);
+ assertEquals(childCount + 1, xsdRootElement.eContents().size());
+
+ assertEquals(newElement, xsdRootElement.eContents().get(childCount));
+ }
+
+ public void testAddElement_xsd_before() throws Exception {
+ int childCount = xsdRootElement.eContents().size();
+ final Object newElement = inspector.addElement(xsdRootElement, new ExpandedName("project"), xsdRootElement.eContents().get(0));
+ assertEquals(childCount + 1, xsdRootElement.eContents().size());
+
+ assertEquals(newElement, xsdRootElement.eContents().get(0));
+ }
+
+ public void testRemoveElement_emf() {
+ Employee emp = (Employee) emfRoot;
+ int beforeListSize = emp.getCustomers().size();
+
+ Customer cust = (Customer) emp.getCustomers().get(0);
+ inspector.removeElement(cust);
+ List afterList = emp.getCustomers();
+ assertEquals(beforeListSize - 1, afterList.size());
+ assertTrue("cust not in afterList", !afterList.contains(cust));
+ }
+
+ public void testRemoveElement_emf_root() {
+ Employee emp = (Employee) emfRoot;
+ int beforeListSize = emfResource.getContents().size();
+
+ inspector.removeElement(emp);
+ List afterList = emfResource.getContents();
+ assertEquals(beforeListSize - 1, afterList.size());
+ assertTrue("cust not in afterList", !afterList.contains(emp));
+ }
+
+ public void testRemoveElement_xml() {
+ EStructuralFeature feature = xmlRootElement.getAny().getEStructuralFeature(0);
+ Object elementA = xmlRootElement.getAny().getValue(0);
+ int beforeSize = xmlRootElement.getAny().list(feature).size();
+
+ inspector.removeElement(elementA);
+
+ assertEquals(beforeSize - 1, xmlRootElement.getAny().list(feature).size());
+ assertTrue("elementA not in list", !xmlRootElement.getAny().list(feature).contains(elementA));
+
+ }
+
+ public void testRemoveElement_xsd() {
+ final Object[] rootChildren = inspector.getChildren(xsdRootElement);
+ Object beanModel = inspector.getChildren(rootChildren[0])[0];
+ assertEquals("BeanModel", ((EObject)beanModel).eClass().getName());
+
+ Object thirdBean = inspector.getChildren(beanModel)[2];
+ assertEquals("Bean", ((EObject)thirdBean).eClass().getName());
+
+// Object[] beanAttributes = inspector.getChildren(thirdBean);
+// final Object beanAttr = beanAttributes[0];
+// Object[] doc = inspector.getChildren(beanAttr);
+// assertEquals(1, doc.length);
+//
+// inspector.removeElement(doc[0]);
+// assertEquals(0, inspector.getChildren(beanAttr).length);
+
+ inspector.removeElement(thirdBean);
+ assertEquals(2, inspector.getChildren(beanModel).length);
+ }
+
+ public void testCopyElement_emf() throws CopyElementException {
+ Customer source = (Customer) ((Employee)emfRoot).getCustomers().get(0);
+ int initialSize = ((Employee)emfRoot).getCustomers().size();
+ Customer newCust = (Customer) inspector.copyElement(emfRoot, source, "customers", true);
+ assertEquals(initialSize + 1, ((Employee)emfRoot).getCustomers().size() );
+ assertTrue("newCust != source", source != newCust);
+ assertEquals(newCust, ((Employee)emfRoot).getCustomers().get(initialSize));
+ assertEquals(inspector.getChildren(source).length, inspector.getChildren(newCust).length);
+ }
+
+ public void testCopyElement_emf_shallow() throws CopyElementException {
+ Customer source = (Customer) ((Employee)emfRoot).getCustomers().get(0);
+ int initialSize = ((Employee)emfRoot).getCustomers().size();
+ Customer newCust = (Customer) inspector.copyElement(emfRoot, source, "customers", false);
+ assertEquals(initialSize + 1, ((Employee)emfRoot).getCustomers().size() );
+ assertTrue("newCust != source", source != newCust);
+ assertEquals(newCust, ((Employee)emfRoot).getCustomers().get(initialSize));
+ assertEquals(0, inspector.getChildren(newCust).length);
+ assertEquals(source.getName(), newCust.getName());
+ }
+
+ public void testCopyElement_xml() throws CopyElementException {
+ AnyType elementA = (AnyType) xmlRootElement.getAny().getValue(0);
+ int initialSize = xmlRootElement.getAny().size();
+ final Object elementACopy = inspector.copyElement(xmlRootElement, elementA, "a", true);
+ assertNotNull(elementACopy);
+ assertTrue("copy != original", elementA != elementACopy);
+ assertEquals(inspector.stringValueOf(elementA), inspector.stringValueOf(elementACopy));
+ assertEquals(initialSize + 1, xmlRootElement.getAny().size());
+ assertEquals(elementACopy ,xmlRootElement.getAny().getValue(initialSize));
+
+ }
+
+ public void testCopyElement_xml_shallow() throws CopyElementException {
+ AnyType elementA = (AnyType) xmlRootElement.getAny().getValue(0);
+ int initialSize = xmlRootElement.getAny().size();
+ final Object elementACopy = inspector.copyElement(xmlRootElement, elementA, "a", false);
+ assertNotNull(elementACopy);
+ assertTrue("copy != original", elementA != elementACopy);
+ assertEquals(initialSize + 1, xmlRootElement.getAny().size());
+ assertEquals(elementACopy ,xmlRootElement.getAny().getValue(initialSize));
+ assertEquals(0, inspector.getChildren(elementACopy).length);
+ }
+
+ public void testCopyElement_xsd() throws CopyElementException {
+ final Object[] projects = inspector.getNamedChildren(xsdRootElement,new ExpandedName("project"));
+ Object projectElement = projects[0];
+
+ final Object newProject = inspector.copyElement(xsdRootElement, projectElement, "project", true);
+
+ final Object[] newProjects = inspector.getNamedChildren(xsdRootElement,new ExpandedName("project"));
+ assertEquals(projects.length + 1, newProjects.length);
+ assertEquals(newProject, newProjects[newProjects.length - 1]);
+ assertEquals(inspector.stringValueOf(projectElement), inspector.stringValueOf(newProject));
+
+ }
+
+ public void testCopyElement_xsd_shallow() throws CopyElementException {
+ final Object[] projects = inspector.getNamedChildren(xsdRootElement,new ExpandedName("project"));
+ Object projectElement = projects[0];
+
+ final Object newProject = inspector.copyElement(xsdRootElement, projectElement, "project", false);
+
+ final Object[] newProjects = inspector.getNamedChildren(xsdRootElement,new ExpandedName("project"));
+ assertEquals(projects.length + 1, newProjects.length);
+ assertEquals(newProject, newProjects[newProjects.length - 1]);
+ assertEquals(0, inspector.getChildren(newProject).length);
+
+ }
+
+ public void testAddTextElement_emf() {
+ // nothing to test. Basic EMF models have nothing equivalent to "Text Elements".
+ }
+
+ public void testAddTextElement_xsd() throws Exception {
+ final Object[] rootChildren = inspector.getChildren(xsdRootElement);
+ Object beanModel = inspector.getChildren(rootChildren[0])[0];
+ Object firstBean = inspector.getChildren(beanModel)[0];
+ assertEquals("Bean", ((EObject)firstBean).eClass().getName());
+
+ Object[] beanAttributes = inspector.getChildren(firstBean);
+
+ inspector.addTextElement(beanAttributes[0], "doc", "Hello Attribute 1", false );
+
+ Object[] doc = inspector.getChildren(beanAttributes[0]);
+ assertEquals(1, doc.length);
+ assertTrue("instanceof EMFEAttrAsElementWrapper", doc[0] instanceof EMFEAttrAsElementWrapper);
+ EMFEAttrAsElementWrapper wrapper = (EMFEAttrAsElementWrapper) doc[0];
+ assertEquals("Hello Attribute 1", wrapper.getSetting().get(true));
+ }
+
+ public void testAddTextElement_xml() throws AddElementException {
+ inspector.addTextElement(xmlRootElement, "bob", "Hello Bob!", false);
+
+ final Object[] namedChildren = inspector.getNamedChildren(xmlRootElement, new ExpandedName("bob"));
+ assertEquals(1, namedChildren.length);
+ assertEquals("Hello Bob!", inspector.stringValueOf(namedChildren[0]));
+ }
+
+ public void testAddTextElement_xml_cdata() throws AddElementException {
+ inspector.addTextElement(xmlRootElement, "bob", "Hello Bob!", true);
+
+ final Object[] namedChildren = inspector.getNamedChildren(xmlRootElement, new ExpandedName("bob"));
+ assertEquals(1, namedChildren.length);
+ assertEquals("Hello Bob!", inspector.stringValueOf(namedChildren[0]));
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EStructuralFeatureSettingTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EStructuralFeatureSettingTests.java
new file mode 100644
index 0000000..47bc12f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/EStructuralFeatureSettingTests.java
@@ -0,0 +1,113 @@
+package org.eclipse.jet.tests.xpath;
+
+import junit.framework.TestCase;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EStructuralFeature.Setting;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.Resource.Factory;
+import org.eclipse.jet.internal.xpath.inspectors.EObjectInspector;
+import org.eclipse.jet.internal.xpath.inspectors.EStructuralFeatureSettingInspector;
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+import org.eclipse.jet.xpath.inspector.INodeInspector.NodeKind;
+
+public class EStructuralFeatureSettingTests extends TestCase {
+
+ protected Resource resource;
+ protected EObject root;
+ protected EStructuralFeature.Setting root_name_attr;
+ protected EObjectInspector eObjectInspector;
+ protected EStructuralFeatureSettingInspector inspector;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ URI fileURI = URI.createURI("platform:/plugin/org.eclipse.jet.tests/data/sample.dataaccess");
+ Factory factory = Resource.Factory.Registry.INSTANCE.getFactory(fileURI);
+
+ resource = factory.createResource(fileURI);
+ resource.load(null);
+
+ root = (EObject) resource.getContents().get(0);
+
+ inspector = new EStructuralFeatureSettingInspector();
+ eObjectInspector = new EObjectInspector();
+
+ root_name_attr = (Setting) eObjectInspector.getNamedAttribute(root, new ExpandedName("name"));
+
+ }
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.EStructuralFeatureSettingInspector.getNodeKind(Object)'
+ */
+ public void testGetNodeKind() {
+ NodeKind nodeKind = inspector.getNodeKind(root_name_attr);
+ assertEquals(NodeKind.ATTRIBUTE, nodeKind);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.EStructuralFeatureSettingInspector.getParent(Object)'
+ */
+ public void testGetParent() {
+ Object parent = inspector.getParent(root_name_attr);
+ assertEquals(root, parent);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.EStructuralFeatureSettingInspector.stringValueOf(Object)'
+ */
+ public void testStringValueOf() {
+ String value = inspector.stringValueOf(root_name_attr);
+ assertEquals("Bob Smith", value);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.EStructuralFeatureSettingInspector.expandedNameOf(Object)'
+ */
+ public void testExpandedNameOf() {
+ ExpandedName expandedName = inspector.expandedNameOf(root_name_attr);
+ assertEquals("http:///dataAccess.ecore:name", expandedName.toString());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.EStructuralFeatureSettingInspector.getAttributes(Object)'
+ */
+ public void testGetAttributes() {
+ Object[] attributes = inspector.getAttributes(root_name_attr);
+ assertNull(attributes);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.EStructuralFeatureSettingInspector.getNamedAttribute(Object, ExpandedName)'
+ */
+ public void testGetNamedAttribute() {
+ Object namedAttribute = inspector.getNamedAttribute(root_name_attr, new ExpandedName("foo"));
+ assertNull(namedAttribute);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.EStructuralFeatureSettingInspector.getDocumentRoot(Object)'
+ */
+ public void testGetDocumentRoot() {
+ Object documentRoot = inspector.getDocumentRoot(root_name_attr);
+ assertEquals(resource, documentRoot);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.EStructuralFeatureSettingInspector.getChildren(Object)'
+ */
+ public void testGetChildren() {
+ Object[] children = inspector.getChildren(root_name_attr);
+ assertNull(children);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.EStructuralFeatureSettingInspector.nameOf(Object)'
+ */
+ public void testNameOf() {
+ String nameOf = inspector.nameOf(root_name_attr);
+ assertEquals("name", nameOf);
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ExpandedNameTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ExpandedNameTests.java
new file mode 100644
index 0000000..497de86
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ExpandedNameTests.java
@@ -0,0 +1,88 @@
+package org.eclipse.jet.tests.xpath;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+
+public class ExpandedNameTests extends TestCase {
+
+ /*
+ * Test method for 'org.eclipse.jet.xpath.ExpandedName.ExpandedName(String)'
+ */
+ public void testExpandedNameString() {
+ ExpandedName en = new ExpandedName("foo");
+
+ assertNull(en.getNamespaceURI());
+ assertEquals("foo", en.getLocalPart());
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.xpath.ExpandedName.ExpandedName(String, String)'
+ */
+ public void testExpandedNameStringString() {
+ ExpandedName en = new ExpandedName("foo", "bar");
+
+ assertEquals("foo", en.getNamespaceURI());
+ assertEquals("bar", en.getLocalPart());
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.xpath.ExpandedName.equals(Object)'
+ */
+ public void testEquals_ncname_ncname() {
+ ExpandedName enFoo1 = new ExpandedName("foo");
+ ExpandedName enFoo2 = new ExpandedName("foo");
+ ExpandedName enBar = new ExpandedName("bar");
+ ExpandedName enBarFoo = new ExpandedName("bar", "foo");
+
+ assertTrue("self equality", enFoo1.equals(enFoo1));
+ assertTrue("equality", enFoo1.equals(enFoo2));
+ assertTrue("reflexive equality", enFoo2.equals(enFoo1));
+ assertFalse("inequality", enFoo1.equals(enBar));
+ assertFalse("reflexive inequality", enBar.equals(enFoo1));
+ assertFalse("inequality qname", enFoo1.equals(enBarFoo));
+ assertFalse("reflexive inequality qname", enBarFoo.equals(enFoo1) );
+
+ }
+
+ public void testEquals_qname_qname() {
+ ExpandedName enFooBar1 = new ExpandedName("foo", "bar");
+ ExpandedName enFooBar2 = new ExpandedName("foo", "bar");
+ ExpandedName enFooBad = new ExpandedName("foo", "bad");
+ ExpandedName enFarBar = new ExpandedName("far", "bar");
+
+ assertTrue("self equality", enFooBar1.equals(enFooBar1));
+ assertTrue("equality", enFooBar1.equals(enFooBar2));
+ assertTrue("reflexive equality", enFooBar2.equals(enFooBar1));
+ assertFalse("inequality in localname", enFooBar1.equals(enFooBad));
+ assertFalse("inequality in uri", enFooBar1.equals(enFarBar));
+ assertFalse("total inequality", enFooBad.equals(enFarBar));
+ }
+
+ public void testEquals_wild() {
+ ExpandedName enWild = new ExpandedName("*");
+
+ ExpandedName enFoo = new ExpandedName("foo");
+ ExpandedName enFooBar = new ExpandedName("foo", "bar");
+
+ assertTrue("equality ncname", enWild.equals(enFoo));
+ assertTrue("reflexive equality ncname", enFoo.equals(enWild));
+ assertTrue("equality qname", enWild.equals(enFooBar));
+ assertTrue("reflexivie equality qname", enFooBar.equals(enWild));
+ }
+
+ public void testEquals_localpart_wild() {
+ ExpandedName enFooWild = new ExpandedName("foo", "*");
+
+ ExpandedName enFoo = new ExpandedName("foo");
+ ExpandedName enFooBar = new ExpandedName("foo", "bar");
+ ExpandedName enFarBar = new ExpandedName("far", "bar");
+
+ assertTrue("equality", enFooWild.equals(enFooBar));
+ assertTrue("reflexive equality", enFooBar.equals(enFooWild));
+ assertFalse("inequality", enFooWild.equals(enFarBar));
+ assertFalse("reflexive inequality", enFarBar.equals(enFooWild));
+ assertFalse("inequality", enFooWild.equals(enFoo));
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/LogicalOpTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/LogicalOpTests.java
new file mode 100644
index 0000000..b20c626
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/LogicalOpTests.java
@@ -0,0 +1,54 @@
+package org.eclipse.jet.tests.xpath;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.xpath.ast.BooleanExpr;
+import org.eclipse.jet.internal.xpath.ast.BooleanLiteral;
+import org.eclipse.jet.internal.xpath.ast.LogicalOp;
+
+public class LogicalOpTests extends TestCase {
+
+ public void testOr() {
+ BooleanExpr expr = new LogicalOp.Or(BooleanLiteral.FALSE, BooleanLiteral.FALSE);
+
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new LogicalOp.Or(BooleanLiteral.TRUE, BooleanLiteral.FALSE);
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new LogicalOp.Or(BooleanLiteral.FALSE, BooleanLiteral.TRUE);
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new LogicalOp.Or(BooleanLiteral.TRUE, BooleanLiteral.TRUE);
+ assertTrue(expr.evalAsBoolean(null));
+
+ // test that if the first term is true, then the second term is not evaluated.
+ expr = new LogicalOp.Or(BooleanLiteral.TRUE, null);
+ assertTrue(expr.evalAsBoolean(null));
+
+
+ }
+
+ public void testAnd() {
+ BooleanExpr expr = new LogicalOp.And(BooleanLiteral.FALSE, BooleanLiteral.FALSE);
+
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new LogicalOp.And(BooleanLiteral.TRUE, BooleanLiteral.FALSE);
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new LogicalOp.And(BooleanLiteral.FALSE, BooleanLiteral.TRUE);
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new LogicalOp.And(BooleanLiteral.TRUE, BooleanLiteral.TRUE);
+ assertTrue(expr.evalAsBoolean(null));
+
+ // test that if the first term is false, then the second term is not evaluated.
+ expr = new LogicalOp.And(BooleanLiteral.FALSE, null);
+ assertFalse(expr.evalAsBoolean(null));
+
+
+ }
+
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/NumberBinaryOpTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/NumberBinaryOpTests.java
new file mode 100644
index 0000000..675b12b
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/NumberBinaryOpTests.java
@@ -0,0 +1,63 @@
+package org.eclipse.jet.tests.xpath;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.xpath.ast.BinaryOp;
+import org.eclipse.jet.internal.xpath.ast.NumberExpr;
+import org.eclipse.jet.internal.xpath.ast.NumberLiteral;
+
+public class NumberBinaryOpTests extends TestCase {
+
+ public void testAdd() {
+ NumberExpr expr = new BinaryOp.Add(new NumberLiteral(3), new NumberLiteral(5));
+ double addResult = expr.evalAsDouble(null);
+
+ assertEquals(8, addResult, 0);
+
+ }
+
+ public void testSubtract() {
+ NumberExpr expr = new BinaryOp.Subtract(new NumberLiteral(3), new NumberLiteral(5));
+ double subtractResult = expr.evalAsDouble(null);
+
+ assertEquals(-2, subtractResult, 0);
+ }
+
+ public void testMultiply() {
+ NumberExpr expr = new BinaryOp.Multiply(new NumberLiteral(3), new NumberLiteral(5));
+ double multiplyResult = expr.evalAsDouble(null);
+
+ assertEquals(15, multiplyResult, 0);
+
+ }
+
+ public void testDiv() {
+ NumberExpr expr = new BinaryOp.Div(new NumberLiteral(3), new NumberLiteral(5));
+ double multiplyResult = expr.evalAsDouble(null);
+
+ assertEquals(0.6, multiplyResult, 0);
+
+ }
+
+ public void testMod() {
+ NumberExpr expr1 = new BinaryOp.Mod(new NumberLiteral(5), new NumberLiteral(2));
+ double result1 = expr1.evalAsDouble(null);
+
+ assertEquals(1, result1, 0);
+
+ NumberExpr expr2 = new BinaryOp.Mod(new NumberLiteral(5), new NumberLiteral(-2));
+ double result2 = expr2.evalAsDouble(null);
+
+ assertEquals(1, result2, 0);
+
+ NumberExpr expr3 = new BinaryOp.Mod(new NumberLiteral(-5), new NumberLiteral(2));
+ double result3 = expr3.evalAsDouble(null);
+
+ assertEquals(-1, result3, 0);
+
+ NumberExpr expr4 = new BinaryOp.Mod(new NumberLiteral(-5), new NumberLiteral(-2));
+ double result4 = expr4.evalAsDouble(null);
+
+ assertEquals(-1, result4, 0);
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/NumberFunctionTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/NumberFunctionTests.java
new file mode 100644
index 0000000..1457f60
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/NumberFunctionTests.java
@@ -0,0 +1,39 @@
+package org.eclipse.jet.tests.xpath;
+
+import org.eclipse.jet.internal.xpath.functions.NumberFunction;
+
+
+public class NumberFunctionTests extends AbstractExprTest {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.functions.NumberFunction.evaluate(Object)'
+ */
+ public void testEvaluateObject_String() {
+
+ double result = NumberFunction.evaluate("1.0");
+ assertEquals(1d, result, 0d);
+ }
+
+ public void testEvaluateObject_String_NaN() {
+
+ double result = NumberFunction.evaluate("foo");
+ assertTrue(Double.isNaN(result));
+ }
+
+ public void testEvaluateObject_Boolean_true() {
+ double result = NumberFunction.evaluate(Boolean.valueOf(true));
+ assertEquals(1d, result, 0d);
+ }
+
+ public void testEvaluateObject_Boolean_false() {
+ double result = NumberFunction.evaluate(Boolean.valueOf(false));
+ assertEquals(0d, result, 0d);
+ }
+
+ public void testEvaluateObject_Number() {
+ double input = 1 / 3;
+
+ double result = NumberFunction.evaluate(new Double(input));
+ assertEquals(input, result, 0d);
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ParentStepTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ParentStepTests.java
new file mode 100644
index 0000000..cecaf4f
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ParentStepTests.java
@@ -0,0 +1,84 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Set;
+
+import org.eclipse.jet.internal.xpath.ast.Axis;
+import org.eclipse.jet.internal.xpath.ast.ContextNode;
+import org.eclipse.jet.internal.xpath.ast.NodeTest;
+import org.eclipse.jet.internal.xpath.ast.Step;
+import org.eclipse.jet.xpath.Context;
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+
+public class ParentStepTests extends AbstractExprTest {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ast.Step.evalAsNodeSet(Context, INodeInspector)'
+ */
+ public void testEvalAsNodeSet_a() {
+ Step stepExpr = new Step(
+ new ContextNode(),
+ Axis.parentAxis(),
+ NodeTest.nameTest(Axis.parentAxis().principalNodeKind(), new ExpandedName("*"))
+ );
+
+ Context context = new Context(elementA, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(rootElement));
+ }
+
+ public void testEvalAsNodeSet_b() {
+ Step stepExpr = new Step(
+ new ContextNode(),
+ Axis.parentAxis(),
+ NodeTest.nameTest(Axis.parentAxis().principalNodeKind(), new ExpandedName("*"))
+ );
+
+ Context context = new Context(elementB, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(elementA));
+ }
+
+ public void testEvalAsNodeSet_root() {
+ Step stepExpr = new Step(
+ new ContextNode(),
+ Axis.parentAxis(),
+ NodeTest.nameTest(Axis.parentAxis().principalNodeKind(), new ExpandedName("*"))
+ );
+
+ Context context = new Context(rootElement, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(0, resultSet.size());
+// assertTrue(resultSet.contains(elementA));
+ }
+
+ public void testEvalAsNodeSet_a_b() {
+ Step stepExpr = new Step(
+ new Step(new ContextNode(),
+ Axis.childAxis(),
+ NodeTest.nameTest(Axis.childAxis().principalNodeKind(), new ExpandedName("b"))
+ ),
+ Axis.parentAxis(),
+ NodeTest.nameTest(Axis.parentAxis().principalNodeKind(), new ExpandedName("*"))
+ );
+
+ Context context = new Context(elementA, null);
+
+ Set resultSet = stepExpr.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(elementA));
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/RelOpTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/RelOpTests.java
new file mode 100644
index 0000000..d4761af
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/RelOpTests.java
@@ -0,0 +1,156 @@
+package org.eclipse.jet.tests.xpath;
+
+import org.eclipse.jet.internal.xpath.NodeSetImpl;
+import org.eclipse.jet.internal.xpath.ast.BooleanExpr;
+import org.eclipse.jet.internal.xpath.ast.BooleanLiteral;
+import org.eclipse.jet.internal.xpath.ast.NodeSetLiteral;
+import org.eclipse.jet.internal.xpath.ast.NumberLiteral;
+import org.eclipse.jet.internal.xpath.ast.RelOp;
+import org.eclipse.jet.internal.xpath.ast.StringLiteral;
+import org.eclipse.jet.xpath.NodeSet;
+
+public class RelOpTests extends AbstractExprTest {
+
+ public void testEquals_Number_Number() {
+ BooleanExpr expr = new RelOp.Eq(new NumberLiteral(3), new NumberLiteral(3));
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NumberLiteral(3), new NumberLiteral(3.0001));
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NumberLiteral(Double.NaN), new NumberLiteral(Double.NaN));
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NumberLiteral(Double.POSITIVE_INFINITY), new NumberLiteral(Double.POSITIVE_INFINITY));
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NumberLiteral(Double.NEGATIVE_INFINITY), new NumberLiteral(Double.NEGATIVE_INFINITY));
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NumberLiteral(Double.POSITIVE_INFINITY), new NumberLiteral(Double.NEGATIVE_INFINITY));
+ assertFalse(expr.evalAsBoolean(null));
+ }
+
+ public void testEquals_String_String() {
+ BooleanExpr expr = new RelOp.Eq(new StringLiteral("hello"), new StringLiteral("hello"));
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new StringLiteral("hello"), new StringLiteral("world"));
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new StringLiteral("hello"), new StringLiteral("hello4"));
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new StringLiteral(""), new StringLiteral(""));
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new StringLiteral("hello"), new StringLiteral(""));
+ assertFalse(expr.evalAsBoolean(null));
+ }
+
+ public void testEquals_Boolean_Boolean() {
+ BooleanExpr expr = new RelOp.Eq(BooleanLiteral.TRUE, BooleanLiteral.TRUE);
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(BooleanLiteral.FALSE, BooleanLiteral.FALSE);
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(BooleanLiteral.FALSE, BooleanLiteral.TRUE);
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(BooleanLiteral.TRUE, BooleanLiteral.FALSE);
+ assertFalse(expr.evalAsBoolean(null));
+ }
+
+ public void testEquals_Nodeset_Nodeset() {
+ NodeSet empty1 = new NodeSetImpl();
+ NodeSet empty2 = new NodeSetImpl();
+ NodeSet singleA = new NodeSetImpl();
+ singleA.add(elementA);
+ NodeSet singleA2 = new NodeSetImpl();
+ singleA2.add(elementA);
+ NodeSet ab = new NodeSetImpl();
+ ab.add(elementA);
+ ab.add(elementB);
+ NodeSet ba = new NodeSetImpl();
+ ba.add(elementB);
+ ba.add(elementA);
+
+
+ // comparing to an empty node set already returns false. See http://www.w3.org/TR/xpath#booleans
+ BooleanExpr expr = new RelOp.Eq(new NodeSetLiteral(empty1), new NodeSetLiteral(empty2));
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(singleA), new NodeSetLiteral(empty1));
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(empty1), new NodeSetLiteral(singleA));
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(singleA), new NodeSetLiteral(singleA2));
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(ab), new NodeSetLiteral(ba));
+ assertTrue(expr.evalAsBoolean(null));
+ }
+
+ public void testEquals_Nodeset_String() {
+ NodeSet empty1 = new NodeSetImpl();
+ NodeSet singleA = new NodeSetImpl();
+ singleA.add(elementA);
+ NodeSet ab = new NodeSetImpl();
+ ab.add(elementA);
+ ab.add(elementB);
+ NodeSet ba = new NodeSetImpl();
+ ba.add(elementB);
+ ba.add(elementA);
+
+ BooleanExpr expr = new RelOp.Eq(new NodeSetLiteral(empty1), new StringLiteral(""));
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(empty1), new StringLiteral("foo"));
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(singleA), new StringLiteral(EXPECTED_A_TEXT));
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(ab), new StringLiteral(EXPECTED_A_TEXT));
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(ba), new StringLiteral(EXPECTED_A_TEXT));
+ assertTrue(expr.evalAsBoolean(null));
+
+ }
+
+ public void testEquals_Nodeset_Boolean() {
+ NodeSet empty1 = new NodeSetImpl();
+ NodeSet singleA = new NodeSetImpl();
+ singleA.add(elementA);
+ NodeSet ab = new NodeSetImpl();
+ ab.add(elementA);
+ ab.add(elementB);
+ NodeSet ba = new NodeSetImpl();
+ ba.add(elementB);
+ ba.add(elementA);
+
+ BooleanExpr expr = new RelOp.Eq(new NodeSetLiteral(empty1), BooleanLiteral.TRUE);
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(empty1), BooleanLiteral.FALSE);
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(singleA), BooleanLiteral.TRUE);
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(singleA), BooleanLiteral.FALSE);
+ assertFalse(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(ab), BooleanLiteral.TRUE);
+ assertTrue(expr.evalAsBoolean(null));
+
+ expr = new RelOp.Eq(new NodeSetLiteral(ba), BooleanLiteral.FALSE);
+ assertFalse(expr.evalAsBoolean(null));
+
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ResourceInspectorTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ResourceInspectorTests.java
new file mode 100644
index 0000000..24b7fde
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/ResourceInspectorTests.java
@@ -0,0 +1,116 @@
+package org.eclipse.jet.tests.xpath;
+
+import junit.framework.TestCase;
+
+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.Resource.Factory;
+import org.eclipse.jet.internal.xpath.inspectors.EMFResourceInspector;
+import org.eclipse.jet.xpath.inspector.ExpandedName;
+import org.eclipse.jet.xpath.inspector.INodeInspector.NodeKind;
+
+public class ResourceInspectorTests extends TestCase {
+
+ protected Resource resource;
+ protected EObject root;
+ protected EMFResourceInspector inspector;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ URI fileURI = URI.createURI("platform:/plugin/org.eclipse.jet.tests/data/sample.dataaccess");
+ Factory factory = Resource.Factory.Registry.INSTANCE.getFactory(fileURI);
+
+ resource = factory.createResource(fileURI);
+ resource.load(null);
+
+ root = (EObject) resource.getContents().get(0);
+
+ inspector = new EMFResourceInspector();
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ResourceInspector.getNamedChildren(Object, ExpandedName)'
+ */
+ public void testGetNamedChildren_contents() {
+ Object[] namedChildren = inspector.getNamedChildren(resource, new ExpandedName("contents"));
+ assertEquals(1, namedChildren.length);
+ assertEquals(root, namedChildren[0]);
+ }
+
+ public void testGetNamedChildren_eClass() {
+ Object[] namedChildren = inspector.getNamedChildren(resource, new ExpandedName("Employee"));
+ assertEquals(1, namedChildren.length);
+ assertEquals(root, namedChildren[0]);
+
+ }
+
+ public void testGetNamedChildren_invalid() {
+ Object[] namedChildren = inspector.getNamedChildren(resource, new ExpandedName("Customer"));
+ assertEquals(0, namedChildren.length);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ResourceInspector.getNodeKind(Object)'
+ */
+ public void testGetNodeKind() {
+ NodeKind nodeKind = inspector.getNodeKind(resource);
+ assertEquals(NodeKind.ROOT, nodeKind);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ResourceInspector.getParent(Object)'
+ */
+ public void testGetParent() {
+ Object result = inspector.getParent(resource);
+ assertNull(result);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ResourceInspector.stringValueOf(Object)'
+ */
+ public void testStringValueOf() {
+ String result = inspector.stringValueOf(resource);
+ assertEquals("", result);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ResourceInspector.expandedNameOf(Object)'
+ */
+ public void testExpandedNameOf() {
+ ExpandedName expandedName = inspector.expandedNameOf(resource);
+
+ assertNull(expandedName);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ResourceInspector.getDocumentRoot(Object)'
+ */
+ public void testGetDocumentRoot() {
+ Object documentRoot = inspector.getDocumentRoot(resource);
+
+ assertEquals(resource, documentRoot);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ResourceInspector.getChildren(Object)'
+ */
+ public void testGetChildren() {
+ Object[] children = inspector.getChildren(resource);
+
+ assertNotNull(children);
+ assertEquals(1, children.length);
+ assertEquals(root, children[0]);
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.ResourceInspector.nameOf(Object)'
+ */
+ public void testNameOf() {
+ String nameOf = inspector.nameOf(resource);
+
+ assertNull(nameOf);
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/RootTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/RootTests.java
new file mode 100644
index 0000000..1dd89fa
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/RootTests.java
@@ -0,0 +1,82 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Set;
+
+import org.eclipse.jet.internal.xpath.ast.Root;
+import org.eclipse.jet.xpath.Context;
+
+public class RootTests extends AbstractExprTest {
+
+ public void testEvalAsNodeSet_document_context() {
+ Root rootExp = new Root();
+
+ Context context = new Context(document, null);
+
+ Set resultSet = rootExp.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(document));
+ }
+
+ public void testEvalAsNodeSet_element_context() {
+ Root rootExp = new Root();
+
+ Context context = new Context(elementA, null);
+
+ Set resultSet = rootExp.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(document));
+ }
+
+ public void testEvalAsNodeSet_attribute_context() {
+ Root rootExp = new Root();
+
+ Context context = new Context(attr, null);
+
+ Set resultSet = rootExp.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(document));
+ }
+
+ public void testEvalAsNodeSet_text_context() {
+ Root rootExp = new Root();
+
+ Context context = new Context(bText, null);
+
+ Set resultSet = rootExp.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(document));
+ }
+
+ public void testEvalAsNodeSet_pi_context() {
+ Root rootExp = new Root();
+
+ Context context = new Context(pi, null);
+
+ Set resultSet = rootExp.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(document));
+ }
+
+ public void testEvalAsNodeSet_comment_context() {
+ Root rootExp = new Root();
+
+ Context context = new Context(comment, null);
+
+ Set resultSet = rootExp.evalAsNodeSet(context);
+
+ assertNotNull(resultSet);
+ assertEquals(1, resultSet.size());
+ assertTrue(resultSet.contains(document));
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/StringFunctionTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/StringFunctionTests.java
new file mode 100644
index 0000000..43bf8b7
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/StringFunctionTests.java
@@ -0,0 +1,61 @@
+package org.eclipse.jet.tests.xpath;
+
+import org.eclipse.jet.internal.xpath.NodeSetImpl;
+import org.eclipse.jet.internal.xpath.functions.StringFunction;
+import org.eclipse.jet.xpath.NodeSet;
+
+public class StringFunctionTests extends AbstractExprTest {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.functions.StringFunction.evaluate(Object)'
+ */
+ public void testEvaluateObject_boolean_true() {
+
+ String result = StringFunction.evaluate(Boolean.TRUE);
+ assertEquals("true", result);
+
+ }
+ public void testEvaluateObject_boolean_false() {
+
+ String result = StringFunction.evaluate(Boolean.FALSE);
+ assertEquals("false", result);
+
+ }
+
+ public void testEvaluateObject_Number() {
+ String result = StringFunction.evaluate(new Double(3.14159265));
+ assertEquals("3.14159265", result);
+
+ String resultNaN = StringFunction.evaluate(new Double(Double.NaN));
+ assertEquals("NaN", resultNaN);
+
+ String resultNegInf = StringFunction.evaluate(new Double(Double.NEGATIVE_INFINITY));
+ assertEquals("-Infinity", resultNegInf);
+
+ String resultPosInf = StringFunction.evaluate(new Double(Double.POSITIVE_INFINITY));
+ assertEquals("Infinity", resultPosInf);
+ }
+
+ public void testEvaluateObject_String() {
+ String result = StringFunction.evaluate("r 3.14159265");
+ assertEquals("r 3.14159265", result);
+
+ }
+
+ public void testEvaluateObject_NodeSet() {
+ NodeSet nodeset = new NodeSetImpl();
+ nodeset.add(elementA);
+ nodeset.add(elementB);
+
+ String result = StringFunction.evaluate(nodeset);
+ assertEquals(EXPECTED_A_TEXT, result);
+
+ nodeset.clear();
+ nodeset.add(elementB);
+ nodeset.add(elementA);
+
+ result = StringFunction.evaluate(nodeset);
+ assertEquals(EXPECTED_B_TEXT, result);
+
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/VariableTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/VariableTests.java
new file mode 100644
index 0000000..fc4fcf6
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/VariableTests.java
@@ -0,0 +1,86 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jet.internal.xpath.NodeSetImpl;
+import org.eclipse.jet.internal.xpath.ast.ExprNode;
+import org.eclipse.jet.internal.xpath.ast.Variable;
+import org.eclipse.jet.xpath.Context;
+import org.eclipse.jet.xpath.NodeSet;
+
+public class VariableTests extends AbstractExprTest {
+
+ public void testStringVariable() {
+ Map vars = new HashMap();
+
+ vars.put("x", "something");
+
+ ExprNode expr = new Variable("x");
+
+ Object result = expr.evalAsObject(new Context(null, vars, null));
+
+ assertEquals("something", result);
+ }
+
+ public void testNumberVariable() {
+ Map vars = new HashMap();
+ double expected = 3.141592653589d;
+ vars.put("x", new Double(expected));
+
+ ExprNode expr = new Variable("x");
+
+ Object result = expr.evalAsObject(new Context(null, vars, null));
+
+ assertTrue(result instanceof Number);
+ assertEquals(expected, ((Number)result).doubleValue(), 0);
+
+ }
+
+ public void testBooleanVariable() {
+ Map vars = new HashMap();
+ boolean expected = true;
+ vars.put("x", Boolean.valueOf(expected));
+
+ ExprNode expr = new Variable("x");
+
+ Object result = expr.evalAsObject(new Context(null, vars, null));
+
+ assertTrue(result instanceof Boolean);
+ assertEquals(expected, ((Boolean)result).booleanValue());
+
+ }
+
+ public void testNodeVariable() {
+ Map vars = new HashMap();
+ vars.put("x", elementA);
+
+ ExprNode expr = new Variable("x");
+
+ Object result = expr.evalAsObject(new Context(null, vars, null));
+
+ assertTrue(result instanceof NodeSet);
+ NodeSet resultSet = (NodeSet)result;
+ assertTrue(resultSet.size() == 1);
+ assertTrue(resultSet.contains(elementA));
+ }
+
+ public void testNodeSetVariable() {
+ Map vars = new HashMap();
+ NodeSet set = new NodeSetImpl();
+ set.add(elementA);
+ set.add(elementB);
+ vars.put("x", set);
+
+ ExprNode expr = new Variable("x");
+
+ Object result = expr.evalAsObject(new Context(null, vars, null));
+
+ assertTrue(result instanceof NodeSet);
+ NodeSet resultSet = (NodeSet)result;
+ assertTrue(resultSet.size() == 2);
+ assertTrue(resultSet.contains(elementA));
+ assertTrue(resultSet.contains(elementB));
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathInspectorManagerTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathInspectorManagerTests.java
new file mode 100644
index 0000000..3fe0499
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathInspectorManagerTests.java
@@ -0,0 +1,45 @@
+package org.eclipse.jet.tests.xpath;
+
+import org.eclipse.jet.internal.xpath.inspectors.DOMInspector;
+import org.eclipse.jet.xpath.inspector.INodeInspector;
+import org.eclipse.jet.xpath.inspector.InspectorManager;
+
+
+public class XPathInspectorManagerTests extends AbstractExprTest {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.XPathInspectorManager.getInspector(Object)'
+ */
+ public void testGetInspector() {
+ InspectorManager manager = InspectorManager.getInstance();
+
+ final String expectedInspectorClass = DOMInspector.class.getName();
+ INodeInspector docInspector = manager.getInspector(document);
+ INodeInspector rootInspector = manager.getInspector(rootElement);
+ INodeInspector elementAInspector = manager.getInspector(elementA);
+ INodeInspector elementBInspector = manager.getInspector(elementB);
+ INodeInspector attrInspector = manager.getInspector(attr);
+ INodeInspector bTextInspector = manager.getInspector(bText);
+ INodeInspector piInspector = manager.getInspector(pi);
+ INodeInspector commentInspector = manager.getInspector(comment);
+
+ assertEquals(expectedInspectorClass, docInspector.getClass().getName());
+ assertEquals(expectedInspectorClass, rootInspector.getClass().getName());
+ assertEquals(expectedInspectorClass, elementAInspector.getClass().getName());
+ assertEquals(expectedInspectorClass, elementBInspector.getClass().getName());
+ assertEquals(expectedInspectorClass, attrInspector.getClass().getName());
+ assertEquals(expectedInspectorClass, bTextInspector.getClass().getName());
+ assertEquals(expectedInspectorClass, piInspector.getClass().getName());
+ assertEquals(expectedInspectorClass, commentInspector.getClass().getName());
+
+ assertTrue(docInspector == rootInspector);
+ assertTrue(docInspector == elementAInspector);
+ assertTrue(docInspector == elementBInspector);
+ assertTrue(docInspector == attrInspector);
+ assertTrue(docInspector == bTextInspector);
+ assertTrue(docInspector == piInspector);
+ assertTrue(docInspector == commentInspector);
+
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverDOMTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverDOMTests.java
new file mode 100644
index 0000000..29c8a18
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverDOMTests.java
@@ -0,0 +1,113 @@
+package org.eclipse.jet.tests.xpath;
+
+import org.eclipse.jet.internal.xpath.ast.ExprNode;
+import org.eclipse.jet.internal.xpath.functions.BuiltinXPathFunctionResolver;
+import org.eclipse.jet.internal.xpath.parser.XPathParser;
+import org.eclipse.jet.xpath.Context;
+import org.eclipse.jet.xpath.NodeSet;
+import org.eclipse.jet.xpath.XPath;
+import org.eclipse.jet.xpath.XPathException;
+import org.eclipse.jet.xpath.XPathExpression;
+import org.eclipse.jet.xpath.XPathFactory;
+import org.eclipse.jet.xpath.XPathLexicalException;
+import org.eclipse.jet.xpath.XPathSyntaxException;
+import org.eclipse.jet.xpath.XPathVariableResolver;
+
+public class XPathOverDOMTests extends AbstractExprTest {
+
+ XPath xp;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ XPathFactory factory = XPathFactory.newInstance();
+ xp = factory.newXPath(null);
+ }
+
+ public void testOne() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser parser = new XPathParser("string(/root/a[@name = 'bar']/b)",BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode node = parser.expr();
+ assertEquals("string(<root>/child::root/child::a[(<ctx>/attribute::name='bar')]/child::b)", node.toString());
+
+ Context ctx = new Context(document, null);
+
+ Object result = node.evalAsObject(ctx);
+
+ assertEquals(EXPECTED_OTHER_B_TEXT, (String)result);
+ }
+
+ public void testTwo() throws XPathLexicalException, XPathSyntaxException {
+
+ XPathParser parser = new XPathParser("string(/root/a[2]/b)",BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode node = parser.expr();
+ assertEquals("string(<root>/child::root/child::a[2.0]/child::b)", node.toString());
+
+ Context ctx = new Context(document, null);
+
+ Object result = node.evalAsObject(ctx);
+
+ assertEquals(EXPECTED_OTHER_B_TEXT, (String)result);
+ }
+
+ public void testThree() throws XPathException {
+ XPathExpression xpExpr = xp.compile("/root/a[@name = 'bar']/b");
+
+ assertEquals("<root>/child::root/child::a[(<ctx>/attribute::name='bar')]/child::b", xpExpr.toString());
+
+ String result = xpExpr.evaluateAsString(document);
+
+ assertEquals(EXPECTED_OTHER_B_TEXT, result);
+ }
+
+ public void testFour() throws XPathException {
+ XPathExpression xpExpr = xp.compile("/root/a[2]/b");
+
+ assertEquals("<root>/child::root/child::a[2.0]/child::b", xpExpr.toString());
+
+ String result = xpExpr.evaluateAsString(document);
+
+ assertEquals(EXPECTED_OTHER_B_TEXT, result);
+ }
+
+ public void testFive() throws XPathException {
+ XPathExpression xp1 = xp.compile("/root");
+ final NodeSet rootNodeSet = xp1.evaluateAsNodeSet(document);
+
+ xp.setXPathVariableResolver(new XPathVariableResolver() {
+
+ public Object resolveVariable(String variableName) {
+ return "root".equals(variableName) ? rootNodeSet : null;
+ }});
+
+ XPathExpression xpExpr = xp.compile("$root/a[2]/b");
+
+ assertEquals("$root/child::a[2.0]/child::b", xpExpr.toString());
+
+ String result = xpExpr.evaluateAsString(document);
+
+ assertEquals(EXPECTED_OTHER_B_TEXT, result);
+ }
+
+ public void testSix() throws XPathException {
+ XPathExpression xp1 = xp.compile("/root");
+ final Object root = xp1.evaluateAsSingleNode(document);
+
+ xp.setXPathVariableResolver(new XPathVariableResolver() {
+
+ public Object resolveVariable(String variableName) {
+ return "root".equals(variableName) ? root : null;
+ }});
+
+ XPathExpression xpExpr = xp.compile("$root/a[2]/b");
+
+ assertEquals("$root/child::a[2.0]/child::b", xpExpr.toString());
+
+ String result = xpExpr.evaluateAsString(document);
+
+ assertEquals(EXPECTED_OTHER_B_TEXT, result);
+ }
+
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverEcoreTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverEcoreTests.java
new file mode 100644
index 0000000..51fc19e
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverEcoreTests.java
@@ -0,0 +1,44 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+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.Resource.Factory;
+import org.eclipse.jet.xpath.NodeSet;
+import org.eclipse.jet.xpath.XPath;
+import org.eclipse.jet.xpath.XPathException;
+import org.eclipse.jet.xpath.XPathExpression;
+import org.eclipse.jet.xpath.XPathFactory;
+
+public class XPathOverEcoreTests extends TestCase {
+ protected Resource resource;
+ protected XPath xp;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ URI fileURI = URI.createURI("platform:/plugin/org.eclipse.jet.tests/data/sample.dataaccess");
+ Factory factory = Resource.Factory.Registry.INSTANCE.getFactory(fileURI);
+
+ resource = factory.createResource(fileURI);
+ resource.load(null);
+
+ xp = XPathFactory.newInstance().newXPath(null);
+ }
+
+ public void testOne() throws XPathException {
+ XPathExpression expr = xp.compile("/contents/customers [@name='Sam Brown']/orders");
+
+ NodeSet nodeSet = expr.evaluateAsNodeSet(resource);
+ assertNotNull(nodeSet);
+ assertEquals(2, nodeSet.size());
+ for (Iterator i = nodeSet.iterator(); i.hasNext();) {
+ EObject element = (EObject) i.next();
+ assertEquals("Order", element.eClass().getName());
+ }
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverEmfXmlXsdTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverEmfXmlXsdTests.java
new file mode 100644
index 0000000..2cede7d
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathOverEmfXmlXsdTests.java
@@ -0,0 +1,127 @@
+package org.eclipse.jet.tests.xpath;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+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.Resource.Factory;
+import org.eclipse.emf.ecore.xmi.impl.GenericXMLResourceFactoryImpl;
+import org.eclipse.emf.ecore.xml.type.AnyType;
+import org.eclipse.jet.xpath.NamespaceContext;
+import org.eclipse.jet.xpath.NodeSet;
+import org.eclipse.jet.xpath.XPath;
+import org.eclipse.jet.xpath.XPathException;
+import org.eclipse.jet.xpath.XPathExpression;
+import org.eclipse.jet.xpath.XPathFactory;
+
+public class XPathOverEmfXmlXsdTests extends TestCase {
+
+ protected Resource resource;
+ protected EObject documentRoot;
+ protected AnyType rootElement;
+ protected AnyType elementA1;
+ protected AnyType elementA2;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ super.setUp();
+
+ URI fileURI = URI.createURI("platform:/plugin/org.eclipse.jet.tests/data/library.xml");
+ Factory factory = new GenericXMLResourceFactoryImpl();
+
+ resource = factory.createResource(fileURI);
+ resource.load(null);
+
+ documentRoot = (EObject) resource.getContents().get(0);
+// rootElement = (AnyType) documentRoot.getMixed().getValue(0);
+// FeatureMap childElementsOfRoot = rootElement.getAny();
+// elementA1 = (AnyType) childElementsOfRoot.getValue(0);
+// elementA2 = (AnyType) childElementsOfRoot.getValue(1);
+
+ }
+
+ public void testOne() throws XPathException {
+ XPath xp = XPathFactory.newInstance().newXPath(null);
+
+ xp.setNamespaceContext(new NamespaceContext() {
+
+ public String getNamespaceURI(String prefix) {
+ return "http://www.example.org/beans";
+ }});
+
+ XPathExpression expr = xp.compile("/beans:root/project/@name");
+
+ String result = expr.evaluateAsString(documentRoot);
+ assertEquals("test.beans", result);
+ }
+
+ public void testTwo() throws XPathException {
+ XPath xp = XPathFactory.newInstance().newXPath(null);
+
+ xp.setNamespaceContext(new NamespaceContext() {
+
+ public String getNamespaceURI(String prefix) {
+ return "http://www.example.org/beans";
+ }});
+
+ XPathExpression expr = xp.compile("/beans:root/project/beanModel/bean/attribute[@kind='LIST']");
+ XPathExpression valueExpr = xp.compile("concat(../@name,'.',@name)");
+ NodeSet nodeSet = expr.evaluateAsNodeSet(documentRoot);
+ assertEquals(4, nodeSet.size());
+ String expectedResults[] = new String[] {
+ "Library.books",
+ "Library.authors",
+ "Book.authors",
+ "Author.books",
+ };
+ int resultIndex = 0;
+ for (Iterator i = nodeSet.iterator(); i.hasNext();) {
+ Object result = (Object) i.next();
+ assertEquals(expectedResults[resultIndex++], valueExpr.evaluateAsString(result));
+ }
+ }
+
+ public void testThree() throws XPathException {
+ XPath xp = XPathFactory.newInstance().newXPath(null);
+
+ xp.setNamespaceContext(new NamespaceContext() {
+
+ public String getNamespaceURI(String prefix) {
+ return "http://www.example.org/beans";
+ }});
+
+ XPathExpression expr = xp.compile("/beans:root/project/beanModel/bean/attribute[@kind='LIST']/@name");
+ XPathExpression valueExpr = xp.compile("concat(../../@name,'.',.)");
+ NodeSet nodeSet = expr.evaluateAsNodeSet(documentRoot);
+ assertEquals(4, nodeSet.size());
+ String expectedResults[] = new String[] {
+ "Library.books",
+ "Library.authors",
+ "Book.authors",
+ "Author.books",
+ };
+ int resultIndex = 0;
+ for (Iterator i = nodeSet.iterator(); i.hasNext();) {
+ Object result = (Object) i.next();
+ assertEquals(expectedResults[resultIndex++], valueExpr.evaluateAsString(result));
+ }
+ }
+
+ public void testFour() throws XPathException {
+ XPath xp = XPathFactory.newInstance().newXPath(null);
+
+ xp.setNamespaceContext(new NamespaceContext() {
+
+ public String getNamespaceURI(String prefix) {
+ return "http://www.example.org/beans";
+ }});
+
+ XPathExpression expr = xp.compile("/beans:root/project/beanModel/bean[@name='Author']/attribute[@name='name']/doc");
+ String result = expr.evaluateAsString(documentRoot);
+ assertEquals("doc for Author.name", result);
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathParserDefects.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathParserDefects.java
new file mode 100644
index 0000000..d2e1ce6
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathParserDefects.java
@@ -0,0 +1,35 @@
+package org.eclipse.jet.tests.xpath;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.xpath.ast.ExprNode;
+import org.eclipse.jet.internal.xpath.functions.BuiltinXPathFunctionResolver;
+import org.eclipse.jet.internal.xpath.parser.XPathParser;
+
+public class XPathParserDefects extends TestCase {
+
+
+ public void testParentheses_full() throws Exception {
+ XPathParser xp = new XPathParser("/child::root /child::biff [(@id = '2')]",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+
+ assertEquals("<root>/child::root/child::biff[(<ctx>/attribute::id='2')]", expr.toString());
+
+ }
+
+ public void testParentheses() throws Exception {
+ XPathParser xp = new XPathParser("(@id = '2')",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.primaryExpr();
+
+ assertNotNull(expr);
+
+ assertEquals("(<ctx>/attribute::id='2')", expr.toString());
+
+ }
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathParserTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathParserTests.java
new file mode 100644
index 0000000..99506aa
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathParserTests.java
@@ -0,0 +1,768 @@
+package org.eclipse.jet.tests.xpath;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.xpath.ast.BinaryOp;
+import org.eclipse.jet.internal.xpath.ast.ExprNode;
+import org.eclipse.jet.internal.xpath.ast.Function;
+import org.eclipse.jet.internal.xpath.ast.LogicalOp;
+import org.eclipse.jet.internal.xpath.ast.NumberLiteral;
+import org.eclipse.jet.internal.xpath.ast.Predicate;
+import org.eclipse.jet.internal.xpath.ast.RelOp;
+import org.eclipse.jet.internal.xpath.ast.Root;
+import org.eclipse.jet.internal.xpath.ast.Step;
+import org.eclipse.jet.internal.xpath.ast.StringLiteral;
+import org.eclipse.jet.internal.xpath.ast.UnaryMinus;
+import org.eclipse.jet.internal.xpath.ast.UnionExpr;
+import org.eclipse.jet.internal.xpath.ast.Variable;
+import org.eclipse.jet.internal.xpath.functions.BuiltinXPathFunctionResolver;
+import org.eclipse.jet.internal.xpath.parser.XPathParser;
+import org.eclipse.jet.xpath.XPathLexicalException;
+import org.eclipse.jet.xpath.XPathSyntaxException;
+
+public class XPathParserTests extends TestCase {
+
+ public void testNumber() throws XPathLexicalException {
+ XPathParser xp = new XPathParser("1234.567", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.number();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof NumberLiteral);
+ assertEquals(1234.567, ((NumberLiteral)expr).getDoubleValue(), 0);
+ }
+
+ public void testVariable() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x.y.z", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.variableReference();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Variable);
+
+ assertEquals("x.y.z", ((Variable)expr).getVariableName());
+ }
+
+ public void testVariable_missingName() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$35", BuiltinXPathFunctionResolver.getInstance());
+
+
+ try {
+ xp.variableReference();
+ fail();
+ } catch (XPathSyntaxException e) {
+ // success
+ }
+ }
+
+ public void testLiteral() throws XPathLexicalException {
+ XPathParser xp = new XPathParser("\"abc'def\"", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.literal();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof StringLiteral);
+
+ assertEquals("abc'def", ((StringLiteral)expr).getLiteral());
+ }
+
+ public void testPrimaryExpr_variable() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x.y.z", BuiltinXPathFunctionResolver.getInstance());
+ ExprNode expr = xp.primaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Variable);
+
+ assertEquals("x.y.z", ((Variable)expr).getVariableName());
+
+ }
+
+ public void testPrimaryExpr_literal() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("\"abc'def\"", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.primaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof StringLiteral);
+
+ assertEquals("abc'def", ((StringLiteral)expr).getLiteral());
+ }
+
+ public void testPrimaryExpr_number() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("1234.567", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.primaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof NumberLiteral);
+ assertEquals(1234.567, ((NumberLiteral)expr).getDoubleValue(), 0);
+ }
+
+ public void testFilterExpr_variable() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x.y.z", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.filterExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Variable);
+
+ assertEquals("x.y.z", ((Variable)expr).getVariableName());
+
+ }
+
+ public void testFilterExpr_literal() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("\"abc'def\"", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.filterExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof StringLiteral);
+
+ assertEquals("abc'def", ((StringLiteral)expr).getLiteral());
+
+ }
+
+ public void testFilterExpr_number() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("1234.567", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.filterExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof NumberLiteral);
+ assertEquals(1234.567, ((NumberLiteral)expr).getDoubleValue(), 0);
+
+ }
+
+ public void testPathExpr_variable() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x.y.z", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Variable);
+
+ assertEquals("x.y.z", ((Variable)expr).getVariableName());
+ }
+
+ public void testPathExpr_literal() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("\"abc'def\"", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof StringLiteral);
+
+ assertEquals("abc'def", ((StringLiteral)expr).getLiteral());
+ }
+
+ public void testPathExpr_number() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("1234.567", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof NumberLiteral);
+ assertEquals(1234.567, ((NumberLiteral)expr).getDoubleValue(), 0);
+
+ }
+
+ public void testPathExpr_ncname() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("foo", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("<ctx>/child::foo", ((Step)expr).toString());
+ }
+
+ public void testPathExpr_ncname_slash_ncName() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("foo/bar", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("<ctx>/child::foo/child::bar", ((Step)expr).toString());
+ }
+
+ public void testPathExpr_ncname_slash_ncName_slash_at_ncName() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("foo/bar/@jim", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("<ctx>/child::foo/child::bar/attribute::jim", ((Step)expr).toString());
+ }
+
+ public void testPathExpr_var_slash_ncName() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$foo/bar", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("$foo/child::bar", ((Step)expr).toString());
+ }
+
+ public void testPathExpr_var_slash_ncName_slash_at_ncName() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$foo/bar/@jim", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("$foo/child::bar/attribute::jim", ((Step)expr).toString());
+ }
+
+ public void testPathExpr_slash() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("/", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Root);
+
+ assertEquals("<root>", expr.toString());
+ }
+
+ public void testPathExpr_slash_ncname() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("<root>/child::foo", ((Step)expr).toString());
+ }
+
+ public void testPathExpr_slash_ncname_slash_ncname() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo/bar", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("<root>/child::foo/child::bar", ((Step)expr).toString());
+ }
+
+ public void testPathExpr_slash_ncname_slash_at_name() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo/@bar", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("<root>/child::foo/attribute::bar", ((Step)expr).toString());
+ }
+
+ public void testUnionExpr_variable() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x.y.z", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.unionExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Variable);
+
+ assertEquals("x.y.z", ((Variable)expr).getVariableName());
+ }
+
+ public void testUnionExpr_literal() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("\"abc'def\"", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.unionExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof StringLiteral);
+
+ assertEquals("abc'def", ((StringLiteral)expr).getLiteral());
+ }
+
+ public void testUnionExpr_number() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("1234.567", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.unionExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof NumberLiteral);
+ assertEquals(1234.567, ((NumberLiteral)expr).getDoubleValue(), 0);
+ }
+
+ public void testUnionExpr_pathExpr_slash_ncname()
+ throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo", BuiltinXPathFunctionResolver
+ .getInstance());
+
+ ExprNode expr = xp.unionExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("<root>/child::foo", ((Step) expr).toString());
+ }
+
+ public void testUnionExpr_pathExpr_ncname_slash_ncname()
+ throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("foo/bar",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.unionExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("<ctx>/child::foo/child::bar", expr.toString());
+ }
+
+ public void testUnionExpr_2_pathExpr()
+ throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo | foo/bar",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.unionExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof UnionExpr);
+
+ assertEquals("<root>/child::foo|<ctx>/child::foo/child::bar", expr.toString());
+ }
+
+ public void testUnionExpr_3_pathExpr() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo | foo/bar | $foo/bar/@jim",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.unionExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof UnionExpr);
+
+ assertEquals("<root>/child::foo|<ctx>/child::foo/child::bar|$foo/child::bar/attribute::jim", expr
+ .toString());
+ }
+
+ public void testUnionExpr_pathExpr_number() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo | 3",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ try {
+ xp.unionExpr();
+ fail();
+ } catch(XPathSyntaxException e) {
+ // success
+ }
+ }
+
+ public void testUnionExpr_2_pathExpr_number() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo | foo/bar | 3",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ try {
+ xp.unionExpr();
+ fail();
+ } catch (XPathSyntaxException e) {
+ // success
+ }
+ }
+
+ public void testUnionExpr_2_pathExpr_var() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo | foo/bar | $x",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.unionExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof UnionExpr);
+
+ assertEquals("<root>/child::foo|<ctx>/child::foo/child::bar|$x", expr
+ .toString());
+ }
+
+ public void testUnaryExpr_number() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("3",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.unaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof NumberLiteral);
+
+ assertEquals("3.0", expr.toString());
+ }
+
+ public void testUnaryExpr_neg_number() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("-3", BuiltinXPathFunctionResolver
+ .getInstance());
+
+ ExprNode expr = xp.unaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof UnaryMinus);
+
+ assertEquals("-(3.0)", expr.toString());
+ }
+
+ public void testUnaryExpr_neg_neg_number() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("--3", BuiltinXPathFunctionResolver
+ .getInstance());
+
+ ExprNode expr = xp.unaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof UnaryMinus);
+
+ assertEquals("-(-(3.0))", expr.toString());
+ }
+
+
+ public void testUnaryExpr_pathExpr() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x/@bar", BuiltinXPathFunctionResolver
+ .getInstance());
+
+ ExprNode expr = xp.unaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Step);
+
+ assertEquals("$x/attribute::bar", expr.toString());
+ }
+
+ public void testUnaryExpr_neg_pathExpr() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("- $x/@bar",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.unaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof UnaryMinus);
+
+ assertEquals("-($x/attribute::bar)", expr.toString());
+ }
+
+ public void testMultiplicativeExpr_number() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("3.0",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.multiplicativeExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof NumberLiteral);
+
+ assertEquals("3.0", expr.toString());
+ }
+
+ public void testMultiplicativeExpr_number_star() throws XPathLexicalException,
+ XPathSyntaxException {
+ XPathParser xp = new XPathParser("3 * 4",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.multiplicativeExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof BinaryOp.Multiply);
+
+ assertEquals("(3.0*4.0)", expr.toString());
+ }
+
+ public void testMultiplicativeExpr_pathExpr_pathExpr()
+ throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x/@y * $a/@b", BuiltinXPathFunctionResolver
+ .getInstance());
+
+ ExprNode expr = xp.multiplicativeExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof BinaryOp.Multiply);
+
+ assertEquals("($x/attribute::y*$a/attribute::b)", expr.toString());
+ }
+
+ public void testMultiplicativeExpr_div_pathExpr_pathExpr()
+ throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x/@y div $a/@b",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.multiplicativeExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof BinaryOp.Div);
+
+ assertEquals("($x/attribute::y div $a/attribute::b)", expr.toString());
+ }
+
+ public void testMultiplicativeExpr_mod_pathExpr_pathExpr()
+ throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x/@y mod $a/@b",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.multiplicativeExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof BinaryOp.Mod);
+
+ assertEquals("($x/attribute::y mod $a/attribute::b)", expr.toString());
+ }
+
+ public void testMultiplicativeExpr_neg_pathExpr_pathExpr()
+ throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("- $x/@y * $a/@b",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.multiplicativeExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof BinaryOp.Multiply);
+
+ assertEquals("(-($x/attribute::y)*$a/attribute::b)", expr.toString());
+ }
+
+ public void testAdditiveExpr_add_mult() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo/bar + - $x/@y * $a/@b",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.additiveExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof BinaryOp.Add);
+
+ assertEquals("(<root>/child::foo/child::bar+(-($x/attribute::y)*$a/attribute::b))", expr.toString());
+ }
+
+ public void testAdditiveExpr_sub_div() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("/foo/bar - - $x/@y div $a/@b",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.additiveExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof BinaryOp.Subtract);
+
+ assertEquals("(<root>/child::foo/child::bar - (-($x/attribute::y) div $a/attribute::b))", expr.toString());
+ }
+
+ public void testRelationalOp_1() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("2 + 3 * 5 > 4 * 5 - 1 >= 0",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.relationalExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof RelOp.Gte);
+
+ assertEquals("(((2.0+(3.0*5.0))>((4.0*5.0) - 1.0))>=0.0)", expr.toString());
+ }
+
+ public void testRelationalOp_2() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("2 + 3 * 5 < 4 * 5 - 1 <= 0",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.relationalExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof RelOp.Lte);
+
+ assertEquals("(((2.0+(3.0*5.0))<((4.0*5.0) - 1.0))<=0.0)", expr.toString());
+ }
+
+ public void testEqualityExpr_var_literal() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x = 'hello'",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.equalityExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof RelOp.Eq);
+
+ assertEquals("($x='hello')", expr.toString());
+ }
+
+ public void testEqualityExpr_var_ne_literal() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x != 'hello'",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.equalityExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof RelOp.NotEq);
+
+ assertEquals("($x!='hello')", expr.toString());
+ }
+
+ public void testEqualityExpr_a_eq_b_lt_c() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$a = $b < $c",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.equalityExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof RelOp.Eq);
+
+ assertEquals("($a=($b<$c))", expr.toString());
+ }
+
+ public void testAndExpr_a_eq_b_and_x_lt_y() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$a = $b and $x < $y",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.andExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof LogicalOp.And);
+
+ assertEquals("(($a=$b) and ($x<$y))", expr.toString());
+ }
+
+ public void testOrExpr_w_neq_z_or_a_eq_b_and_x_lt_y() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x != $z or $a = $b and $x < $y",
+ BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.orExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof LogicalOp.Or);
+
+ assertEquals("(($x!=$z) or (($a=$b) and ($x<$y)))", expr.toString());
+ }
+
+ public void testfilterExpr_number_predicate() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("1234.567[3 = 4]", BuiltinXPathFunctionResolver.getInstance());
+
+ try {
+ xp.filterExpr();
+ fail();
+ } catch(XPathSyntaxException e) {
+ // success
+ }
+ }
+
+ public void testfilterExpr_literal_predicate() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("'abcde'[3 = 4]", BuiltinXPathFunctionResolver.getInstance());
+
+ try {
+ xp.filterExpr();
+ fail();
+ } catch(XPathSyntaxException e) {
+ // success
+ }
+ }
+
+ public void testfilterExpr_var_predicate() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x[3 = 4]", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.filterExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Predicate);
+
+ assertEquals("$x[(3.0=4.0)]", expr.toString());
+ }
+
+ public void testfilterExpr_var_predicate_predicate() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("$x[3 = 4][2]", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.filterExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Predicate);
+
+ assertEquals("$x[(3.0=4.0)][2.0]", expr.toString());
+ }
+
+ public void testPathExpr_path_predicate() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("foo/bar[3 = 4]", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Predicate);
+
+ assertEquals("<ctx>/child::foo/child::bar[(3.0=4.0)]", expr.toString());
+ }
+
+ public void testPathExpr_path_predicate_predicate() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("foo/bar[3 = 4][2]", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.pathExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Predicate);
+
+ assertEquals("<ctx>/child::foo/child::bar[(3.0=4.0)][2.0]", expr.toString());
+ }
+
+ public void testPrimaryExpr_function_starts_with() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("starts-with('abc', 'ab')", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.primaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Function);
+
+ assertEquals("starts-with('abc','ab')", expr.toString());
+ }
+
+ public void testPrimaryExpr_function_starts_with_1_arg() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("starts-with('abc')", BuiltinXPathFunctionResolver.getInstance());
+
+ try {
+ xp.primaryExpr();
+ fail();
+ } catch(XPathSyntaxException e) {
+ // success
+ }
+
+ }
+
+ public void testPrimaryExpr_function_last() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("last()", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.primaryExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Function);
+
+ assertEquals("last()", expr.toString());
+ }
+
+ public void testFilterExpr_function_id_predicate() throws XPathLexicalException, XPathSyntaxException {
+ XPathParser xp = new XPathParser("floor('boo')[3]", BuiltinXPathFunctionResolver.getInstance());
+
+ ExprNode expr = xp.filterExpr();
+
+ assertNotNull(expr);
+ assertTrue(expr instanceof Predicate);
+
+ assertEquals("floor('boo')[3.0]", expr.toString());
+ }
+
+ public void testFunctionCall_with_malformed_arg() throws XPathLexicalException {
+ XPathParser xp = new XPathParser("concat(../..@name,'.',.)", BuiltinXPathFunctionResolver.getInstance());
+
+ try {
+ xp.functionCall();
+ fail();
+ } catch(XPathSyntaxException e) {
+ // success
+ }
+
+ }
+
+}
diff --git a/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathTokenScannerTests.java b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathTokenScannerTests.java
new file mode 100644
index 0000000..8524c87
--- /dev/null
+++ b/tests/org.eclipse.jet.tests/src/org/eclipse/jet/tests/xpath/XPathTokenScannerTests.java
@@ -0,0 +1,251 @@
+package org.eclipse.jet.tests.xpath;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jet.internal.xpath.parser.Token;
+import org.eclipse.jet.internal.xpath.parser.XPathTokenScanner;
+import org.eclipse.jet.internal.xpath.parser.XPathTokens;
+import org.eclipse.jet.xpath.XPathLexicalException;
+
+public class XPathTokenScannerTests extends TestCase {
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.parset.XPathTokenScanner.prev()'
+ */
+ public void testPrev() {
+ XPathTokenScanner scanner = new XPathTokenScanner("abcde");
+
+ int a = scanner.next();
+ int b = scanner.next();
+ int c = scanner.next();
+ int d = scanner.next();
+ int e = scanner.next();
+ int f1 = scanner.next();
+ int f2 = scanner.next();
+
+ assertEquals('a', a);
+ assertEquals('b', b);
+ assertEquals('c', c);
+ assertEquals('d', d);
+ assertEquals('e', e);
+ assertEquals(XPathTokenScanner.EOF, f1);
+ assertEquals(XPathTokenScanner.EOF, f2);
+
+ // do a 'prev()' for each next() above, and then
+ scanner.prev();
+ scanner.prev();
+ scanner.prev();
+ scanner.prev();
+ scanner.prev();
+ scanner.prev();
+ scanner.prev();
+
+ int a_2 = scanner.next();
+ int b_2 = scanner.next();
+ int c_2 = scanner.next();
+ int d_2 = scanner.next();
+ int e_2 = scanner.next();
+ int f1_2 = scanner.next();
+ int f2_2 = scanner.next();
+
+ assertEquals('a', a_2);
+ assertEquals('b', b_2);
+ assertEquals('c', c_2);
+ assertEquals('d', d_2);
+ assertEquals('e', e_2);
+ assertEquals(XPathTokenScanner.EOF, f1_2);
+ assertEquals(XPathTokenScanner.EOF, f2_2);
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.parset.XPathTokenScanner.next()'
+ */
+ public void testNext() {
+ XPathTokenScanner scanner = new XPathTokenScanner("abcde");
+
+ int a = scanner.next();
+ int b = scanner.next();
+ int c = scanner.next();
+ int d = scanner.next();
+ int e = scanner.next();
+ int f1 = scanner.next();
+ int f2 = scanner.next();
+
+ assertEquals('a', a);
+ assertEquals('b', b);
+ assertEquals('c', c);
+ assertEquals('d', d);
+ assertEquals('e', e);
+ assertEquals(XPathTokenScanner.EOF, f1);
+ assertEquals(XPathTokenScanner.EOF, f2);
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.parset.XPathTokenScanner.nextToken()'
+ */
+ public void testNextToken_Literal_doublequotes() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("\"abcde'fgh\"");
+
+ Token t = scanner.nextToken();
+
+ assertEquals(XPathTokens.LITERAL, t);
+ assertEquals("\"abcde'fgh\"", scanner.getTokenText());
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.parset.XPathTokenScanner.nextToken()'
+ */
+ public void testNextToken_Literal_singlequotes() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("'abcde\"fgh'");
+
+ Token t = scanner.nextToken();
+
+ assertEquals(XPathTokens.LITERAL, t);
+ assertEquals("'abcde\"fgh'", scanner.getTokenText());
+
+ }
+
+ /*
+ * Test method for 'org.eclipse.jet.internal.xpath.parset.XPathTokenScanner.nextToken()'
+ */
+ public void testNextToken_Literal_missingquotes() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("'abcde\"fgh");
+
+ try {
+ scanner.nextToken();
+ fail();
+ } catch (XPathLexicalException e) {
+ // success
+ }
+ }
+
+ public void testNextToken_Literal_multi_strings_and_ws() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner(" 'abcde\"fgh' \"abcde'fgh\"\"abcde'fgh\" ");
+
+ Token t1 = scanner.nextToken();
+ assertEquals(XPathTokens.LITERAL, t1);
+ assertEquals("'abcde\"fgh'", scanner.getTokenText());
+
+ Token t2 = scanner.nextToken();
+ assertEquals(XPathTokens.LITERAL, t2);
+ assertEquals("\"abcde'fgh\"", scanner.getTokenText());
+
+ Token t3 = scanner.nextToken();
+ assertEquals(XPathTokens.LITERAL, t3);
+ assertEquals("\"abcde'fgh\"", scanner.getTokenText());
+
+ }
+
+ public void testNextToken_NCName() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("_abcde");
+
+ Token t1 = scanner.nextToken();
+ assertEquals(XPathTokens.NCNAME, t1);
+ assertEquals("_abcde", scanner.getTokenText());
+
+ }
+
+ public void testNextToken_NCName_2() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("_abcde:");
+
+ Token t1 = scanner.nextToken();
+ assertEquals(XPathTokens.NCNAME, t1);
+ assertEquals("_abcde", scanner.getTokenText());
+
+ }
+
+ public void testNextToken_QName() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("_abcde:_defg");
+
+ Token t1 = scanner.nextToken();
+ assertEquals(XPathTokens.QNAME, t1);
+ assertEquals("_abcde:_defg", scanner.getTokenText());
+
+ }
+
+ public void testNextToken_QName_1() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("_abcde:123");
+
+ Token t1 = scanner.nextToken();
+ assertEquals(XPathTokens.NCNAME, t1);
+ assertEquals("_abcde", scanner.getTokenText());
+
+ }
+
+ public void testNextToken_QName_2() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("_abcde:*");
+
+ Token t1 = scanner.nextToken();
+ assertEquals(XPathTokens.NCNAME, t1);
+ assertEquals("_abcde", scanner.getTokenText());
+
+ }
+
+ public void testNextToken_Number_1() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("123");
+
+ Token t = scanner.nextToken();
+ assertEquals(XPathTokens.NUMBER, t);
+ assertEquals("123", scanner.getTokenText());
+ }
+
+ public void testNextToken_Number_2() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("123.");
+
+ Token t = scanner.nextToken();
+ assertEquals(XPathTokens.NUMBER, t);
+ assertEquals("123.", scanner.getTokenText());
+ }
+
+ public void testNextToken_Number_3() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("123.45");
+
+ Token t = scanner.nextToken();
+ assertEquals(XPathTokens.NUMBER, t);
+ assertEquals("123.45", scanner.getTokenText());
+ }
+
+ public void testNextToken_Number_4() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner(".1234");
+
+ Token t = scanner.nextToken();
+ assertEquals(XPathTokens.NUMBER, t);
+ assertEquals(".1234", scanner.getTokenText());
+ }
+
+ public void testNextToken_Number_5() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner(".1234.12");
+
+ Token t = scanner.nextToken();
+ assertEquals(XPathTokens.NUMBER, t);
+ assertEquals(".1234", scanner.getTokenText());
+ }
+
+ public void testNextToken_Number_6() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("0.1234.12");
+
+ Token t = scanner.nextToken();
+ assertEquals(XPathTokens.NUMBER, t);
+ assertEquals("0.1234", scanner.getTokenText());
+ }
+
+ public void testNextToken_Dot() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner(".abcde");
+
+ Token t = scanner.nextToken();
+ assertEquals(XPathTokens.DOT, t);
+ assertEquals(".", scanner.getTokenText());
+ }
+
+ public void testNextToken_DotDot() throws XPathLexicalException {
+ XPathTokenScanner scanner = new XPathTokenScanner("..123");
+
+ Token t = scanner.nextToken();
+ assertEquals(XPathTokens.DOT_DOT, t);
+ assertEquals("..", scanner.getTokenText());
+ }
+
+}