Based on approval of https://dev.eclipse.org/ipzilla/show_bug.cgi?id=5021.
SIE tests plug-in
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/.classpath b/plugins/org.eclipse.wst.sse.sieditor.test/.classpath
new file mode 100644
index 0000000..634bdc6
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/.classpath
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="api"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry exported="true" kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/.gitignore b/plugins/org.eclipse.wst.sse.sieditor.test/.gitignore
new file mode 100644
index 0000000..d567ba0
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/.gitignore
@@ -0,0 +1,2 @@
+bin
+target
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/.project b/plugins/org.eclipse.wst.sse.sieditor.test/.project
new file mode 100644
index 0000000..46c174c
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/.project
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>

+<projectDescription>

+	<name>org.eclipse.wst.sse.sieditor.test</name>

+	<comment></comment>

+	<projects>

+	</projects>

+	<buildSpec>

+		<buildCommand>

+			<name>org.eclipse.pde.SchemaBuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+		<buildCommand>

+			<name>org.eclipse.jdt.core.javabuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+		<buildCommand>

+			<name>org.eclipse.pde.ManifestBuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+		<buildCommand>

+			<name>com.sap.ide.eclipse.validation.core.autoValidationBuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+		<buildCommand>

+			<name>org.eclipse.wst.validation.validationbuilder</name>

+			<arguments>

+			</arguments>

+		</buildCommand>

+	</buildSpec>

+	<natures>

+		<nature>com.sap.ide.eclipse.validation.core.autoValidationNature</nature>

+		<nature>org.eclipse.pde.PluginNature</nature>

+		<nature>org.eclipse.jdt.core.javanature</nature>

+		<nature>com.sap.tools.japro.japroProjectNature</nature>

+	</natures>

+</projectDescription>

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.wst.sse.sieditor.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..34599e2
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,13 @@
+#Tue Jan 25 23:56:32 EET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/.settings/org.eclipse.wst.validation.prefs b/plugins/org.eclipse.wst.sse.sieditor.test/.settings/org.eclipse.wst.validation.prefs
new file mode 100644
index 0000000..309f404
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/.settings/org.eclipse.wst.validation.prefs
@@ -0,0 +1,11 @@
+#Fri Feb 25 18:20:54 EET 2011

+DELEGATES_PREFERENCE=delegateValidatorList

+USER_BUILD_PREFERENCE=enabledBuildValidatorList

+USER_MANUAL_PREFERENCE=enabledManualValidatorListorg.eclipse.wst.wsi.ui.internal.WSIMessageValidator;

+USER_PREFERENCE=overrideGlobalPreferencestruedisableAllValidationfalseversion1.2.200.v201005271900

+eclipse.preferences.version=1

+override=true

+suspend=false

+vals/org.eclipse.wst.wsdl.validation.wsdl/global=TF02158org.eclipse.wst.wsdl.validation.internal.eclipse.Validator

+vals/org.eclipse.wst.xsd.core.xsd/global=TF02162org.eclipse.wst.xsd.core.internal.validation.eclipse.Validator

+vf.version=3

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/.settings/org.maven.ide.eclipse.prefs b/plugins/org.eclipse.wst.sse.sieditor.test/.settings/org.maven.ide.eclipse.prefs
new file mode 100644
index 0000000..46e96f0
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/.settings/org.maven.ide.eclipse.prefs
@@ -0,0 +1,8 @@
+#Tue Jan 25 23:48:24 EET 2011
+activeProfiles=
+eclipse.preferences.version=1
+fullBuildGoals=process-test-resources
+resolveWorkspaceProjects=true
+resourceFilterGoals=process-resources resources\:testResources
+skipCompilerPlugin=true
+version=1
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/InvalidSchema.xsd b/plugins/org.eclipse.wst.sse.sieditor.test/InvalidSchema.xsd
new file mode 100755
index 0000000..f711596
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/InvalidSchema.xsd
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>

+<xsd:schema targetNamespace="http://missing/XMLSchema" >


+    <xsd:element name="Element1"><xsd:complexType><xsd:sequence><xsd:element minOccurs="1" maxOccurs="1" name="string" type="xsd:string"></xsd:element></xsd:sequence></xsd:complexType></xsd:element>

+    <xsd:complexType name="StructureType1"><xsd:sequence><xsd:element minOccurs="1" maxOccurs="1" name="Element1" type="xsd:string"></xsd:element></xsd:sequence></xsd:complexType>

+    <xsd:element name="Element2"><xsd:complexType><xsd:sequence><xsd:element minOccurs="1" maxOccurs="1" name="string" type="xsd:string"></xsd:element></xsd:sequence><xsd:attribute name="Attribute1"></xsd:attribute></xsd:complexType></xsd:element>

+</xsd:schema>

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.wst.sse.sieditor.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..f4f1222
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/META-INF/MANIFEST.MF
@@ -0,0 +1,149 @@
+Manifest-Version: 1.0

+Bundle-ManifestVersion: 2

+Bundle-Name: %plugin.name

+Bundle-SymbolicName: org.eclipse.wst.sse.sieditor.test;singleton:=true

+Bundle-Version: 1.0.0.qualifier

+Bundle-Activator: org.eclipse.wst.sse.sieditor.test.SIEditorTestsPlugin

+Bundle-Vendor: %provider.name

+Require-Bundle: org.eclipse.core.runtime,

+ org.eclipse.core.resources;bundle-version="3.4.1",

+ org.eclipse.jdt.core;bundle-version="3.4.2",

+ org.junit;bundle-version="3.8.2",

+ org.eclipse.xsd;bundle-version="2.4.1",

+ org.eclipse.wst.sse.sieditor.ui;bundle-version="1.0.0",

+ org.eclipse.ui;bundle-version="3.4.1",

+ org.eclipse.wst.wsdl,

+ org.junit4,

+ org.eclipse.ui.views.properties.tabbed,

+ org.eclipse.ui.ide;bundle-version="3.5.0",

+ org.eclipse.emf.workspace;bundle-version="1.3.0",

+ javax.wsdl;bundle-version="[1.5.1,1.6.2]",

+ org.eclipse.ui.workbench.texteditor,

+ org.eclipse.wst.common.ui,

+ org.eclipse.wst.common.core,

+ org.eclipse.wst.xsd.ui,

+ org.eclipse.wst.xml.core,

+ org.eclipse.wst.sse.core,

+ org.eclipse.ui.editors,

+ org.eclipse.jface.text,

+ org.eclipse.wst.wsdl.ui,

+ org.eclipse.wst.sse.core,

+ org.eclipse.wst.sse.ui,

+ org.eclipse.wst.sse.sieditor.core;bundle-version="1.0.0",

+ org.eclipse.wst.sse.sieditor.fwk;bundle-version="1.0.0",

+ org.eclipse.wst.sse.sieditor.model;bundle-version="1.0.0",

+ org.eclipse.wst.sse.sieditor.ui;bundle-version="1.0.0"

+Bundle-RequiredExecutionEnvironment: JavaSE-1.6

+Bundle-ActivationPolicy: lazy

+Export-Package: org.eclipse.wst.sse.sieditor.test;uses:="org.osgi.framework",

+ org.eclipse.wst.sse.sieditor.test.all,

+ org.eclipse.wst.sse.sieditor.test.core.common,

+ org.eclipse.wst.sse.sieditor.test.core.editorfwk,

+ org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport,

+ org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport.ui;uses:="org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport,org.eclipse.swt.widgets,org.eclipse.wst.sse.sieditor.fwk.mvp.ui",

+ org.eclipse.wst.sse.sieditor.test.fwk.mvp.ui;uses:="org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport.ui",

+ org.eclipse.wst.sse.sieditor.test.model;

+  uses:="junit.framework,

+   org.eclipse.wst.sse.sieditor.test.util,

+   org.eclipse.wst.sse.sieditor.model.wsdl.api,

+   org.eclipse.wst.sse.sieditor.model.xsd.api",

+ org.eclipse.wst.sse.sieditor.test.model.commands;

+  uses:="org.eclipse.wst.sse.sieditor.core.common,

+   org.eclipse.core.runtime,

+   org.eclipse.wst.sse.sieditor.command.common,

+   org.eclipse.core.commands.operations,

+   org.eclipse.wst.sse.sieditor.model.api,

+   org.eclipse.wst.sse.sieditor.test.util,

+   org.eclipse.wst.sse.sieditor.model.impl",

+ org.eclipse.wst.sse.sieditor.test.model.commands.common,

+ org.eclipse.wst.sse.sieditor.test.model.commands.common.integration,

+ org.eclipse.wst.sse.sieditor.test.model.commands.common.setcommandbuilder,

+ org.eclipse.wst.sse.sieditor.test.model.commands.common.settargetnamespace,

+ org.eclipse.wst.sse.sieditor.test.model.commands.wsdl;

+  uses:="org.eclipse.wst.sse.sieditor.test.model.commands,

+   org.eclipse.wst.sse.sieditor.command.common,

+   org.eclipse.wst.sse.sieditor.model.api,

+   org.eclipse.wst.sse.sieditor.model.impl",

+ org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.extract,

+ org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.facets,

+ org.eclipse.wst.sse.sieditor.test.model.commands.xsd;

+  uses:="org.eclipse.wst.sse.sieditor.test.model.commands.xsd.base,

+   org.eclipse.core.runtime,

+   org.eclipse.wst.sse.sieditor.test.model.commands,

+   org.eclipse.wst.sse.sieditor.command.common,

+   org.eclipse.wst.sse.sieditor.model.api,

+   org.eclipse.wst.sse.sieditor.model.xsd.api,

+   org.eclipse.wst.sse.sieditor.model.xsd.impl,

+   org.eclipse.wst.sse.sieditor.model.impl",

+ org.eclipse.wst.sse.sieditor.test.model.commands.xsd.base;

+  uses:="org.eclipse.wst.sse.sieditor.test.model.commands,

+   org.eclipse.wst.sse.sieditor.command.common,

+   org.eclipse.wst.sse.sieditor.model.api,

+   org.eclipse.wst.sse.sieditor.model.xsd.api,

+   org.eclipse.wst.sse.sieditor.model.xsd.impl,

+   org.eclipse.wst.sse.sieditor.model.impl",

+ org.eclipse.wst.sse.sieditor.test.model.commands.xsd.setstructurebasetype,

+ org.eclipse.wst.sse.sieditor.test.model.factory,

+ org.eclipse.wst.sse.sieditor.test.model.utils,

+ org.eclipse.wst.sse.sieditor.test.model.validation,

+ org.eclipse.wst.sse.sieditor.test.model.validation.constraints,

+ org.eclipse.wst.sse.sieditor.test.model.validation.constraints.http,

+ org.eclipse.wst.sse.sieditor.test.model.validation.constraints.soap,

+ org.eclipse.wst.sse.sieditor.test.model.validation.constraints.webservice.interoperability,

+ org.eclipse.wst.sse.sieditor.test.model.validation.constraints.xsd,

+ org.eclipse.wst.sse.sieditor.test.model.wsdl.impl,

+ org.eclipse.wst.sse.sieditor.test.model.xsd,

+ org.eclipse.wst.sse.sieditor.test.smoke,

+ org.eclipse.wst.sse.sieditor.test.ui,

+ org.eclipse.wst.sse.sieditor.test.ui.preferences,

+ org.eclipse.wst.sse.sieditor.test.ui.readonly,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.common,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.common.propertyEditor,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.dt,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.dt.extract,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.impl,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.labels,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor.selectionlisteners,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor.typecommitters,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.factory,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.newtypedialog,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.nodes.impl,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.providers,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.resources,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.sections,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.sections.elements,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.sections.tables.editing,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.typeselect,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.controller,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.detailspages,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.formpage,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.actionenablement,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.nodes,

+ org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.nodes.labels,

+ org.eclipse.wst.sse.sieditor.test.util;

+  uses:="com.sap.ide.junit.extensions,

+   junit.framework,

+   org.eclipse.wst.sse.sieditor.model.api,

+   org.eclipse.core.resources,

+   org.eclipse.wst.sse.sieditor.model.wsdl.api",

+ org.eclipse.wst.sse.sieditor.test.v2.ui.editor;

+  uses:="org.eclipse.core.runtime,

+   org.eclipse.jface.resource,

+   org.eclipse.wst.sse.sieditor.ui.v2.input,

+   org.eclipse.ui",

+ org.eclipse.wst.sse.sieditor.test.wizard;uses:="junit.framework,org.eclipse.wst.sse.sieditor.test.util",

+ org.eclipse.wst.sse.sieditor.test.wizard.mocks;

+  uses:="org.eclipse.ui,

+   org.eclipse.core.resources,

+   org.eclipse.jface.viewers,

+   org.eclipse.swt.widgets,

+   org.eclipse.wst.sse.sieditor.ui.listeners,

+   org.eclipse.wst.sse.sieditor.ui.view,

+   org.eclipse.wst.sse.sieditor.fwk.mvp.ui"

+Bundle-ClassPath: .

+Eclipse-RegisterBuddy: org.eclipse.wst.sse.sieditor.ui

+Import-Package: org.eclipse.ui.editors.text,

+ org.eclipse.ui.texteditor

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/TEST-INF/testrun.xml b/plugins/org.eclipse.wst.sse.sieditor.test/TEST-INF/testrun.xml
new file mode 100644
index 0000000..c954fa3
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/TEST-INF/testrun.xml
@@ -0,0 +1,25 @@
+<test> 

+  

+

+  <run type="junit4_ec" purpose="component,scenario,weekstone,global">

+    <name>Service Interface And Data Types Editors</name>

+    <plugin-name>org.eclipse.wst.sse.sieditor.test</plugin-name>

+    <plugin-suite>org.eclipse.wst.sse.sieditor.test.all.AllTestSuites</plugin-suite>

+    <code-coverage>org.eclipse.wst.sse.sieditor.core;org.eclipse.wst.sse.sieditor.fwk;org.eclipse.wst.sse.sieditor.model;org.eclipse.wst.sse.sieditor.ui</code-coverage>

+    <mail>biser.tzvetkov@sap.com, georgi.konstantinov@sap.com</mail>

+	<timeout>1500</timeout> 

+   </run>

+   

+   <run type="junit4_ec" purpose="smoke,weekstone">

+    <name>SIEditor Smoke Test Suite: 1. Create Java Project and import WSDL Document 2. Check imported WSDl File 3. Add Service Interface

+    4. Add Operation with Input, Output and Fault Parameters 5. Add Namespace with Simple type, Complex Type with Element and Attribute types 

+    6. Save all created objects 7. Delete all created objects </name>

+    <plugin-name>org.eclipse.wst.sse.sieditor.test</plugin-name>

+    <plugin-suite>org.eclipse.wst.sse.sieditor.test.smoke.SIEditorSmokeTestSuite</plugin-suite>

+    <code-coverage>org.eclipse.wst.sse.sieditor.fwk;org.eclipse.wst.sse.sieditor.model;org.eclipse.wst.sse.sieditor.ui</code-coverage>

+    <mail>biser.tzvetkov@sap.com, georgi.konstantinov@sap.com</mail>

+	<timeout>1500</timeout> 

+   </run>

+

+ </test>

+

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/SIEditorTestsPlugin.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/SIEditorTestsPlugin.java
new file mode 100644
index 0000000..8c52c09
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/SIEditorTestsPlugin.java
@@ -0,0 +1,69 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test;

+

+import org.eclipse.core.runtime.Plugin;

+import org.osgi.framework.BundleContext;

+

+/**

+ * The activator class controls the plug-in life cycle

+ */

+@SuppressWarnings("nls")

+public class SIEditorTestsPlugin extends Plugin {

+

+    // The plug-in ID

+    public static final String PLUGIN_ID = "org.eclipse.wst.sse.sieditor.test";

+

+    // The shared instance

+    private static SIEditorTestsPlugin plugin;

+

+    /**

+     * The constructor

+     */

+    public SIEditorTestsPlugin() {

+    }

+

+    /*

+     * (non-Javadoc)

+     * 

+     * @see

+     * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)

+     */

+    public void start(BundleContext context) throws Exception {

+        super.start(context);

+        plugin = this;

+    }

+

+    /*

+     * (non-Javadoc)

+     * 

+     * @see

+     * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)

+     */

+    public void stop(BundleContext context) throws Exception {

+        plugin = null;

+        super.stop(context);

+    }

+

+    /**

+     * Returns the shared instance

+     * 

+     * @return the shared instance

+     */

+    public static SIEditorTestsPlugin getDefault() {

+        return plugin;

+    }

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/AllTestSuites.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/AllTestSuites.java
new file mode 100644
index 0000000..1f88e9f
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/AllTestSuites.java
@@ -0,0 +1,32 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.all;

+

+import org.eclipse.wst.sse.sieditor.test.smoke.SIEditorSmokeTestSuite;

+import org.junit.runner.RunWith;

+import org.junit.runners.Suite;

+import org.junit.runners.Suite.SuiteClasses;

+

+

+@RunWith(Suite.class)

+@SuiteClasses({

+	SIEditorSmokeTestSuite.class,

+	AllTestsSuiteStandalone.class,

+	UITestsSuite.class,

+	FutureBugzillaFixesTrackingTestsSuite.class

+})

+public class AllTestSuites {

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/AllTestsSuiteStandalone.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/AllTestsSuiteStandalone.java
new file mode 100644
index 0000000..18da6ad
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/AllTestsSuiteStandalone.java
@@ -0,0 +1,72 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.all;

+

+import org.eclipse.wst.sse.sieditor.test.core.editorfwk.ModelHandlerTest;

+import org.eclipse.wst.sse.sieditor.test.model.AbstractModelObjectFactoryTest;

+import org.eclipse.wst.sse.sieditor.test.model.EnsureSchemaCommandRepatchTest;

+import org.eclipse.wst.sse.sieditor.test.model.ModelTestsSuite;

+import org.eclipse.wst.sse.sieditor.test.model.TestWSTmodelInSyncWithDOM;

+import org.eclipse.wst.sse.sieditor.test.model.factory.DataTypesModelRootFactoryTest;

+import org.eclipse.wst.sse.sieditor.test.model.factory.ServiceInterfaceModelRootFactoryTest;

+import org.eclipse.wst.sse.sieditor.test.model.utils.EmfXsdUtilsTest;

+import org.eclipse.wst.sse.sieditor.test.model.utils.TestEmfWSDLUtils;

+import org.eclipse.wst.sse.sieditor.test.model.utils.TestResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.model.validation.constraints.ValidationTestsSuite;

+import org.eclipse.wst.sse.sieditor.test.model.xsd.ResolveImportedAndIncludedSchemasDefinitionsCommandsExecutionTest;

+import org.eclipse.wst.sse.sieditor.test.model.xsd.ResolveReferredSchemasCommandsExecutionTest;

+import org.eclipse.wst.sse.sieditor.test.model.xsd.XSDModelRootTest;

+import org.eclipse.wst.sse.sieditor.test.ui.TestXMLModelNotifierWrapper;

+import org.eclipse.wst.sse.sieditor.test.ui.XMLModelNotifierWrapperSingleTransactionTest;

+import org.eclipse.wst.sse.sieditor.test.wizard.WizardCreatorTest;

+import org.eclipse.wst.sse.sieditor.test.wizard.WizardTest;

+import org.eclipse.wst.sse.sieditor.test.wizard.WizardViewFactoryTest;

+import org.junit.runner.RunWith;

+import org.junit.runners.Suite;

+import org.junit.runners.Suite.SuiteClasses;

+

+

+

+/**

+ * 

+ * 

+ */

+@RunWith(Suite.class)

+@SuiteClasses({

+        ValidationTestsSuite.class,

+	ModelTestsSuite.class,

+	ModelCommandsTestSuite.class,

+	XSDModelRootTest.class,

+	TestSuiteForMVP.class,

+	WizardTest.class,

+	WizardCreatorTest.class,

+	WizardViewFactoryTest.class,

+	AbstractModelObjectFactoryTest.class,

+	ModelHandlerTest.class,

+	EmfXsdUtilsTest.class,

+	TestResourceUtils.class,

+	TestXMLModelNotifierWrapper.class,

+	XMLModelNotifierWrapperSingleTransactionTest.class,

+	TestWSTmodelInSyncWithDOM.class,

+	ResolveReferredSchemasCommandsExecutionTest.class,

+        ResolveImportedAndIncludedSchemasDefinitionsCommandsExecutionTest.class, 

+        EnsureSchemaCommandRepatchTest.class,

+        TestEmfWSDLUtils.class,

+        DataTypesModelRootFactoryTest.class,

+        ServiceInterfaceModelRootFactoryTest.class

+        

+})

+public class AllTestsSuiteStandalone {

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/FutureBugzillaFixesTrackingTestsSuite.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/FutureBugzillaFixesTrackingTestsSuite.java
new file mode 100644
index 0000000..a4ce11d
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/FutureBugzillaFixesTrackingTestsSuite.java
@@ -0,0 +1,29 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.all;

+

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.IncludeSchemaOnImportSchemaCommandXSDTest;

+import org.junit.runner.RunWith;

+import org.junit.runners.Suite;

+import org.junit.runners.Suite.SuiteClasses;

+

+

+@RunWith(Suite.class)

+@SuiteClasses( { 

+    IncludeSchemaOnImportSchemaCommandXSDTest.class

+})

+public class FutureBugzillaFixesTrackingTestsSuite {

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/ModelCommandsTestSuite.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/ModelCommandsTestSuite.java
new file mode 100644
index 0000000..2ffb482
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/ModelCommandsTestSuite.java
@@ -0,0 +1,298 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.all;

+

+import org.eclipse.wst.sse.sieditor.test.model.commands.TestRenamePartCommandWithMultiReferredPart;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.CompositeTextOperationWrapperNotifiesTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.CompositeTextOperationWrapperTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.NewElementTypeCompositeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.NewSimpleTypeCompositeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.NewStructureTypeCompositeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.TextCommandWrapperTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.integration.NewElementTypeCompositeCommandIntegrationTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.integration.NewSimpleTypeCompositeCommandIntegrationTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.integration.NewStructureTypeCompositeCommandIntegrationTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.setcommandbuilder.DefaultSetTypeCommandBuilderTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.common.settargetnamespace.SetTargetNamespaceTestsSuite;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddAsynchronousOperationCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddFaultCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddGlobalElementAndRenameToExistingOneCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddInParameterCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddMessageCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddMessageNoNSCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddNewSchemaBadDocCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddNewSchemaCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddNewSchemaEmptyDocCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddOutParameterCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddParameterTypeCommandNullTNSDocTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddServiceInterfaceAndOperationCommandBadDocTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddServiceInterfaceAndOperationCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddServiceInterfaceCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.AddSynchronousOperationCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeAsynchronousOperationTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeDefinitionTNSCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeDefinitionTNSEmptyDocCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeDefinitionTNSNullTNSCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeGlobalElementTypeCommandChainTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeSchemaImportsLocationCommandTest1;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeSchemaImportsLocationCommandTest2;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeSynchronousOperationTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeSynchronousOperationTypeCommandWithFaultsTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeToAsynchronousOperationTypeNoInputTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ChangeToAsynchronousOperationTypeNoMessageTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.CloneNamespaceCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.DeleteFaultCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.DeleteFaultParameterCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.DeleteInParameterCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.DeleteOutParameterCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.DeleteServiceInterfaceCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.DeleteServiceInterfaceWithOperationCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.EnsureWsdlDefinitionCommandJiberishContentTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.EnsureWsdlDefinitionCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ExtractDependentXmlSchemaTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ExtractRootXmlSchemaTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ImportSchemaCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ImportSchemaCommandUndoRedoTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.InlineNamespaceCompositeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.InlineNamespaceCompositeCommandTestWithAnnotations;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.ReconcilerCalledAfterInliningTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.RemoveSchemaCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.RemoveXsdImportToImportedTypesCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.RemoveXsdImportToReferedElementCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.RenameOperationCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.RenameParameterCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.RenameParameterInRpcStyleCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.RenameServiceInterfaceCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.SetDocumentationCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.SetFaultTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.SetParameterInWSDLWIthSpacesTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.SetParameterTypeCommandChangeFromExistingElementToTypeTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.SetParameterTypeCommandChangeFromMissingElementToTypeTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.SetParameterTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.SetParameterTypeImportFromNullTNSSchemaCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.SetUnwrappedParameterTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.SetWrappedParameterTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.extract.ExtractNamespaceRunnableWithImportTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.extract.ExtractNamespaceRunnableWithoutImportTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.extract.SchemaDependenciesUtilsTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.extract.XmlSchemaExtractorTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.facets.SetElementTypeCannotReuseFacetsCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.wsdl.facets.SetElementTypeReuseFacetsCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddAnotationToXSDAttributeDeclarationCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddAnotationToXSDAttributeDeclarationSimpleCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddAnotationToXSDElementDeclarationCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddAnotationToXSDSchemaImplCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddAttributeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddAttributeToComplexTypeSimpleContentTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddComplexTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddElementCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddEnumFacetToElementTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddEnumerationFacetCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddFacetCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddFacetToElementTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddGlobalElementCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddSchemaForSchemaXSDCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.AddSimpleTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.CopyElementCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.CopyElementCommandTestSimpleContent;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.CopyTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.DeleteFacetCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.EnsureSchemaElementCommandJiberishContentTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.EnsureSchemaElementCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.ImportSchemaCommandXSDTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.InlineStructureTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.MakeTypeAnonymousCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.MakeTypeGlobalCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.MakeTypeResolvableCommandElementDeclTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.MakeTypeResolvableCommandSimpleTypeTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.MakeTypeResolvableCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.OperationsOnRemovedObjectTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.RemoveGlobalElementCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.RemoveMixedSetCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.RenameComplexTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.RenameLocalElementCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.RenameSimpleTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetAttributeDefaultValueCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementComplexAnonymousTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementComplexTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementCustomSimpleTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementDefaultValueCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementImportedComplexTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementImportedPrimitiveTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementMaxOccursCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementMinOccursCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementNillableCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementPrimitiveTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementReferenceAnonymousTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementReferenceCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementSimpleAnonymousTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetElementTypeCommandXSDTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetNamespaceCommandAfterNoNamespaceExistsTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetNamespaceCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.SetStructureTypeCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.ToggleBetweenMakeTypeAnonymousAndMakeTypeGlobalCommandTest;

+import org.eclipse.wst.sse.sieditor.test.model.commands.xsd.setstructurebasetype.SetStructureTypeBaseTypeTestsSuite;

+import org.junit.runner.RunWith;

+import org.junit.runners.Suite;

+import org.junit.runners.Suite.SuiteClasses;

+

+

+@RunWith(Suite.class)

+@SuiteClasses( {

+    SetElementReferenceAnonymousTypeCommandTest.class,

+    SetElementSimpleAnonymousTypeCommandTest.class,

+    SetElementComplexAnonymousTypeCommandTest.class,

+    SetElementReferenceCommandTest.class,

+    SetElementComplexTypeCommandTest.class,

+    SetElementCustomSimpleTypeCommandTest.class,

+    SetElementPrimitiveTypeCommandTest.class,

+    SetElementMaxOccursCommandTest.class,

+    SetElementMinOccursCommandTest.class,

+    SetElementNillableCommandTest.class,

+    SetNamespaceCommandTest.class,

+    SetNamespaceCommandAfterNoNamespaceExistsTest.class,

+    RenameLocalElementCommandTest.class,

+    RenameSimpleTypeCommandTest.class,

+    RenameComplexTypeCommandTest.class,

+    RemoveGlobalElementCommandTest.class,

+    RemoveMixedSetCommandTest.class,

+    // ResolveImportedSchemaCommandTest.class,

+    DeleteFacetCommandTest.class,

+    AddFacetCommandTest.class,

+    AddEnumerationFacetCommandTest.class,

+    AddFacetToElementTest.class,

+    AddEnumFacetToElementTest.class,

+    AddComplexTypeCommandTest.class,

+    AddGlobalElementCommandTest.class,

+    /*

+     * AddAnotationToXSDTypeDefinitionCommandTest. class , - EXCLUDED UNTIL

+     * THE FEATURE IS FIXED

+     */

+    AddAnotationToXSDElementDeclarationCommandTest.class,

+    AddAnotationToXSDAttributeDeclarationCommandTest.class,

+    AddAnotationToXSDAttributeDeclarationSimpleCommandTest.class,

+    AddAnotationToXSDSchemaImplCommandTest.class,

+    AddSimpleTypeCommandTest.class,

+    AddElementCommandTest.class,

+    AddAttributeCommandTest.class,

+    AddAttributeToComplexTypeSimpleContentTest.class,

+    RemoveSchemaCommandTest.class,

+    RemoveXsdImportToReferedElementCommandTest.class,

+    RemoveXsdImportToImportedTypesCommandTest.class,

+    DeleteServiceInterfaceCommandTest.class,

+    DeleteServiceInterfaceWithOperationCommandTest.class,

+    DeleteOutParameterCommandTest.class,

+    DeleteInParameterCommandTest.class,

+    DeleteFaultParameterCommandTest.class,

+    DeleteFaultCommandTest.class,

+    ChangeAsynchronousOperationTypeCommandTest.class,

+    ChangeSynchronousOperationTypeCommandTest.class,

+    ChangeSynchronousOperationTypeCommandWithFaultsTest.class,

+    ChangeToAsynchronousOperationTypeNoInputTest.class,

+    ChangeToAsynchronousOperationTypeNoMessageTest.class,

+    AddServiceInterfaceCommandTest.class,

+    AddAsynchronousOperationCommandTest.class,

+    AddSynchronousOperationCommandTest.class,

+    AddNewSchemaCommandTest.class,

+    AddInParameterCommandTest.class,

+    AddOutParameterCommandTest.class,

+    SetWrappedParameterTypeCommandTest.class,

+    SetUnwrappedParameterTypeCommandTest.class,

+    AddFaultCommandTest.class,

+    RenameParameterCommandTest.class,

+    ChangeDefinitionTNSCommandTest.class,

+    RenameServiceInterfaceCommandTest.class,

+    RenameOperationCommandTest.class,

+    SetDocumentationCommandTest.class,

+    CopyElementCommandTest.class,

+    CopyElementCommandTestSimpleContent.class,

+    CopyTypeCommandTest.class,

+    MakeTypeResolvableCommandTest.class,

+    MakeTypeResolvableCommandSimpleTypeTest.class,

+    MakeTypeResolvableCommandElementDeclTest.class,

+    SetStructureTypeCommandTest.class,

+    SetElementImportedComplexTypeCommandTest.class,

+    SetElementImportedPrimitiveTypeCommandTest.class,

+    SetParameterTypeCommandTest.class,

+    SetParameterTypeCommandChangeFromExistingElementToTypeTest.class,

+    SetParameterTypeCommandChangeFromMissingElementToTypeTest.class,

+    SetParameterInWSDLWIthSpacesTest.class,

+    AddMessageCommandTest.class,

+    RenameParameterInRpcStyleCommandTest.class,

+    ImportSchemaCommandTest.class,

+    ChangeDefinitionTNSNullTNSCommandTest.class,

+    ImportSchemaCommandUndoRedoTest.class,

+    SetParameterTypeImportFromNullTNSSchemaCommandTest.class,

+    AddParameterTypeCommandNullTNSDocTest.class,

+    SetFaultTypeCommandTest.class,

+    DefaultSetTypeCommandBuilderTest.class,

+    NewElementTypeCompositeCommandTest.class,

+    NewSimpleTypeCompositeCommandTest.class,

+    NewStructureTypeCompositeCommandTest.class,

+    NewElementTypeCompositeCommandIntegrationTest.class,

+    NewSimpleTypeCompositeCommandIntegrationTest.class,

+    NewStructureTypeCompositeCommandIntegrationTest.class,

+    TextCommandWrapperTest.class,

+    AddServiceInterfaceAndOperationCommandBadDocTest.class,

+    AddServiceInterfaceAndOperationCommandTest.class,

+    EnsureWsdlDefinitionCommandJiberishContentTest.class,

+    EnsureWsdlDefinitionCommandTest.class,

+    ChangeDefinitionTNSEmptyDocCommandTest.class,

+    AddNewSchemaEmptyDocCommandTest.class,

+    AddNewSchemaBadDocCommandTest.class,

+    AddSchemaForSchemaXSDCommandTest.class,

+    EnsureSchemaElementCommandTest.class,

+    EnsureSchemaElementCommandJiberishContentTest.class,

+    ImportSchemaCommandXSDTest.class,

+    SetElementTypeCommandXSDTest.class,

+    OperationsOnRemovedObjectTest.class,

+    AddMessageNoNSCommandTest.class,

+

+    SetElementTypeCannotReuseFacetsCommandTest.class,

+    SetElementTypeReuseFacetsCommandTest.class,

+    TestRenamePartCommandWithMultiReferredPart.class,

+    MakeTypeGlobalCommandTest.class,

+    MakeTypeAnonymousCommandTest.class,

+    InlineStructureTypeCommandTest.class,

+    ToggleBetweenMakeTypeAnonymousAndMakeTypeGlobalCommandTest.class,

+

+    SetTargetNamespaceTestsSuite.class,

+    CompositeTextOperationWrapperTest.class,

+    AddGlobalElementAndRenameToExistingOneCommandTest.class,

+

+    ExtractNamespaceRunnableWithoutImportTest.class,

+    ExtractNamespaceRunnableWithImportTest.class,

+    SchemaDependenciesUtilsTest.class,

+    XmlSchemaExtractorTest.class,

+    ChangeSchemaImportsLocationCommandTest1.class,

+    ChangeSchemaImportsLocationCommandTest2.class,

+    ExtractDependentXmlSchemaTest.class,

+    ExtractRootXmlSchemaTest.class,

+    CloneNamespaceCommandTest.class,

+    InlineNamespaceCompositeCommandTest.class,

+    InlineNamespaceCompositeCommandTestWithAnnotations.class,

+

+    SetStructureTypeBaseTypeTestsSuite.class,

+    CompositeTextOperationWrapperNotifiesTest.class,

+

+    SetAttributeDefaultValueCommandTest.class,

+    SetElementDefaultValueCommandTest.class,

+    ReconcilerCalledAfterInliningTest.class,

+    ChangeGlobalElementTypeCommandChainTest.class

+    })

+public class ModelCommandsTestSuite {

+    public ModelCommandsTestSuite() {

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/TestSuiteForMVP.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/TestSuiteForMVP.java
new file mode 100644
index 0000000..5f5091a
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/TestSuiteForMVP.java
@@ -0,0 +1,39 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.all;

+import org.eclipse.wst.sse.sieditor.test.fwk.mvp.ui.BasePresenterTest;

+import org.eclipse.wst.sse.sieditor.test.fwk.mvp.ui.DefaultPresenterTest;

+import org.eclipse.wst.sse.sieditor.test.fwk.mvp.ui.ViewDelegateTest;

+import org.junit.runner.RunWith;

+import org.junit.runners.Suite;

+

+

+

+/**

+ *  

+ *  Adding MVP TestCase class into the suite class.

+ */

+

+@RunWith(Suite.class)

+@Suite.SuiteClasses( { 

+	BasePresenterTest.class,

+	DefaultPresenterTest.class,

+	ViewDelegateTest.class

+	//WorkbenchPartTest.class

+	                 }

+		)

+public class TestSuiteForMVP {

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/UITestsSuite.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/UITestsSuite.java
new file mode 100644
index 0000000..40253e0
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/all/UITestsSuite.java
@@ -0,0 +1,284 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.all;

+

+import org.eclipse.wst.sse.sieditor.test.core.common.TestDisposableInstances;

+import org.eclipse.wst.sse.sieditor.test.model.commands.TestUndoRedoInSourceAndEMF;

+import org.eclipse.wst.sse.sieditor.test.ui.TestAbstractDetailsPage;

+import org.eclipse.wst.sse.sieditor.test.ui.TestServiceInterfaceEditor;

+import org.eclipse.wst.sse.sieditor.test.ui.preferences.TestServiceInterfaceEditorPreferencePage;

+import org.eclipse.wst.sse.sieditor.test.ui.readonly.CommonDocumentationSectionReadOnlyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.readonly.ElementNodeDetailsControllerReadOnlyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.readonly.SIFormPageControllerReadOnlyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.AbstractEditorWithSourcePageUndoHandlersDisposeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.DataTypesLabelProviderPlugInTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.EditorTitleMessagesManagerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.ProblemDecoratorTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.TestSetSelectionInDTPageFromSourcePageWithDTE;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.TestSetSelectionInSIPageFromSourcePageWithSIE;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.TestSetSelectionInSourceWithDataTypesEditor;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.TestSetSelectionInSourceWithSIEditor;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.TestTypePropertyEditorHyperLinkSelection;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.TestTypeSearchDialog;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.propertyEditor.ElementTypeEditorTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.propertyEditor.FaultTypeEditorTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.common.propertyEditor.ParameterTypeEditorTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.AbstractFormPageControllerPluginTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.AbstractFormPageControllerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.CreateSearchListProviderTests;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.DTTreeContextMenuListenerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.DataTypesContentProviderTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.DataTypesDetailsPageProviderTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.DataTypesEditorPageTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.DataTypesFormPageControllerJUnitTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.DataTypesFormPageControllerPlugInTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.DataTypesLabelProviderTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.DataTypesMasterDetailsBlockPlugInTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.DataTypesMasterDetailsBlockTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.NamespaceDetailsPageTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.SetNewTypeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.SiEditorDataTypesFormPageControllerPlugInTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.SiEditorDataTypesFormPageControllerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.SimpleTypeFacetsUtilsFacetsVisibleTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.SimpleTypeFacetsUtilsPatternsTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.SimpleTypeFacetsUtilsProjectTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.StandaloneDtEditorPageNSReadOnlyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.StructureNodeDetailsPageTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.TestElementNodeDetailsPage;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.TestTypeNullNameAttribute;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.extract.ExtractNamespaceWizardTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.extract.ExtractSchemaTextFieldModifyListenerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.impl.ElementNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.impl.ImportedSchemaNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.impl.ImportedTypesNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.impl.NamespaceNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.impl.SimpleTypeNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.impl.StructureTypeNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.labels.DTTreeNodeLabelsProviderFactoryTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.labels.DataTypesTreeNodesLabelsPovider_BrokenElements_Test;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.nodes.labels.DataTypesTreeNodesLabelsPovider_ValidElements_Test;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor.TypePropertyEditorTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor.selectionlisteners.AbstractTypePropertyEditorEventListenerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor.selectionlisteners.TypePropertyEditorBrowseButtonSelectionListenerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor.selectionlisteners.TypePropertyEditorNewButtonSelectionListenerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor.selectionlisteners.TypePropertyEditorTypeComboEventListenerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor.typecommitters.ElementTypeEditorTypeCommitterTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.dt.propertyEditor.typecommitters.ParameterTypeEditorTypeCommitterTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.factory.TestTreeNodeMapper;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.newtypedialog.AbstractTypeDialogStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.newtypedialog.FaultTypeDialogStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.newtypedialog.GlobalElementDialogStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.newtypedialog.LocalElementDialogStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.newtypedialog.NewTypeDialogTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.newtypedialog.ParameterTypeDialogStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.newtypedialog.SimpleTypeDialogStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.nodes.impl.AbstractTreeNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.providers.TestWSDLContentProvider;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.providers.TestWSDLDetailsPageProvider;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.providers.TestWSDLLabelProvider;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.resources.TestCanEditResource;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.resources.TestIsSetEditValidatorWhenCreateModel;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.resources.TestModelFileMoved;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.resources.TestModelRevertToSaved;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.AbstractDetailsPageSectionTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.DocumentationSectionTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.ElementDetailsSectionRefreshFromRefToNonRefReLayoutTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.NamespaceDetailsSectionTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.StructureDetailsSectionTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.TestElementConstraintsController;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.TestElementDetailsSection;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.TestSimpleTypeConstraintsSection;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.TestTypePropertyEditor;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.elements.AttributeStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.elements.ElementNodeDetailsControllerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.elements.ElementOfAnonymousTypeStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.elements.ElementOfGlobalTypeStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.elements.ElementRefToGlobalElementStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.elements.GlobalElementStrategyTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.tables.editing.EnumsTableEditingSupportTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.sections.tables.editing.PatternsTableEditingSupportTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.typeselect.DescriptionTypeResolverTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.typeselect.SIEditorSearchListProviderTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.typeselect.SchemaTypeResolverTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.typeselect.TypeSelectionDialogDelegateTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.AbstractMasterDetailsBlockTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.ServiceIntefaceEditorPageTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.TreeViewerSelectionListenerTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.controller.TestGetReferencedServices;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.controller.TestImportedSchemaNodes;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.controller.TestImportedServicesNodes;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.controller.TestSIFormPageController;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.detailspages.TestOperationDetailsPage;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.detailspages.TestParameterDetailsPage;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.detailspages.TestServiceInterfaceDetailsPage;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdl.formpage.TestSIMasterDetailsBlock;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.TestIsEditorActivationInTreeViewerEditorActivationStrategy;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.TestSITreeContextMenuListener;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.TestSITreeViewerCellModifier;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.TestSITreeViewerEditorActivationStrategy;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.actionenablement.TestSIEActionEnablementForSelectionManager;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.nodes.FaultNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.nodes.ImportedServiceNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.nodes.OperationCategoryNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.nodes.OperationNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.nodes.ParameterNodeTest;

+import org.eclipse.wst.sse.sieditor.test.ui.v2.wsdltree.nodes.labels.SITreeNodeLabelsProviderFactoryTest;

+import org.eclipse.wst.sse.sieditor.test.v2.ui.editor.MissingSchemaElementQuickfixTest;

+import org.eclipse.wst.sse.sieditor.test.v2.ui.editor.MissingSchemaForSchemaQuickFixTest;

+import org.eclipse.wst.sse.sieditor.test.v2.ui.editor.MultipageEditorTest;

+import org.eclipse.wst.sse.sieditor.test.v2.ui.editor.NonUIThreadOpenEditorTest;

+import org.eclipse.wst.sse.sieditor.test.v2.ui.editor.OpenEditorWithUnusedImportTest;

+import org.eclipse.wst.sse.sieditor.test.v2.ui.editor.SIEditorRefresNullTNS;

+import org.junit.runner.RunWith;

+import org.junit.runners.Suite;

+import org.junit.runners.Suite.SuiteClasses;

+

+

+

+@RunWith(Suite.class)

+@SuiteClasses( { 

+    MissingSchemaForSchemaQuickFixTest.class, 

+    MultipageEditorTest.class, 

+    OpenEditorWithUnusedImportTest.class,

+    NonUIThreadOpenEditorTest.class, 

+    DataTypesDetailsPageProviderTest.class,

+    DataTypesContentProviderTest.class, 

+    DataTypesEditorPageTest.class,

+    DataTypesLabelProviderTest.class, 

+    DataTypesMasterDetailsBlockTest.class, 

+    DataTypesMasterDetailsBlockPlugInTest.class,

+    DataTypesFormPageControllerJUnitTest.class, 

+    DataTypesFormPageControllerPlugInTest.class,

+    SiEditorDataTypesFormPageControllerTest.class, 

+    SiEditorDataTypesFormPageControllerPlugInTest.class,

+    ServiceIntefaceEditorPageTest.class, 

+    StandaloneDtEditorPageNSReadOnlyTest.class, 

+    DTTreeContextMenuListenerTest.class,

+    AbstractFormPageControllerTest.class, 

+    ElementNodeTest.class, 

+    ImportedSchemaNodeTest.class, 

+    ImportedTypesNodeTest.class,

+    NamespaceNodeTest.class, 

+    SimpleTypeNodeTest.class, 

+    StructureTypeNodeTest.class, 

+    DataTypesTreeNodesLabelsPovider_ValidElements_Test.class,

+    DataTypesTreeNodesLabelsPovider_BrokenElements_Test.class,

+    DTTreeNodeLabelsProviderFactoryTest.class,

+    AbstractTreeNodeTest.class,

+    NamespaceDetailsSectionTest.class, 

+    NamespaceDetailsPageTest.class, 

+    StructureNodeDetailsPageTest.class,

+    StructureDetailsSectionTest.class, 

+    DocumentationSectionTest.class, 

+    AbstractDetailsPageSectionTest.class,

+    AbstractTypePropertyEditorEventListenerTest.class,

+    TypePropertyEditorBrowseButtonSelectionListenerTest.class,

+    TypePropertyEditorNewButtonSelectionListenerTest.class,

+    TypePropertyEditorTypeComboEventListenerTest.class,

+    ElementTypeEditorTypeCommitterTest.class,

+    ParameterTypeEditorTypeCommitterTest.class,

+    TypePropertyEditorTest.class, 

+    CommonDocumentationSectionReadOnlyTest.class, 

+    SimpleTypeFacetsUtilsFacetsVisibleTest.class,

+    SimpleTypeFacetsUtilsPatternsTest.class,

+    SimpleTypeFacetsUtilsProjectTest.class, 

+    ImportedServiceNodeTest.class,

+    FaultNodeTest.class,

+    OperationCategoryNodeTest.class, 

+    OperationNodeTest.class,

+    ParameterNodeTest.class, 

+    SITreeNodeLabelsProviderFactoryTest.class,

+    TestWSDLContentProvider.class, 

+    TestWSDLDetailsPageProvider.class, 

+    TestWSDLLabelProvider.class,

+    TestSIFormPageController.class, 

+    SIFormPageControllerReadOnlyTest.class, 

+    ElementNodeDetailsControllerReadOnlyTest.class, 

+    TestSITreeContextMenuListener.class, 

+    TestSITreeViewerCellModifier.class,

+    TestSITreeViewerEditorActivationStrategy.class, 

+    TestOperationDetailsPage.class, 

+    TestParameterDetailsPage.class,

+    TestServiceInterfaceDetailsPage.class, 

+    TestTypeSearchDialog.class, 

+    TestElementDetailsSection.class,

+    EnumsTableEditingSupportTest.class,

+    PatternsTableEditingSupportTest.class,

+    TestSimpleTypeConstraintsSection.class, 

+    TestTypePropertyEditor.class, 

+    NewTypeDialogTest.class,

+    LocalElementDialogStrategyTest.class, 

+    FaultTypeDialogStrategyTest.class, 

+    GlobalElementDialogStrategyTest.class,

+    ParameterTypeDialogStrategyTest.class, 

+    SimpleTypeDialogStrategyTest.class, 

+    AttributeStrategyTest.class,

+    ElementNodeDetailsControllerTest.class, 

+    ElementOfGlobalTypeStrategyTest.class, 

+    AbstractTypeDialogStrategyTest.class,

+    ElementRefToGlobalElementStrategyTest.class, 

+    GlobalElementStrategyTest.class, 

+    ElementOfAnonymousTypeStrategyTest.class,

+    TestElementNodeDetailsPage.class, 

+    TestAbstractDetailsPage.class, 

+    DescriptionTypeResolverTest.class,

+    SchemaTypeResolverTest.class, 

+    AbstractEditorWithSourcePageUndoHandlersDisposeTest.class, 

+    TestModelRevertToSaved.class,

+    TestCanEditResource.class, 

+    ElementTypeEditorTest.class, 

+    ParameterTypeEditorTest.class, 

+    FaultTypeEditorTest.class,

+    SIEditorSearchListProviderTest.class, 

+    ProblemDecoratorTest.class, 

+    TestTypeNullNameAttribute.class, 

+    DataTypesLabelProviderPlugInTest.class,

+    TestServiceInterfaceEditorPreferencePage.class, 

+    TestImportedServicesNodes.class,

+    AbstractFormPageControllerPluginTest.class, 

+    TestImportedSchemaNodes.class, 

+    CreateSearchListProviderTests.class,

+    TestElementConstraintsController.class, 

+    TestGetReferencedServices.class, 

+    TypeSelectionDialogDelegateTest.class,

+    SIEditorRefresNullTNS.class,

+    TestUndoRedoInSourceAndEMF.class,

+    SetNewTypeTest.class,

+    AbstractMasterDetailsBlockTest.class,

+    TestTreeNodeMapper.class,

+    MissingSchemaElementQuickfixTest.class,

+    TestModelFileMoved.class,

+    TreeViewerSelectionListenerTest.class,

+    TestSIMasterDetailsBlock.class,

+    TestIsEditorActivationInTreeViewerEditorActivationStrategy.class,

+    ElementDetailsSectionRefreshFromRefToNonRefReLayoutTest.class,

+    TestSIEActionEnablementForSelectionManager.class,

+    TestServiceInterfaceEditor.class,

+    

+    EditorTitleMessagesManagerTest.class,

+    TestIsSetEditValidatorWhenCreateModel.class,

+    TestDisposableInstances.class,

+    TestSetSelectionInSourceWithDataTypesEditor.class,

+    TestSetSelectionInSourceWithSIEditor.class,

+    

+    ExtractNamespaceWizardTest.class,

+    ExtractSchemaTextFieldModifyListenerTest.class,

+    TestSetSelectionInDTPageFromSourcePageWithDTE.class,

+    TestSetSelectionInSIPageFromSourcePageWithSIE.class,

+    TestTypePropertyEditorHyperLinkSelection.class

+})

+public class UITestsSuite {

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/common/TestDisposableInstances.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/common/TestDisposableInstances.java
new file mode 100644
index 0000000..95252f3
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/common/TestDisposableInstances.java
@@ -0,0 +1,98 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.core.common;

+

+import java.io.IOException;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.emf.common.command.BasicCommandStack;

+import org.eclipse.emf.common.command.CommandStack;

+import org.eclipse.ui.PartInitException;

+import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;

+import org.eclipse.wst.sse.core.internal.undo.IStructuredTextUndoManager;

+import org.eclipse.wst.sse.sieditor.model.validation.ValidationService;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.eclipse.wst.sse.sieditor.test.util.ThreadUtils;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.core.common.IDisposable;

+import org.eclipse.wst.sse.sieditor.model.XMLModelNotifierWrapper;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.reconcile.adapters.AnnotationsReconcileAdapter;

+import org.eclipse.wst.sse.sieditor.model.reconcile.adapters.AttributesReconcileAdapter;

+import org.eclipse.wst.sse.sieditor.model.reconcile.adapters.ElementsReconcileAdapter;

+import org.eclipse.wst.sse.sieditor.model.reconcile.adapters.TransactionalWSDLModelStateListener;

+import org.eclipse.wst.sse.sieditor.model.utils.CommandStackWrapper;

+import org.eclipse.wst.sse.sieditor.model.utils.EnvironmentFactory;

+import org.eclipse.wst.sse.sieditor.ui.ServiceInterfaceEditor;

+

+public class TestDisposableInstances extends SIEditorBaseTest {

+	

+	private final static Class EXPECTED_DISPOSABLES_IN_REGISTRY[] = {

+		AnnotationsReconcileAdapter.class,

+		AttributesReconcileAdapter.class,

+		ElementsReconcileAdapter.class,

+		CommandStackWrapper.class,

+		TransactionalWSDLModelStateListener.class,

+		ValidationService.class,

+		XMLModelNotifierWrapper.class};

+

+	@Test

+	public void testDisposedAfterEditorIsClosed() throws PartInitException, IOException, CoreException {

+		IWsdlModelRoot wsdlModelRoot = (IWsdlModelRoot) getModelRoot("pub/simple/NewWSDLFile.wsdl", "NewWSDLFile.wsdl", ServiceInterfaceEditor.EDITOR_ID);

+		EnvironmentFactory.EnvironmentImpl env = (EnvironmentFactory.EnvironmentImpl)wsdlModelRoot.getEnv();

+		

+		CommandStack currentCommandStack = editor.getStructuredModel().getUndoManager().getCommandStack();

+		assertEquals(CommandStackWrapper.class, currentCommandStack.getClass());

+		

+		// All disposables should exist in the registry

+		boolean disposableInstanceFound = false;

+		for(Class expectedDisposable : EXPECTED_DISPOSABLES_IN_REGISTRY) {

+			disposableInstanceFound = false;

+			for(IDisposable disposable : env.getRegistryOfDisposables()) {

+				if(expectedDisposable.equals(disposable.getClass())) {

+					disposableInstanceFound = true;

+					break;

+				}

+			}

+			assertTrue("Missing disposable instance from env. registry. Missing instance of class:" + expectedDisposable, 

+					disposableInstanceFound);

+		}

+		

+		// Register a test disposable to ensure its method is called

+		final boolean disposeCalled[] = {false};

+		env.addDisposable(new IDisposable() {

+			

+			@Override

+			public void doDispose() {

+				disposeCalled[0] = true;

+			}

+		});

+		

+		// get undo manager before closing the editor

+		IStructuredModel structuredModel = editor.getStructuredModel();

+		IStructuredTextUndoManager undoManager = structuredModel.getUndoManager();

+		

+		// close the editor - here all disposables should be disposed

+		editor.close(false);

+		ThreadUtils.waitOutOfUI(10);

+		

+		assertTrue("Closing editor does not dispose instances in environment registry of disposables.",

+				disposeCalled[0]);

+		

+		currentCommandStack = undoManager.getCommandStack();

+		assertEquals(BasicCommandStack.class, currentCommandStack.getClass());

+	}

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/editorfwk/ModelHandlerTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/editorfwk/ModelHandlerTest.java
new file mode 100644
index 0000000..3a38f86
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/core/editorfwk/ModelHandlerTest.java
@@ -0,0 +1,98 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.core.editorfwk;

+

+import java.io.BufferedInputStream;

+import java.io.IOException;

+

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetNamespaceCommand;

+import org.eclipse.wst.sse.sieditor.core.common.IEnvironment;

+import org.eclipse.wst.sse.sieditor.core.editorfwk.IModelObject;

+import org.eclipse.wst.sse.sieditor.core.editorfwk.ModelHandler;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+

+public class ModelHandlerTest extends SIEditorBaseTest {

+

+    @Test

+    public void testLoadXSDfromFile() throws IOException, CoreException {

+        final IFile file = ResourceUtils.copyFileIntoTestProject("pub/xsd/example.xsd", Document_FOLDER_NAME, this.getProject(),

+                "example.xsd");

+        refreshProjectNFile(file);

+

+        StringBuffer sb = new StringBuffer();

+        BufferedInputStream bis = new BufferedInputStream(file.getContents());

+        int readedByte;

+        while ((readedByte = bis.read()) > 0) {

+            sb.append((char) readedByte);

+        }

+

+        String fileContent = sb.toString();

+        IModelObject modelObject = ModelHandler.retrieveModelObject(fileContent, file.getLocationURI().toString());

+

+        assertTrue(modelObject instanceof IXSDModelRoot);

+    }

+

+    @Test

+    public void testLoadWSDLfromFile() throws IOException, CoreException {

+        final IFile file = ResourceUtils.copyFileIntoTestProject("pub/self/mix2/ChangePurchaseOrder_WSD.wsdl",

+                Document_FOLDER_NAME, this.getProject(), "ChangePurchaseOrder_WSD.wsdl");

+        refreshProjectNFile(file);

+

+        StringBuffer sb = new StringBuffer();

+        BufferedInputStream bis = new BufferedInputStream(file.getContents());

+        int readedByte;

+        while ((readedByte = bis.read()) > 0) {

+            sb.append((char) readedByte);

+        }

+

+        String fileContent = sb.toString();

+        IModelObject modelObject = ModelHandler.retrieveModelObject(fileContent, file.getLocationURI().toString());

+

+        assertTrue(modelObject instanceof IWsdlModelRoot);

+    }

+

+    @Test

+    public void testOperationHistoryNotClearedAfterRetrivingModelObject() throws IOException, CoreException, ExecutionException {

+        IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("pub/self/mix2/ChangePurchaseOrder_WSD.wsdl",

+                "ChangePurchaseOrder_WSD.wsdl");

+        final IFile file = ResourceUtils.copyFileIntoTestProject("pub/xsd/example.xsd", Document_FOLDER_NAME, this.getProject(),

+                "example.xsd");

+        refreshProjectNFile(file);

+

+        IDescription description = wsdlModelRoot.getDescription();

+        ISchema schema = description.getSchema("http://sap.com/xi/SAPGlobal20/Global")[0];

+        SetNamespaceCommand cmd = new SetNamespaceCommand(wsdlModelRoot, schema, "testChange");

+        IEnvironment env = wsdlModelRoot.getEnv();

+        assertEquals(Status.OK_STATUS, env.execute(cmd));

+        assertEquals(1, env.getOperationHistory().getUndoHistory(env.getUndoContext()).length);

+        assertTrue(env.getOperationHistory().canUndo(env.getUndoContext()));

+

+        ModelHandler.retrieveModelObject(env, URI.createFileURI(file.getLocation().toOSString()), false);

+        assertEquals(1, env.getOperationHistory().getUndoHistory(env.getUndoContext()).length);

+        assertTrue(env.getOperationHistory().canUndo(env.getUndoContext()));

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/Argument.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/Argument.java
new file mode 100644
index 0000000..e77600e
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/Argument.java
@@ -0,0 +1,41 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport;

+

+/**

+ * 

+ * @param <T>

+ */

+public class Argument<T> {

+

+    private T t;

+

+    /**

+     * Returns the value.

+     * 

+     * @return The arguments value or <code>null</code>

+     */

+    public T getValue() {

+        return t;

+    }

+

+    /**

+     * @param t

+     *            The value to set

+     */

+    public void setValue(final T t) {

+        this.t = t;

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/Arguments.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/Arguments.java
new file mode 100644
index 0000000..eaf8b15
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/Arguments.java
@@ -0,0 +1,60 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport;

+

+import org.easymock.EasyMock;

+import org.easymock.IArgumentMatcher;

+

+/**

+ * 

+ */

+public class Arguments {

+

+    private static final class AnyArgumentMatcher<T> implements

+        IArgumentMatcher {

+

+        private final Argument<T> argument;

+

+        AnyArgumentMatcher(final Argument<T> argument) {

+            this.argument = argument;

+        }

+

+        public void appendTo(final StringBuffer buffer) {

+            buffer.append("<any argument>"); //$NON-NLS-1$

+        }

+

+        @SuppressWarnings("unchecked")

+        public boolean matches(final Object o) {

+            argument.setValue((T) o);

+            return true;

+        }

+    }

+

+    /**

+     * Creates and registers a argument matcher which matches any argument. The

+     * argument matcher is composed with the given {@link Argument} and saves

+     * the parameter into the argument.

+     * 

+     * @param <T>

+     * @param argument

+     *            The argument where to store the parameter while

+     *            {@link IArgumentMatcher#matches(Object)} is called.

+     * @return <code>null</code>

+     */

+    public static <T> T any(final Argument<T> argument) {

+        EasyMock.reportMatcher(new AnyArgumentMatcher<T>(argument));

+        return null;

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/ui/AbstractPresenterTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/ui/AbstractPresenterTest.java
new file mode 100644
index 0000000..9b76d80
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/ui/AbstractPresenterTest.java
@@ -0,0 +1,71 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport.ui;

+

+import static org.easymock.EasyMock.expect;

+

+import org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport.Argument;

+import org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport.Arguments;

+

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.IView;

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.IViewListener;

+

+/**

+ * This abstract base class for presenter tests allows the test to easy fire

+ * view- open and dispose lifecycle events to the presenter.

+ * 

+ * 

+ */

+public abstract class AbstractPresenterTest {

+

+    /**

+     * 

+     */

+    protected Argument<IViewListener> viewListener;

+

+    /**

+     * Fires a view created event to the presenter. Ensure that

+     * {@link AbstractPresenterTest#setUpViewExpectations(IView)} is called

+     * before.

+     * 

+     * @param view

+     */

+    protected void fireViewCreated(final IView view) {

+        viewListener.getValue().viewCreated(view);

+    }

+

+    /**

+     * Fires a view disposed event to the presenter. Ensure that

+     * {@link AbstractPresenterTest#setUpViewExpectations(IView)} is called

+     * before.

+     * 

+     * @param view

+     */

+    protected void fireViewDisposed(final IView view) {

+        viewListener.getValue().viewDispose(view);

+    }

+

+    /**

+     * Sets up the expectation that view.addViewListener is called and saves the

+     * listener in an {@link Argument}.

+     * 

+     * @param view

+     */

+    protected void setUpViewExpectations(final IView view) {

+        viewListener = new Argument<IViewListener>();

+        expect(view.addViewListener(Arguments.any(viewListener))).andReturn(

+            true);

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/ui/SwtTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/ui/SwtTest.java
new file mode 100644
index 0000000..90f2172
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/testsupport/ui/SwtTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport.ui;

+

+import org.eclipse.swt.widgets.Display;

+

+/**

+ * Base test for SWT tests giving subclasses access to protected a

+ * {@link Display} field.

+ * 

+ * 

+ */

+public class SwtTest {

+

+    /**

+     * {@link Display} instance for usage in the tests. Will be created in

+     * {@link #setUp()} and closed in {@link #tearDown()}.

+     */

+    protected Display display;

+

+    /**

+     * Creates a {@link Display}.

+     * 

+     * @throws Exception

+     *             Any exception.

+     */

+    public void setUp() throws Exception {

+        display = Display.getDefault();

+    }

+

+    /**

+     * Closes the {@link Display}.

+     * 

+     * @throws Exception

+     *             Any exception.

+     */

+    public void tearDown() throws Exception {

+        if (display != null) {

+            display.close();

+        }

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/ui/BasePresenterTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/ui/BasePresenterTest.java
new file mode 100644
index 0000000..207f652
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/ui/BasePresenterTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.fwk.mvp.ui;

+

+import static org.easymock.EasyMock.createNiceMock;

+import static org.junit.Assert.assertNotNull;

+import static org.junit.Assert.assertSame;

+import static org.junit.Assert.assertTrue;

+

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.BasePresenter;

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.IView;

+

+import org.junit.Before;

+import org.junit.Test;

+

+/**

+ * 

+ */

+public class BasePresenterTest {

+

+    private final class MockPresenter extends BasePresenter<IView> {

+

+        private boolean isAttachViewListenersCalled;

+

+        MockPresenter(final IView view) {

+            super(view);

+        }

+

+        @Override

+        protected void attachViewListeners() {

+            isAttachViewListenersCalled = true;

+        }

+    }

+

+    private MockPresenter mockPresenter;

+

+    private IView view;

+

+    @Before

+    public void setUp() throws Exception {

+        view = createNiceMock(IView.class);

+        mockPresenter = new MockPresenter(view);

+    }

+

+    @Test

+    public void testBasePresenter() {

+        assertTrue(mockPresenter.isAttachViewListenersCalled);

+        assertNotNull(mockPresenter.getView());

+        assertSame(view, mockPresenter.getView());

+    }

+

+    @Test(expected = IllegalArgumentException.class)

+    public void testBasePresenterEx() {

+        new BasePresenter<IView>(null) {

+

+            @Override

+            protected void attachViewListeners() {

+            }

+        };

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/ui/DefaultPresenterTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/ui/DefaultPresenterTest.java
new file mode 100644
index 0000000..f7494bc
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/ui/DefaultPresenterTest.java
@@ -0,0 +1,107 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.fwk.mvp.ui;

+

+import static org.easymock.EasyMock.createMock;

+import static org.easymock.EasyMock.expect;

+import static org.easymock.EasyMock.replay;

+import static org.easymock.EasyMock.verify;

+import static org.junit.Assert.assertSame;

+import static org.junit.Assert.assertTrue;

+

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.DefaultPresenter;

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.IView;

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.IViewListener;

+

+import org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport.Argument;

+import org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport.Arguments;

+import org.eclipse.wst.sse.sieditor.test.fwk.mvp.testsupport.ui.AbstractPresenterTest;

+import org.junit.Before;

+import org.junit.Test;

+

+/**

+ * 

+ */

+public class DefaultPresenterTest extends AbstractPresenterTest {

+

+    private final class MockDefaultPresenter<T extends IView> extends

+        DefaultPresenter<IView> {

+

+        private boolean isHandleViewCreatedCalled;

+

+        private boolean isHandleViewDisposeCalled;

+

+        public MockDefaultPresenter(final IView view) {

+            super(view);

+        }

+

+        @Override

+        protected void handleViewCreated(final IView view) {

+            super.handleViewCreated(view);

+            isHandleViewCreatedCalled = true;

+        }

+

+        @Override

+        protected void handleViewDispose(final IView view) {

+            isHandleViewDisposeCalled = true;

+            super.handleViewDispose(view);

+        }

+    }

+

+    private MockDefaultPresenter<IView> mockDefaultPresenter;

+

+    private Argument<IViewListener> removeViewListenerArgument;

+

+    private IView view;

+

+    @Before

+    public void setUp() {

+        view = createMock(IView.class);

+        removeViewListenerArgument = new Argument<IViewListener>();

+        setUpViewExpectations(view);

+    }

+

+    @Test

+    public void testAttachViewListeners() {

+        replay(view);

+        mockDefaultPresenter = new MockDefaultPresenter<IView>(view);

+        verify(view);

+    }

+

+    @Test

+    public void testHandleViewCreated() {

+        replay(view);

+        mockDefaultPresenter = new MockDefaultPresenter<IView>(view);

+        fireViewCreated(view);

+        assertTrue(mockDefaultPresenter.isHandleViewCreatedCalled);

+        verify(view);

+    }

+

+    @Test

+    public void testHandleViewDispose() {

+        expect(

+            view.removeViewListener(Arguments.any(removeViewListenerArgument)))

+            .andReturn(true);

+        replay(view);

+        mockDefaultPresenter = new MockDefaultPresenter<IView>(view);

+

+        //        addViewListenerArgument.getValue().viewDispose(view);

+        fireViewDisposed(view);

+        assertTrue(mockDefaultPresenter.isHandleViewDisposeCalled);

+        assertSame(viewListener.getValue(), removeViewListenerArgument

+            .getValue());

+        verify(view);

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/ui/ViewDelegateTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/ui/ViewDelegateTest.java
new file mode 100644
index 0000000..3d12ab9
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/fwk/mvp/ui/ViewDelegateTest.java
@@ -0,0 +1,151 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.fwk.mvp.ui;

+

+import static org.easymock.EasyMock.createMock;

+import static org.easymock.EasyMock.expect;

+import static org.easymock.EasyMock.expectLastCall;

+import static org.easymock.EasyMock.isA;

+import static org.easymock.EasyMock.replay;

+import static org.junit.Assert.assertEquals;

+import static org.junit.Assert.assertFalse;

+import static org.junit.Assert.assertSame;

+import static org.junit.Assert.assertTrue;

+import static org.junit.Assert.fail;

+

+import org.junit.Before;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.IView;

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.IViewListener;

+import org.eclipse.wst.sse.sieditor.fwk.mvp.ui.ViewDelegate;

+

+/**

+ *

+ */

+

+@SuppressWarnings("nls")

+public class ViewDelegateTest {

+

+    private final class MockViewListener implements IViewListener {

+

+        private boolean isViewCreatedCalled;

+

+        private boolean isViewDisposeCalled;

+

+        private IView viewCreatedArgument;

+

+        private IView viewDisposeArgument;

+

+        public void viewCreated(final IView view) {

+            viewCreatedArgument = view;

+            isViewCreatedCalled = true;

+        }

+

+        public void viewDispose(final IView view) {

+            viewDisposeArgument = view;

+            isViewDisposeCalled = true;

+            viewDelegate.removeViewListener(this);

+        }

+    }

+

+    private IView view;

+

+    private ViewDelegate viewDelegate;

+

+    private MockViewListener viewListener1;

+

+    private MockViewListener viewListener2;

+

+    @Before

+    public void setUp() throws Exception {

+        view = createMock(IView.class);

+        viewDelegate = new ViewDelegate(view);

+        // viewListener1 = createMock(IViewListener.class);

+        // viewListener2 = createMock(IViewListener.class);

+        viewListener1 = new MockViewListener();

+        viewListener2 = new MockViewListener();

+    }

+

+    @Test

+    public void testAddGetRemove() {

+

+        assertTrue(viewDelegate.getViewListeners().isEmpty());

+

+        assertTrue(viewDelegate.addViewListener(viewListener1));

+        assertTrue(viewDelegate.addViewListener(createMock(IViewListener.class)));

+        assertTrue(viewDelegate.addViewListener(createMock(IViewListener.class)));

+        assertEquals(3, viewDelegate.getViewListeners().size());

+

+        assertTrue(viewDelegate.removeViewListener(viewListener1));

+        assertFalse(viewDelegate.removeViewListener(createMock(IViewListener.class)));

+        assertEquals(2, viewDelegate.getViewListeners().size());

+

+        try {

+            viewDelegate.getViewListeners().add(viewListener1);

+            fail("UnsupportedOperationException expected!");

+        } catch (final UnsupportedOperationException e) { // That is expected!

+        }

+    }

+

+    @Test

+    public void testNotifyViewCreated() {

+

+        // viewListener1.viewCreated(Arguments.any(viewArgument));

+        // replay(viewListener1);

+        // viewListener2.viewCreated(Arguments.any(viewArgument));

+        // replay(viewListener2);

+

+        viewDelegate.addViewListener(viewListener1);

+        viewDelegate.addViewListener(viewListener2);

+

+        viewDelegate.notifyViewCreated();

+        assertTrue(viewListener1.isViewCreatedCalled);

+        assertSame(view, viewListener1.viewCreatedArgument);

+        assertTrue(viewListener2.isViewCreatedCalled);

+        assertSame(view, viewListener2.viewCreatedArgument);

+        // verify(viewListener1);

+        // verify(viewListener2);

+    }

+

+    @Test

+    public void testNotifyViewDispose() {

+

+        // viewListener1.viewDispose(Arguments.any(viewArgument));

+        // replay(viewListener1);

+        // viewListener2.viewDispose(Arguments.any(viewArgument));

+        // replay(viewListener2);

+

+        expect(view.removeViewListener(isA(IViewListener.class))).andReturn(true);

+        expectLastCall().times(2);

+        replay(view);

+

+        viewDelegate.addViewListener(viewListener1);

+        viewDelegate.addViewListener(viewListener2);

+

+        viewDelegate.notifyViewDispose();

+        assertTrue(viewListener1.isViewDisposeCalled);

+        assertSame(view, viewListener1.viewDisposeArgument);

+        assertTrue(viewListener2.isViewDisposeCalled);

+        assertSame(view, viewListener2.viewDisposeArgument);

+        // verify(viewListener1);

+        // verify(viewListener2);

+    }

+

+    @Test(expected = IllegalArgumentException.class)

+    public void testViewDelegate() {

+        new ViewDelegate(null);

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/AbstractModelObjectFactoryTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/AbstractModelObjectFactoryTest.java
new file mode 100644
index 0000000..e9ca13c
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/AbstractModelObjectFactoryTest.java
@@ -0,0 +1,71 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.io.IOException;

+import java.net.URISyntaxException;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.eclipse.wst.wsdl.Definition;

+import org.eclipse.xsd.XSDSchema;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+import org.eclipse.wst.sse.sieditor.model.impl.WSDLFactory;

+import org.eclipse.wst.sse.sieditor.model.impl.XSDFactory;

+import org.eclipse.wst.sse.sieditor.model.wsdl.impl.AbstractWSDLComponent;

+

+

+public class AbstractModelObjectFactoryTest extends SIEditorBaseTest{

+

+	@Test 

+	public void testNotSameXSDModelRootInstancesWhenLoadResources() throws IOException, CoreException {

+		IXSDModelRoot xsdModelRoot = getXSDModelRoot("pub/xsd/example.xsd", "example.xsd");

+		IXSDModelRoot xsdModelRoot2 = getXSDModelRoot("pub/xsd/example.xsd", "example.xsd");

+		

+		assertNotSame(xsdModelRoot, xsdModelRoot2);

+	}

+	

+	@Test 

+	public void testSameXSDModelRootInstancesFromPool() throws IOException, CoreException, URISyntaxException {

+		IXSDModelRoot xsdModelRoot = getXSDModelRoot("pub/xsd/example.xsd", "example.xsd");

+		

+		XSDSchema xsdSchema = xsdModelRoot.getSchema().getComponent();

+		IXSDModelRoot xsdModelRoot2 = XSDFactory.getInstance().createXSDModelRoot(xsdSchema);

+		

+		assertSame(xsdModelRoot, xsdModelRoot2);

+	}

+	

+	@Test 

+	public void testNotSameWSDLModelRootInstancesWhenLoadResources() throws IOException, CoreException {

+		IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("pub/self/mix2/ChangePurchaseOrder_WSD.wsdl", "ChangePurchaseOrder_WSD.wsdl");

+		IWsdlModelRoot wsdlModelRoot2 = getWSDLModelRoot("pub/self/mix2/ChangePurchaseOrder_WSD.wsdl", "ChangePurchaseOrder_WSD.wsdl");

+		

+		assertNotSame(wsdlModelRoot, wsdlModelRoot2);

+	}

+	

+	@Test 

+	public void testSameWSDLModelRootInstancesFromPool() throws IOException, CoreException, URISyntaxException {

+		IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("pub/self/mix2/ChangePurchaseOrder_WSD.wsdl", "ChangePurchaseOrder_WSD.wsdl");

+		

+		Definition definition = (Definition)((AbstractWSDLComponent)wsdlModelRoot.getDescription()).getComponent();

+		IWsdlModelRoot wsdlModelRoot2 = WSDLFactory.getInstance().createWSDLModelRoot(definition);

+		

+		assertSame(wsdlModelRoot, wsdlModelRoot2);

+	}

+	

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ActionsSelectionTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ActionsSelectionTest.java
new file mode 100644
index 0000000..83073ee
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ActionsSelectionTest.java
@@ -0,0 +1,191 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.ArrayList;

+import java.util.List;

+

+import junit.framework.Assert;

+

+import org.eclipse.wst.sse.sieditor.ui.v2.dt.DataTypesContentProvider;

+import org.eclipse.wst.sse.sieditor.ui.v2.dt.DataTypesFormPageController;

+import org.eclipse.wst.sse.sieditor.ui.v2.dt.nodes.IDataTypesTreeNode;

+import org.eclipse.wst.sse.sieditor.ui.v2.dt.nodes.impl.NamespaceNode;

+import org.eclipse.wst.sse.sieditor.ui.v2.dt.nodes.impl.SimpleTypeNode;

+import org.eclipse.wst.sse.sieditor.ui.v2.nodes.ITreeNode;

+import org.eclipse.wst.sse.sieditor.ui.v2.providers.WSDLContentProvider;

+import org.eclipse.wst.sse.sieditor.ui.v2.wsdl.controller.SIFormPageController;

+import org.eclipse.wst.sse.sieditor.ui.v2.wsdltree.nodes.OperationCategory;

+import org.eclipse.wst.sse.sieditor.ui.v2.wsdltree.nodes.OperationCategoryNode;

+import org.eclipse.wst.sse.sieditor.ui.v2.wsdltree.nodes.ServiceInterfaceNode;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.model.api.IModelObject;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType;

+

+public class ActionsSelectionTest extends SIEditorBaseTest {

+

+    private static final String FILE_NAME = "pub/simple/CommonEntities.wsdl";

+    private static final String PROJECT_NAME = "actions_sel_test";

+

+    @Test

+    public void testSIActions() throws Exception {

+        final IWsdlModelRoot modelRoot = getWSDLModelRoot(FILE_NAME, "CommonEntities.wsdl");

+        Assert.assertNotNull(modelRoot);

+

+        final SIFormPageController controller = new SIFormPageController(modelRoot, false, false);

+        final WSDLContentProvider contentProvider = new WSDLContentProvider(controller);

+

+        final Object[] elements = contentProvider.getElements(modelRoot);

+        testWSDLSelection(elements, contentProvider, controller);

+    }

+

+    private void testWSDLSelection(final Object[] elements, final WSDLContentProvider contentProvider,

+            final SIFormPageController controller) {

+        if (elements != null) {

+            for (final Object object : elements) {

+                if (object instanceof ITreeNode) {

+                    final ITreeNode node = (ITreeNode) object;

+

+                    // actual testing start

+                    // interface - always

+                    Assert.assertTrue(controller.isAddNewServiceInterfaceEnabled(node));

+                    controller.addNewServiceInterface();

+                    // operation - always

+                    Assert.assertTrue(controller.isAddNewOperationEnabled(node));

+                    controller.addNewOperation(node);

+                    // in, out, fault - always, except for service interface

+                    if (!(node instanceof ServiceInterfaceNode)) {

+                        Assert.assertTrue(controller.isAddNewInParameterEnabled(node));

+                        controller.addNewParameter(node, OperationCategory.INPUT);

+                        Assert.assertTrue(controller.isAddNewOutParameterEnabled(node));

+                        controller.addNewParameter(node, OperationCategory.OUTPUT);

+                        Assert.assertTrue(controller.isAddNewFaultEnabled(node));

+                        controller.addNewFault(node);

+                    }

+                    // delete - if not OperationCategory

+                    if (!(node instanceof OperationCategoryNode)) {

+                        Assert.assertTrue(controller.isDeleteItemEnabled(node));

+                    }

+                    // actual testing end

+

+                    final Object[] children = contentProvider.getChildren(node);

+                    testWSDLSelection(children, contentProvider, controller);

+                }

+            }

+        }

+    }

+

+    @Test

+    public void testDTActions() throws Exception {

+        final IWsdlModelRoot modelRoot = getWSDLModelRoot(FILE_NAME, "CommonEntities.wsdl");

+        Assert.assertNotNull(modelRoot);

+

+        final DataTypesFormPageController controller = new DataTypesFormPageController(modelRoot, false);

+        final DataTypesContentProvider contentProvider = new DataTypesContentProvider(controller);

+

+        final Object[] elements = contentProvider.getElements(modelRoot);

+        testXSDSelection(elements, contentProvider, controller);

+    }

+

+    private void testXSDSelection(final Object[] elements, final DataTypesContentProvider contentProvider,

+            final DataTypesFormPageController controller) {

+        if (elements != null) {

+            for (final Object object : elements) {

+                if (object instanceof IDataTypesTreeNode) {

+                    final IDataTypesTreeNode node = (IDataTypesTreeNode) object;

+                    final IModelObject modelObject = node.getModelObject();

+

+                    if (!(modelObject instanceof ISchema || modelObject instanceof ISimpleType)) {

+                        if (modelObject instanceof IStructureType) {

+                            final IStructureType structure = (IStructureType) modelObject;

+                            if (structure.getType() instanceof ISimpleType) {

+                                Assert.assertFalse(controller.isAddElementEnabled(node));

+                                continue;

+                            }

+                        }

+                        // add element

+                        if (node.isReadOnly()

+                                && ((node.getCategories() & ITreeNode.CATEGORY_REFERENCE) == ITreeNode.CATEGORY_REFERENCE)

+                                && node.getParent().isReadOnly()) {

+                            Assert.assertFalse(controller.isAddElementEnabled(node));

+                        } else {

+                            Assert.assertTrue(controller.isAddElementEnabled(node));

+                        }

+                        controller.handleAddElementAction(node);

+                    }

+

+                    // Simple Type

+                    if (node.isReadOnly()

+                            && ((node.getCategories() & ITreeNode.CATEGORY_REFERENCE) != ITreeNode.CATEGORY_REFERENCE)) {

+                        Assert.assertFalse(controller.isAddSimpleTypeEnabled(node));

+                    } else {

+                        Assert.assertTrue(controller.isAddSimpleTypeEnabled(node));

+                    }

+                    controller.handleAddSimpleTypeAction(node);

+                    // Structure Type

+                    if (node.isReadOnly()

+                            && ((node.getCategories() & ITreeNode.CATEGORY_REFERENCE) != ITreeNode.CATEGORY_REFERENCE)) {

+                        Assert.assertFalse(controller.isAddStructureEnabled(node));

+                    } else {

+                        Assert.assertTrue(controller.isAddStructureEnabled(node));

+                    }

+                    controller.handleAddStructureTypeAction(node);

+                    // if not namespace, simple type or simple type element -

+                    // also Attribute should be possible

+                    boolean executeAttributeCheck = true;

+                    if ((node instanceof SimpleTypeNode) || (node instanceof NamespaceNode)) {

+                        executeAttributeCheck = false;

+                    }

+                    if (modelObject instanceof IStructureType) {

+                        final IStructureType structure = (IStructureType) modelObject;

+                        // global element

+                        if (structure.isElement()

+                                && !(structure.getType() instanceof IStructureType && structure.getType().isAnonymous())) {

+                            executeAttributeCheck = false;

+                        }

+                    }

+                    if (executeAttributeCheck) {

+                        if (node.isReadOnly()

+                                && ((node.getCategories() & ITreeNode.CATEGORY_REFERENCE) == ITreeNode.CATEGORY_REFERENCE)

+                                && node.getParent().isReadOnly()) {

+                            Assert.assertFalse(controller.isAddAttributeEnabled(node));

+                        } else {

+                            Assert.assertTrue(controller.isAddAttributeEnabled(node));

+                        }

+                        controller.handleAddAttributeAction(node);

+                    }

+                    // delete - always

+                    final List<IDataTypesTreeNode> nodes = new ArrayList<IDataTypesTreeNode>();

+                    nodes.add(node);

+                    controller.isRemoveItemsEnabled(nodes);

+                    // actual testing end

+

+                    final Object[] children = contentProvider.getChildren(node);

+                    testXSDSelection(children, contentProvider, controller);

+                }

+            }

+        }

+    }

+

+    @Override

+    protected String getProjectName() {

+        return PROJECT_NAME;

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/Constants.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/Constants.java
new file mode 100644
index 0000000..c17f453
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/Constants.java
@@ -0,0 +1,25 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+@SuppressWarnings("nls")

+public interface Constants {

+    public static final String DATA_PUBLIC_SELF_KESHAV = "pub/self/mix/";

+

+    public static final String DATA_PUBLIC_SELF_MIX2 = "pub/self/mix2/";

+    

+    public static final String DATA_PUBLIC_SIMPLE = "pub/simple/";

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/EnsureSchemaCommandRepatchTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/EnsureSchemaCommandRepatchTest.java
new file mode 100644
index 0000000..9c6b745
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/EnsureSchemaCommandRepatchTest.java
@@ -0,0 +1,73 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.wst.sse.sieditor.test.model.commands.AbstractXSDCommandTest;

+import org.eclipse.xsd.XSDSchema;

+import org.w3c.dom.Document;

+import org.w3c.dom.Node;

+

+import org.eclipse.wst.sse.sieditor.command.common.AbstractNotificationOperation;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.EnsureSchemaElementCommand;

+import org.eclipse.wst.sse.sieditor.model.api.IModelObject;

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+

+public class EnsureSchemaCommandRepatchTest extends AbstractXSDCommandTest {

+

+    @Override

+    protected void assertPostRedoState(IStatus redoStatus, IXSDModelRoot modelRoot) {

+        final IModelObject modelObject = modelRoot.getModelObject();

+

+        assertNotNull(modelObject);

+        assertTrue(modelObject.getComponent() instanceof XSDSchema);

+        assertNotNull(((XSDSchema) modelObject.getComponent()).getElement());

+

+        final Document document = modelRoot.getSchema().getComponent().getDocument();

+

+        assertEquals(Node.PROCESSING_INSTRUCTION_NODE, document.getFirstChild().getNodeType());

+        assertEquals(Node.TEXT_NODE, document.getFirstChild().getNextSibling().getNodeType());

+        assertEquals(Node.ELEMENT_NODE, document.getFirstChild().getNextSibling().getNextSibling().getNodeType());

+    }

+

+    @Override

+    protected void assertPostUndoState(IStatus undoStatus, IXSDModelRoot modelRoot) {

+        final IModelObject modelObject = modelRoot.getModelObject();

+

+        assertNotNull(modelObject);

+        assertTrue(modelObject.getComponent() instanceof XSDSchema);

+        assertNull(((XSDSchema) modelObject.getComponent()).getElement());

+

+        final Document document = modelRoot.getSchema().getComponent().getDocument();

+

+        assertNull(document.getFirstChild());

+    }

+

+    @Override

+    protected AbstractNotificationOperation getOperation(IXSDModelRoot modelRoot) throws Exception {

+        return new EnsureSchemaElementCommand(modelRoot.getSchema(), "");

+    }

+

+    @Override

+    protected String getFilename() {

+        return "empty.xsd";

+    }

+

+    @Override

+    protected String getFolderName() {

+        return "pub/csns/badContent/";

+    }

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/InvalidWSDLTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/InvalidWSDLTest.java
new file mode 100644
index 0000000..b93107f
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/InvalidWSDLTest.java
@@ -0,0 +1,264 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.Collection;

+import java.util.List;

+

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface;

+import org.eclipse.wst.sse.sieditor.model.wsdl.impl.OperationParameter;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IType;

+import org.eclipse.wst.sse.sieditor.model.xsd.impl.UnresolvedType;

+

+@SuppressWarnings("nls")

+public class InvalidWSDLTest extends SIEditorBaseTest {

+

+    protected String getProjectName() {

+        return "InvalidWSDLTest";

+    }

+

+    @Test

+    public void testNoName() throws Exception {

+        // Service Interface

+        final IDescription description = getModelRoot("InvalidWSDL.wsdl");

+        Collection<IServiceInterface> interfaces = description.getAllInterfaces();

+        assertTrue(interfaces.size() == 3);

+        IServiceInterface[] serviceinterfaces = new IServiceInterface[3];

+        interfaces.toArray(serviceinterfaces);

+        assertEquals("", serviceinterfaces[0].getName());

+        assertEquals("", serviceinterfaces[1].getName());

+        List<IServiceInterface> sIs = description.getInterface("");

+        assertFalse(sIs.isEmpty());

+        IServiceInterface serviceInterface = sIs.get(0);

+        assertNotNull("Null returned for service interface with name ''", serviceInterface);

+

+        sIs = description.getInterface("PortType");

+        assertFalse(sIs.isEmpty());

+        serviceInterface = sIs.get(0);

+        assertNotNull(serviceInterface);

+

+        // Operation

+        final Collection<IOperation> operations = serviceInterface.getAllOperations();

+        assertTrue(operations.size() == 5);

+        IOperation[] operationArray = new IOperation[5];

+        operations.toArray(operationArray);

+        assertEquals(null, operationArray[0].getName());

+        assertEquals("", operationArray[1].getName());

+        List<IOperation> ops = serviceInterface.getOperation("");

+        assertFalse(ops.isEmpty());

+        IOperation operation = ops.get(0);

+        assertNotNull("Null returned for operation with name ''", operation);

+        ops = serviceInterface.getOperation(null);

+        assertFalse(ops.isEmpty());

+        assertNotNull(ops.get(0));

+

+        // In Parameters

+        ops = serviceInterface.getOperation("Operation");

+        assertFalse(ops.isEmpty());

+        operation = ops.get(0);

+        assertNotNull(operation);

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertEquals(4, parameters.size());

+        IParameter[] parameterArray = new IParameter[4];

+        parameters.toArray(parameterArray);

+        assertEquals("", parameterArray[0].getName());

+        assertEquals("", parameterArray[1].getName());

+        assertEquals("parameterOne", parameterArray[2].getName());

+        assertEquals("parameterTwo", parameterArray[3].getName());

+        List<IParameter> params = operation.getInputParameter("");

+        assertFalse(params.isEmpty());

+        IParameter parameter = params.get(0);

+        assertNotNull("In Paramter is null for name ''", parameter);

+        assertTrue("In Paramter is not null for null", operation.getInputParameter(null).isEmpty());

+

+        // Out Parameters

+        parameters = operation.getAllOutputParameters();

+        assertEquals(4, parameters.size());

+        parameterArray = new IParameter[4];

+        parameters.toArray(parameterArray);

+        assertEquals("", parameterArray[0].getName());

+        assertEquals("", parameterArray[1].getName());

+        assertEquals("parameterOne", parameterArray[2].getName());

+        assertEquals("parameterTwo", parameterArray[3].getName());

+        params = operation.getOutputParameter("");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull("Out Paramter is null for name ''", parameter);

+        assertTrue("Out Paramter is not null for null", operation.getOutputParameter(null).isEmpty());

+

+        // Faults

+        final Collection<IFault> faults = operation.getAllFaults();

+        assertEquals(3, faults.size());

+        IFault[] faultArray = new IFault[3];

+        faults.toArray(faultArray);

+        assertEquals(null, faultArray[0].getName());

+        assertEquals("", faultArray[1].getName());

+        assertEquals("fault", faultArray[2].getName());

+        List<IFault> flts = operation.getFault("");

+        assertFalse(flts.isEmpty());

+        IFault fault = flts.get(0);

+        assertNotNull("Fault is null for name ''", fault);

+        flts = operation.getFault(null);

+        assertFalse(flts.isEmpty());

+        fault = flts.get(0);

+        assertNotNull("Fault is null for null", fault);

+

+        // Fault Parameters

+        fault = faultArray[2];

+        parameters = fault.getParameters();

+        assertEquals(4, parameters.size());

+        parameterArray = new IParameter[4];

+        parameters.toArray(parameterArray);

+        assertEquals("", parameterArray[0].getName());

+        assertEquals("", parameterArray[1].getName());

+        assertEquals("parameterOne", parameterArray[2].getName());

+        assertEquals("parameterTwo", parameterArray[3].getName());

+        List<IParameter> prms = fault.getParameter("");

+        assertFalse(prms.isEmpty());

+        parameter = prms.get(0);

+        assertNotNull("Fault Paramter is null for name ''", parameter);

+        assertTrue("Fault Parameter is not null for null", fault.getParameter(null).isEmpty());

+    }

+

+    @Test

+    public void testNoParameterType() throws Exception {

+        final IDescription description = getModelRoot("InvalidWSDL.wsdl");

+        IServiceInterface serviceInterface = description.getInterface("PortType").get(0);

+

+        IOperation operation = serviceInterface.getOperation("MissingParameterType").get(0);

+

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertEquals(5, parameters.size());

+        List<IParameter> params = operation.getInputParameter("missingTypeParameter");

+        assertFalse(params.isEmpty());

+        IParameter parameter = params.get(0);

+        assertNotNull(parameter);

+        IType type = parameter.getType();

+        assertNull("Type returned is not null", type);

+        params = operation.getInputParameter("missingTypeParameterOne");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNotNull(type);

+        assertTrue(type instanceof UnresolvedType);

+        params = operation.getInputParameter("missingTypeParameterTwo");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNotNull(type);

+        assertTrue(type instanceof UnresolvedType);

+        params = operation.getInputParameter("correctParameter");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNotNull("Type returned is null", type);

+

+        parameters = operation.getAllOutputParameters();

+        assertEquals(5, parameters.size());

+        params = operation.getOutputParameter("missingTypeParameter");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNull("Type returned is not null", type);

+        params = operation.getOutputParameter("missingTypeParameterOne");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNotNull(type);

+        assertTrue(type instanceof UnresolvedType);

+        params = operation.getOutputParameter("missingTypeParameterTwo");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNotNull(type);

+        assertTrue(type instanceof UnresolvedType);

+        params = operation.getOutputParameter("correctParameter");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNotNull("Type returned is null", type);

+

+        IFault fault = operation.getFault("fault").get(0);

+

+        parameters = fault.getParameters();

+        assertEquals(5, parameters.size());

+        params = fault.getParameter("missingTypeParameter");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNull(type);

+        params = fault.getParameter("missingTypeParameterOne");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNotNull(type);

+        assertTrue(type instanceof UnresolvedType);

+        params = fault.getParameter("missingTypeParameterTwo");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNotNull(type);

+        assertTrue(type instanceof UnresolvedType);

+        params = fault.getParameter("correctParameter");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        type = parameter.getType();

+        assertNotNull("Type returned is null", type);

+    }

+

+    @Test

+    public void testNoMessage() throws Exception {

+        final IDescription description = getModelRoot("InvalidWSDL.wsdl");

+        IServiceInterface serviceInterface = description.getInterface("PortType").get(0);

+

+        IOperation operation = serviceInterface.getOperation("MissingMessage").get(0);

+

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertEquals(0, parameters.size());

+        parameters = operation.getAllOutputParameters();

+        assertEquals(0, parameters.size());

+

+        IFault fault = operation.getFault("fault").get(0);

+        parameters = fault.getParameters();

+        assertEquals(0, parameters.size());

+    }

+

+    private IDescription getModelRoot(String fileName) throws Exception {

+        final String fullPath = Constants.DATA_PUBLIC_SELF_KESHAV + fileName;

+        final IWsdlModelRoot modelRoot = getWSDLModelRoot(fullPath, fileName);

+        assertNotNull("Could not Acquire Model Root for " + fullPath, modelRoot);

+        return modelRoot.getDescription();

+    }

+

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/InvalidXSDTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/InvalidXSDTest.java
new file mode 100644
index 0000000..ddd0ab2
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/InvalidXSDTest.java
@@ -0,0 +1,43 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+

+@SuppressWarnings("nls")

+public class InvalidXSDTest extends SIEditorBaseTest {

+

+    protected String getProjectName() {

+        return "InvalidXSDTest";

+    }

+

+    @Test

+    public void testNoResolvedSchemas() throws Exception {

+

+    }

+

+    @Test

+    public void testNoResolvedTypes() throws Exception {

+

+    }

+

+    @Test

+    public void testNoNames() throws Exception {

+

+    }

+

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ModelTestsSuite.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ModelTestsSuite.java
new file mode 100644
index 0000000..1077585
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ModelTestsSuite.java
@@ -0,0 +1,35 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import org.eclipse.wst.sse.sieditor.test.model.wsdl.impl.TestDescription;

+import org.junit.runner.RunWith;

+import org.junit.runners.Suite;

+import org.junit.runners.Suite.SuiteClasses;

+

+

+/**

+ * Read API's Tests suite

+ * 

+ * 

+ */

+@RunWith(Suite.class)

+@SuiteClasses( { WSDLReadAPITest.class, WsdlMultipleComponentsTest.class, InvalidWSDLTest.class, ReferencedDocumentsTest.class,

+        XSDReadAPITest.class, XSDMultipleComponentsTest.class, InvalidXSDTest.class, XSDReferencedDocumentsTest.class,

+        WSDLWriteTest.class, XSDWriteTest.class, SetAPIWSDLWriteTest.class, SetAPIXSDWriteTest.class, TestDescription.class,

+        ReadOfDuplicateSITest.class, ActionsSelectionTest.class, UriEncodingsOnImportTest.class, RemoveTargetNamespaceTest.class })

+public class ModelTestsSuite {

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ReadOfDuplicateSITest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ReadOfDuplicateSITest.java
new file mode 100644
index 0000000..68544b5
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ReadOfDuplicateSITest.java
@@ -0,0 +1,188 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.io.IOException;

+import java.net.URISyntaxException;

+import java.util.List;

+

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface;

+

+/**

+ *

+ * 

+ */

+public class ReadOfDuplicateSITest extends SIEditorBaseTest{

+

+   /**

+     * Test method for

+     * {@link org.eclipse.wst.sse.sieditor.model.wsdl.impl.Description#getInterface(java.lang.String)}

+     * .

+     * 

+     * @throws URISyntaxException

+     * @throws CoreException 

+     * @throws IOException 

+     */

+    @Test

+    public void testGetInterface() throws URISyntaxException, IOException, CoreException {

+        IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("pub/self/mix/DuplicateNameSI.wsdl", "DuplicateNameSI.wsdl");

+        final String SI_NAME = "DuplicateNameSI";

+        

+        List<IServiceInterface> interfaces = wsdlModelRoot.getDescription().getInterface(SI_NAME); //$NON-NLS-1$

+        

+        assertEquals(2, interfaces.size());

+        for (IServiceInterface sInterface : interfaces) {

+            assertNotNull(sInterface);

+            assertNotNull(sInterface.getComponent());

+            assertEquals(SI_NAME,sInterface.getName());

+        }

+    }

+    /**

+     * Test method for

+     * {@link org.eclipse.wst.sse.sieditor.model.wsdl.impl.ServiceInterface#getOperation(java.lang.String)}

+     * .

+     * 

+     * @throws URISyntaxException

+     * @throws CoreException 

+     * @throws IOException 

+     */

+    @Test 

+    public void testGetOperation() throws IOException, CoreException{

+        IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("pub/self/mix/DuplicateNameSI.wsdl", "DuplicateNameSI.wsdl");

+        List<IServiceInterface> interfaces = wsdlModelRoot.getDescription().getInterface("DuplicateNameSI"); //$NON-NLS-1$

+        IServiceInterface sInterface = interfaces.get(0);

+        

+        final String OP_NAME = "NewOperation";

+        List<IOperation> parameters = sInterface.getOperation(OP_NAME); //$NON-NLS-1$

+     

+        assertEquals(2, parameters.size());

+        for (IOperation parameter : parameters) {

+            assertNotNull(parameter);

+            assertNotNull(parameter.getComponent());

+            assertEquals(OP_NAME, parameter.getName());

+        }

+    }

+    /**

+     * Test method for

+     * {@link org.eclipse.wst.sse.sieditor.model.wsdl.impl.ServiceOperation#getInputParameter(java.lang.String)}

+     * .

+     * 

+     * @throws URISyntaxException

+     * @throws CoreException 

+     * @throws IOException 

+     */

+    @Test

+    public void testGetInputParameter() throws IOException, CoreException{

+        IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("pub/self/mix/DuplicateNameSI.wsdl", "DuplicateNameSI.wsdl");

+        List<IServiceInterface> interfaces = wsdlModelRoot.getDescription().getInterface("DuplicateNameSI"); //$NON-NLS-1$

+        IOperation sInterface = interfaces.get(0).getOperation("NewOperation").get(0);

+        

+        final String PARAM_NAME = "Parameter";

+        List<IParameter> parameters = sInterface.getInputParameter(PARAM_NAME); //$NON-NLS-1$

+     

+        assertEquals(2, parameters.size());

+        for (IParameter parameter : parameters) {

+            assertNotNull(parameter);

+            assertNotNull(parameter.getComponent());

+            assertEquals(PARAM_NAME, parameter.getName());

+            assertEquals(IParameter.INPUT,parameter.getParameterType());

+        }

+    }

+    /**

+     * Test method for

+     * {@link org.eclipse.wst.sse.sieditor.model.wsdl.impl.ServiceOperation#getOutputParameter(java.lang.String)}

+     * .

+     * 

+     * @throws URISyntaxException

+     * @throws CoreException 

+     * @throws IOException 

+     */

+    @Test

+    public void testGetOutputParameter() throws IOException, CoreException{

+        IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("pub/self/mix/DuplicateNameSI.wsdl", "DuplicateNameSI.wsdl");

+        List<IServiceInterface> interfaces = wsdlModelRoot.getDescription().getInterface("DuplicateNameSI"); //$NON-NLS-1$

+        IOperation sInterface = interfaces.get(0).getOperation("NewOperation").get(0);

+        

+        final String PARAM_NAME = "Parameter"; //$NON-NLS-1$

+        List<IParameter> parameters = sInterface.getOutputParameter(PARAM_NAME);

+     

+        assertEquals(2, parameters.size());

+        for (IParameter parameter : parameters) {

+            assertNotNull(parameter);

+            assertNotNull(parameter.getComponent());

+            assertEquals(PARAM_NAME, parameter.getName());

+            assertEquals(IParameter.OUTPUT,parameter.getParameterType());

+        }

+    }

+    /**

+     * Test method for

+     * {@link org.eclipse.wst.sse.sieditor.model.wsdl.impl.ServiceOperation#getFault(java.lang.String)}

+     * .

+     * 

+     * @throws URISyntaxException

+     * @throws CoreException 

+     * @throws IOException 

+     */

+    @Test

+    public void testGetFault() throws IOException, CoreException{

+        IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("pub/self/mix/DuplicateNameSI.wsdl", "DuplicateNameSI.wsdl");

+        List<IServiceInterface> interfaces = wsdlModelRoot.getDescription().getInterface("DuplicateNameSI"); //$NON-NLS-1$

+        IOperation sInterface = interfaces.get(0).getOperation("NewOperation").get(0);

+        

+        final String PARAM_NAME = "Fault1";//$NON-NLS-1$

+        List<IFault> parameters = sInterface.getFault(PARAM_NAME); 

+     

+        assertEquals(2, parameters.size());

+        for (IFault fault : parameters) {

+            assertNotNull(fault);

+            assertNotNull(fault.getComponent());

+            assertEquals(PARAM_NAME, fault.getName());

+        }

+    }

+    /**

+     * Test method for

+     * {@link org.eclipse.wst.sse.sieditor.model.wsdl.impl.OperationFault#getParameter(java.lang.String)}

+     * .

+     * 

+     * @throws URISyntaxException

+     * @throws CoreException 

+     * @throws IOException 

+     */

+    @Test

+    public void testGetFaultParameter() throws URISyntaxException, IOException, CoreException {

+        IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("pub/self/mix/DuplicateNameSI.wsdl", "DuplicateNameSI.wsdl");

+        List<IServiceInterface> interfaces = wsdlModelRoot.getDescription().getInterface("DuplicateNameSI"); //$NON-NLS-1$

+        IFault fault = interfaces.get(0).getAllOperations().iterator().next().getAllFaults().iterator().next();

+        

+        final String PARAM_NAME = "Parameter";

+        List<IParameter> parameters = fault.getParameter(PARAM_NAME); //$NON-NLS-1$

+     

+        assertEquals(2, parameters.size());

+        for (IParameter parameter : parameters) {

+            assertNotNull(parameter);

+            assertNotNull(parameter.getComponent());

+            assertEquals(PARAM_NAME, parameter.getName());

+            assertEquals(IParameter.FAULT, parameter.getParameterType());

+        }

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ReferencedDocumentsTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ReferencedDocumentsTest.java
new file mode 100644
index 0000000..8d58317
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/ReferencedDocumentsTest.java
@@ -0,0 +1,148 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.Collection;

+import java.util.List;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface;

+import org.eclipse.wst.sse.sieditor.model.wsdl.impl.OperationParameter;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IType;

+

+@SuppressWarnings("nls")

+public class ReferencedDocumentsTest extends SIEditorBaseTest {

+

+    protected String getProjectName() {

+        return "ReferencedDocumentsTest";

+    }

+

+    @Test

+    public void testGetReferencedDocuments() throws Exception {

+        IFile file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported.wsdl",

+                Document_FOLDER_NAME, this.getProject(), "Imported.wsdl");

+        assertTrue(null != file && file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "po.xsd", Document_FOLDER_NAME, this

+                .getProject(), "po.xsd");

+        assertTrue(null != file && file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "example.xsd", Document_FOLDER_NAME,

+                this.getProject(), "example.xsd");

+        assertTrue(null != file && file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Importing.wsdl", Document_FOLDER_NAME,

+                this.getProject(), "Importing.wsdl");

+        assertTrue(null != file && file.exists());

+        // check for referenced documents

+        final IDescription description = getModelRoot("Importing.wsdl");

+        assertNotNull(description);

+

+        final Collection<IServiceInterface> interfaces = description.getAllInterfaces();

+        assertEquals(2, interfaces.size());

+

+        final Collection<IDescription> services = description.getReferencedServices();

+        assertNotNull("Null returned for referenced documents", services);

+        assertTrue("No referenced documents present", services.size() == 1);

+        assertEquals("http://www.example.org/Imported/", services.iterator().next().getNamespace());

+

+        final Collection<ISchema> schemas = description.getAllVisibleSchemas();

+        assertNotNull("Null returned for referenced schemas", schemas);

+        assertEquals(4, schemas.size());

+        List<IServiceInterface> sIs = description.getInterface("PortTypeWithImportedMessageRef");

+        assertFalse(sIs.isEmpty());

+        IServiceInterface serviceInterface = sIs.get(0);

+        assertNotNull(serviceInterface);

+        serviceInterface.getOperation("NewOperation");

+

+    }

+

+    @Test

+    public void testImportedType() throws Exception {

+        final IDescription description = getModelRoot("Importing.wsdl");

+        List<IServiceInterface> sIs = description.getInterface("PortType");

+        assertFalse(sIs.isEmpty());

+        IServiceInterface serviceInterface = sIs.get(0);

+        assertNotNull(serviceInterface);

+

+        IOperation operation = serviceInterface.getOperation("NewOperation").get(0);

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertEquals(3, parameters.size());

+

+        IParameter parameter = operation.getInputParameter("containedType").get(0);

+        IType type = parameter.getType();

+        assertNotNull("Type for containedType is null", type);

+        assertEquals("NewOperation", type.getName());

+

+        parameter = operation.getInputParameter("importedType").get(0);

+        type = parameter.getType();

+        assertNotNull("Type for importedType is null", type);

+        assertEquals("comment", type.getName());

+        assertEquals("http://www.example.com/IPO", type.getNamespace());

+

+        parameter = operation.getInputParameter("wsiImportedType").get(0);

+        type = parameter.getType();

+        assertNotNull("Type for wsiImportedType is null", type);

+        assertEquals("comment", type.getName());

+        assertEquals("http://www.example.com/", type.getNamespace());

+    }

+

+    @Test

+    public void testImportedMessage() throws Exception {

+        //copy files used in the test:

+        ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV+"example.xsd", this.getProject());

+        getModelRoot("Imported.wsdl");

+    

+        final IDescription description = getModelRoot("Importing.wsdl");

+        List<IServiceInterface> sIs = description.getInterface("PortTypeWithImportedMessageRef");

+        assertFalse(sIs.isEmpty());

+        IServiceInterface serviceInterface = sIs.get(0);

+        assertNotNull(serviceInterface);

+

+        IOperation operation = serviceInterface.getOperation("NewOperation").get(0);

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertEquals(2, parameters.size());

+

+        List<IParameter> params = operation.getInputParameter("importedParamWithContainedType");

+        assertFalse(params.isEmpty());

+        IParameter parameter = params.get(0);

+        assertNotNull(parameter);

+        assertEquals("importedParamWithContainedType", parameter.getName());

+        IType type = parameter.getType();

+        assertNotNull(type);

+        assertEquals("ImportedOperation", type.getName());

+        assertEquals("http://www.example.org/Imported/", type.getNamespace());

+

+        params = operation.getInputParameter("importedParamWithWsiImportedType");

+        assertFalse(params.isEmpty());

+        parameter = params.get(0);

+        assertNotNull(parameter);

+        assertEquals("importedParamWithWsiImportedType", parameter.getName());

+        type = parameter.getType();

+        assertNotNull(type);

+        assertEquals("purchaseOrder", type.getName());

+        assertEquals("http://www.example.com/", type.getNamespace());

+    }

+

+    private IDescription getModelRoot(String fileName) throws Exception {

+        return getWSDLModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV + fileName, fileName).getDescription();

+    }

+

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/RemoveTargetNamespaceTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/RemoveTargetNamespaceTest.java
new file mode 100644
index 0000000..4c8a8fa
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/RemoveTargetNamespaceTest.java
@@ -0,0 +1,60 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.AddNewSchemaCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetNamespaceCommand;

+import org.eclipse.wst.sse.sieditor.core.common.IEnvironment;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+

+public class RemoveTargetNamespaceTest extends SIEditorBaseTest {

+

+    @Test

+    public void testXsdCase() throws ExecutionException {

+        IXSDModelRoot xsdModelRoot = null;

+        try {

+            xsdModelRoot = getXSDModelRoot("pub/xsd/example2.xsd", "test with space.xsd");

+        } catch (Exception e) {

+            fail(e.toString());

+        }

+

+        SetNamespaceCommand setNamespaceCommand = new SetNamespaceCommand(xsdModelRoot, xsdModelRoot.getSchema(), "");

+        xsdModelRoot.getEnv().execute(setNamespaceCommand);

+        assertNull(xsdModelRoot.getSchema().getComponent().getTargetNamespace());

+

+    }

+

+    @Test

+    public void testWsdlCase() throws Exception {

+        IWsdlModelRoot wsdlModelRoot = getWSDLModelRoot("tns/wsdl/wsdlWithoutTns.wsdl", "wsdlWithoutTns.wsdl");

+        AddNewSchemaCommand addNewSchemaCommand = new AddNewSchemaCommand(wsdlModelRoot, "dummy");

+        IEnvironment env = wsdlModelRoot.getEnv();

+        env.execute(addNewSchemaCommand);

+        ISchema newSchema = addNewSchemaCommand.getNewSchema();

+        SetNamespaceCommand setNamespaceCommand = new SetNamespaceCommand(wsdlModelRoot, newSchema, "");

+        env.execute(setNamespaceCommand);

+        // fails because the model is not loaded from a real opened editor

+        // TODO write a command test for undo/redo on this command

+        // assertTrue(env.getOperationHistory().undo(env.getUndoContext(), new

+        // NullProgressMonitor(), null).isOK());

+        // assertEquals("dummy", newSchema.getNamespace());

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/SetAPIWSDLWriteTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/SetAPIWSDLWriteTest.java
new file mode 100644
index 0000000..7c80572
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/SetAPIWSDLWriteTest.java
@@ -0,0 +1,845 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.Collection;

+import java.util.Iterator;

+import java.util.List;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.runtime.IPath;

+import org.eclipse.core.runtime.Path;

+import org.eclipse.ui.part.FileEditorInput;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.mm.ModelManager;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.generic.IllegalInputException;

+import org.eclipse.wst.sse.sieditor.model.write.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.write.wsdl.api.IFault;

+import org.eclipse.wst.sse.sieditor.model.write.wsdl.api.IOperation;

+import org.eclipse.wst.sse.sieditor.model.write.wsdl.api.IServiceInterface;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.OperationType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+

+/*

+ * Those tests should be removed after the wsdl write API gets removed.

+ */

+@SuppressWarnings("nls")

+public class SetAPIWSDLWriteTest extends SIEditorBaseTest {

+

+    private static final String SOURCE_FOLDER = "src/wsdl";

+

+    protected String getProjectName() {

+        return "SetAPIWSDLWriteTest";

+    }

+

+    @Test

+    public void test_Description() throws Exception {

+        // check for referenced documents

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "One.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        description = modelRoot.getDescription();

+        final ModelManager mm = ModelManager.getInstance();

+

+        IDescription wDesc = (IDescription) mm.getWriteSupport(description);

+        interfaceObj = wDesc.addInterface("newInterface");

+        assertEquals("newInterface", interfaceObj.getName());

+        assertEquals("http://sap.com/xi/Purchasing", interfaceObj.getNamespace());

+        List<org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface> interfaces = description

+                .getInterface("newInterface");

+        assertFalse("Could not find service new SI", interfaces.isEmpty());

+        assertNotNull("Could not find service new SI", interfaces.get(0));

+        assertEquals(0, interfaceObj.getAllOperations().size());

+

+        wDesc.removeInterface(interfaceObj);

+        assertTrue("newInterface is not removed", description.getInterface("newInterface").isEmpty());

+

+        interfaceObj = wDesc.addInterface("newInterface");

+        assertEquals("newInterface", interfaceObj.getName());

+        assertEquals("http://sap.com/xi/Purchasing", interfaceObj.getNamespace());

+        assertFalse("Could not find service new SI", description.getInterface("newInterface").isEmpty());

+        assertNotNull("Could not find service new SI", description.getInterface("newInterface").get(0));

+        assertEquals(0, interfaceObj.getAllOperations().size());

+

+        // Implement these methods

+        Exception error = null;

+        try {

+            wDesc.addExtension(null);

+        } catch (Exception e) {

+            error = e;

+        }

+        assertNotNull(error);

+        error = null;

+        try {

+            wDesc.removeExtension(null);

+        } catch (Exception e) {

+            error = e;

+        }

+        assertNotNull(error);

+

+        wDesc.removeInterface(description.getInterface("PurchaseOrderConfirmation").get(0));

+        assertTrue("PurchaseOrderConfirmation is not removed", description.getInterface("PurchaseOrderConfirmation").isEmpty());

+

+        schema = wDesc.addSchema("http://newNs");

+        assertNotNull("Schema http://newNs is not added", schema);

+        assertEquals("http://newNs", schema.getNamespace());

+        assertEquals(description, schema.getRoot());

+        assertEquals(description, schema.getParent());

+        assertTrue("Schema location is not WSDL Location", schema.getLocation().endsWith("One.wsdl"));

+        assertNotNull("new Schema could not be obtained", description.getSchema("http://newNs"));

+        assertEquals(0, schema.getAllContainedTypes().size());

+

+        assertTrue(wDesc.removeSchema(schema));

+        assertNotNull("new Schema is not deleted", description.getSchema("http://newNs"));

+

+        schema = wDesc.addSchema("http://newNs");

+        assertNotNull("Schema http://newNs is not added", schema);

+        assertEquals("http://newNs", schema.getNamespace());

+        assertEquals(description, schema.getRoot());

+        assertEquals(description, schema.getParent());

+        assertTrue("Schema location is not WSDL Location", schema.getLocation().endsWith("One.wsdl"));

+        assertNotNull("new Schema could not be obtained", description.getSchema("http://newNs"));

+        assertEquals(0, schema.getAllContainedTypes().size());

+

+        wDesc.setDocumentation("Documentation");

+        assertEquals("Documentation", description.getDocumentation());

+        wDesc.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", description.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "Two.wsdl");

+        description = modelRoot.getDescription();

+        wDesc = (IDescription) mm.getWriteSupport(description);

+        wDesc.addInterface("newInterface");

+        wDesc.removeInterface(description.getInterface("PurchaseOrderConfirmation").get(0));

+        wDesc.addSchema("http://newNs");

+        assertTrue(wDesc.removeSchema("http://sap.com/xi/SRM/Basis/Global"));

+        wDesc.setDocumentation("Documentation");

+        wDesc.setDocumentation("NewDocumentation");

+        wDesc.save();

+

+        modelRoot = getModelRoot("Two.wsdl");

+        description = modelRoot.getDescription();

+        assertFalse("Could not find service new SI", description.getInterface("newInterface").isEmpty());

+        assertNotNull(description.getInterface("newInterface").get(0));

+        assertNotNull("new Schema is not deleted", description.getSchema("http://newNs"));

+        assertEquals("Schema http://sap.com/xi/SRM/Basis/Global is not deleted", 0, description

+                .getSchema("http://sap.com/xi/SRM/Basis/Global").length);

+        assertTrue("PurchaseOrderConfirmation is not removed", description.getInterface("PurchaseOrderConfirmation").isEmpty());

+        assertEquals("NewDocumentation", description.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("Documentation.wsdl", "Documentation.wsdl");

+        description = modelRoot.getDescription();

+        assertEquals("Documentation", description.getDocumentation());

+        wDesc = (IDescription) mm.getWriteSupport(description);

+        wDesc.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", description.getDocumentation());

+        wDesc.save();

+        modelRoot = getModelRoot("Documentation.wsdl");

+        description = modelRoot.getDescription();

+        assertEquals("NewDocumentation", description.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("PrefixWSDL.wsd", "PrefixWSDL.wsdl");

+        description = modelRoot.getDescription();

+        wDesc = (IDescription) mm.getWriteSupport(description);

+        wDesc.setDocumentation("Documentation");

+        assertEquals("Documentation", description.getDocumentation());

+

+        wDesc.setNamespace("http://example.org");

+        assertEquals("http://example.org", description.getNamespace());

+        wDesc.save();

+        modelRoot = getModelRoot("PrefixWSDL.wsdl");

+        description = modelRoot.getDescription();

+        assertEquals("http://example.org", description.getNamespace());

+

+        try {

+            wDesc.setNamespace("http://example.org&%^^*&%*(");

+            fail("Validation of description namespace doesn't work");

+        } catch (IllegalInputException e) {

+

+        }

+    }

+

+    @Test

+    public void test_ServiceInterface() throws Exception {

+        // check for referenced documents

+        final String fileName = "Three.wsdl";

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", fileName);

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation;

+        description = modelRoot.getDescription();

+        final ModelManager mm = ModelManager.getInstance();

+

+        IDescription wDesc = (IDescription) mm.getWriteSupport(description);

+        // check add and remove operations for old serviceinterface

+        interfaceObj = description.getInterface("PurchaseOrderConfirmation").get(0);

+        IServiceInterface wInterface = (IServiceInterface) mm.getWriteSupport(interfaceObj);

+        operation = wInterface.addOperation("newReqResponseOperation", OperationType.REQUEST_RESPONSE);

+        assertNotNull("New operation 'newReqResponseOperation' could not be added successfully", operation);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllFaults().size());

+        assertEquals("newReqResponseOperation", operation.getName());

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+        assertEquals(operation.getParent(), interfaceObj);

+        assertEquals(operation.getRoot(), description);

+        assertEquals(2, interfaceObj.getAllOperations().size());

+

+        operation = wInterface.addOperation("newAsyncOperation", OperationType.ASYNCHRONOUS);

+        assertNotNull("New operation 'newAsyncOperation' could not be added successfully", operation);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllFaults().size());

+        assertEquals("newAsyncOperation", operation.getName());

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+        assertEquals(operation.getParent(), interfaceObj);

+        assertEquals(operation.getRoot(), description);

+        assertEquals(3, interfaceObj.getAllOperations().size());

+

+        wInterface.setDocumentation("Documentation");

+        assertEquals("Documentation", interfaceObj.getDocumentation());

+        wInterface.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", interfaceObj.getDocumentation());

+

+        interfaceObj = wDesc.addInterface("newInterface");

+        wInterface = (IServiceInterface) mm.getWriteSupport(interfaceObj);

+        operation = wInterface.addOperation("newReqResponseOperation", OperationType.REQUEST_RESPONSE);

+        assertNotNull("New operation 'newReqResponseOperation' could not be added successfully", operation);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllFaults().size());

+        assertEquals("newReqResponseOperation", operation.getName());

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+        assertEquals(operation.getParent(), interfaceObj);

+        assertEquals(operation.getRoot(), description);

+        assertEquals(1, interfaceObj.getAllOperations().size());

+

+        operation = wInterface.addOperation("newAsyncOperation", OperationType.ASYNCHRONOUS);

+        assertNotNull("New operation 'newAsyncOperation' could not be added successfully", operation);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllFaults().size());

+        assertEquals("newAsyncOperation", operation.getName());

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+        assertEquals(operation.getParent(), interfaceObj);

+        assertEquals(operation.getRoot(), description);

+        assertEquals(2, interfaceObj.getAllOperations().size());

+

+        wInterface.setDocumentation("Documentation");

+        assertEquals("Documentation", interfaceObj.getDocumentation());

+        wInterface.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", interfaceObj.getDocumentation());

+

+        wInterface.removeOperation(interfaceObj.getOperation("newReqResponseOperation").get(0));

+        assertTrue(interfaceObj.getOperation("newReqResponseOperation").isEmpty());

+        wInterface.removeOperation(operation);

+        assertTrue(interfaceObj.getOperation("newAsyncOperation").isEmpty());

+

+        modelRoot = getModelRoot("Documentation.wsdl");

+        description = modelRoot.getDescription();

+        wDesc = (IDescription) mm.getWriteSupport(description);

+        List<org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface> interfaces = description.getInterface("PurchaseOrderConfirmation");

+        assertFalse(interfaces.isEmpty());

+        interfaceObj = interfaces.get(0);

+        assertEquals("Documentation\n\t\t", interfaceObj.getDocumentation());

+        wInterface = (IServiceInterface) mm.getWriteSupport(interfaceObj);

+        wInterface.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", interfaceObj.getDocumentation());

+        wInterface.setName("NewPurchaseOrderConfirmation");

+        assertEquals("NewPurchaseOrderConfirmation", interfaceObj.getName());

+        assertFalse("Could not find interface after renaming", description.getInterface("NewPurchaseOrderConfirmation").isEmpty());

+        assertNotNull("Could not find interface after renaming", description.getInterface("NewPurchaseOrderConfirmation").get(0));

+        wDesc.save();

+

+        // Test if changes are saved

+        modelRoot = getModelRoot("Documentation.wsdl");

+        description = modelRoot.getDescription();

+        interfaceObj = description.getInterface("NewPurchaseOrderConfirmation").get(0);

+        assertEquals("NewPurchaseOrderConfirmation", interfaceObj.getName());

+        assertEquals("NewDocumentation", interfaceObj.getDocumentation());

+        wInterface = (IServiceInterface) mm.getWriteSupport(interfaceObj);

+

+        modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", fileName);

+        description = modelRoot.getDescription();

+        wDesc = (IDescription) mm.getWriteSupport(description);

+        interfaceObj = description.getInterface("PurchaseOrderConfirmation").get(0);

+        wInterface = (IServiceInterface) mm.getWriteSupport(interfaceObj);

+        operation = wInterface.addOperation("NewOperation", OperationType.REQUEST_RESPONSE);

+        assertEquals(2, interfaceObj.getAllOperations().size());

+        wInterface.removeOperation(operation);

+        assertEquals(1, interfaceObj.getAllOperations().size());

+        wInterface.removeOperation(interfaceObj.getOperation("PurchaseOrderConfirmationRequestResponse_In").get(0));

+        assertEquals(0, interfaceObj.getAllOperations().size());

+    }

+

+    @Test

+    public void test_Operation() throws Exception {

+        // check for referenced documents

+        final String fileName = "TestOperation.wsdl";

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("Operations.wsdl", fileName);

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter parameter;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault faultObj;

+        description = modelRoot.getDescription();

+        final ModelManager mm = ModelManager.getInstance();

+

+        // check add and remove operations for old serviceinterface

+        interfaceObj = description.getInterface("Operations").get(0);

+        operation = interfaceObj.getOperation("SyncOperation").get(0);

+        IOperation wOperation = (IOperation) mm.getWriteSupport(operation);

+        // Test parameter addition and deletion

+        assertEquals(1, operation.getAllInputParameters().size());

+        parameter = wOperation.addInputParameter("Parameter1");

+        assertEquals(2, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        parameter = wOperation.addOutputParameter("Parameter2");

+        assertEquals(2, operation.getAllOutputParameters().size());

+        assertEquals("Parameter2", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        assertEquals("Documentation", operation.getDocumentation());

+        wOperation.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", operation.getDocumentation());

+        faultObj = wOperation.addFault("fault2");

+        assertNotNull("New Fault is null", faultObj);

+        assertEquals("fault2", faultObj.getName());

+

+        operation = interfaceObj.getOperation("SyncOperationWithNoMessage").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        // Test parameter addition and deletion

+        assertEquals(0, operation.getAllInputParameters().size());

+        parameter = wOperation.addInputParameter("Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        parameter = wOperation.addOutputParameter("Parameter2");

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals("Parameter2", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        wOperation.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("SyncOperationWithMissingMessages").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        // Test parameter addition and deletion

+        assertEquals(0, operation.getAllInputParameters().size());

+        parameter = wOperation.addInputParameter("Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        parameter = wOperation.addOutputParameter("Parameter2");

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals("Parameter2", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        assertEquals("", operation.getDocumentation());

+        wOperation.setDocumentation("Documentation");

+        assertEquals("Documentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("ASyncOperationWithNoMessage").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        // Test parameter addition and deletion

+        assertEquals(0, operation.getAllInputParameters().size());

+        parameter = wOperation.addInputParameter("Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        assertEquals("", operation.getDocumentation());

+        wOperation.setDocumentation("Documentation");

+        assertEquals("Documentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("ASyncOperationWithMissingMessage").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        // Test parameter addition and deletion

+        assertEquals(0, operation.getAllInputParameters().size());

+        parameter = wOperation.addInputParameter("Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        wOperation.setName("NewASyncOperationWithMissingMessage");

+        assertEquals("NewASyncOperationWithMissingMessage", operation.getName());

+        assertFalse("Could not find operation after renaming", interfaceObj.getOperation("NewASyncOperationWithMissingMessage").isEmpty());

+        assertNotNull("Could not find operation after renaming", interfaceObj.getOperation("NewASyncOperationWithMissingMessage").get(0));

+        assertTrue("Old operation is not renamed", interfaceObj.getOperation("ASyncOperationWithMissingMessage").isEmpty());

+

+        operation = interfaceObj.getOperation("OperationWithNoInputOutput1").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        // Test adding input parameter

+        assertEquals(0, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        parameter = wOperation.addInputParameter("Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+

+        operation = interfaceObj.getOperation("OperationWithNoInputOutput2").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        // Test adding output parameter

+        assertEquals(0, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        parameter = wOperation.addOutputParameter("Parameter1");

+        assertEquals(0, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+

+        IDescription wDesc = (IDescription) mm.getWriteSupport(description);

+        wDesc.save();

+

+        modelRoot = getModelRoot(fileName);

+        description = modelRoot.getDescription();

+

+        // Test if changes are saved

+        interfaceObj = description.getInterface("Operations").get(0);

+        operation = interfaceObj.getOperation("SyncOperation").get(0);

+        assertEquals(2, operation.getAllInputParameters().size());

+        assertEquals(2, operation.getAllOutputParameters().size());

+        assertFalse(operation.getInputParameter("Parameter1").isEmpty());

+        assertNotNull(operation.getInputParameter("Parameter1").get(0));

+        assertFalse(operation.getOutputParameter("Parameter2").isEmpty());

+        assertNotNull(operation.getOutputParameter("Parameter2").get(0));

+        assertEquals("NewDocumentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("SyncOperationWithNoMessage").get(0);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertFalse(operation.getInputParameter("Parameter1").isEmpty());

+        assertNotNull(operation.getInputParameter("Parameter1").get(0));

+        assertFalse(operation.getOutputParameter("Parameter2").isEmpty());

+        assertNotNull(operation.getOutputParameter("Parameter2").get(0));

+        assertEquals("NewDocumentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("SyncOperationWithMissingMessages").get(0);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertFalse(operation.getInputParameter("Parameter1").isEmpty());

+        assertNotNull(operation.getInputParameter("Parameter1").get(0));

+        assertFalse(operation.getOutputParameter("Parameter2").isEmpty());

+        assertNotNull(operation.getOutputParameter("Parameter2").get(0));

+        assertEquals("Documentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("ASyncOperationWithNoMessage").get(0);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertFalse(operation.getInputParameter("Parameter1").isEmpty());

+        assertNotNull(operation.getInputParameter("Parameter1").get(0));

+        assertEquals("Documentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("NewASyncOperationWithMissingMessage").get(0);

+        assertNotNull("Operation NewASyncOperationWithMissingMessage could not be found", operation);

+

+        operation = interfaceObj.getOperation("OperationWithNoInputOutput1").get(0);

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(1, operation.getAllInputParameters().size());

+

+        operation = interfaceObj.getOperation("OperationWithNoInputOutput2").get(0);

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllInputParameters().size());

+

+        // Test Removal of parameters and faults

+        operation = interfaceObj.getOperation("SyncOperation").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        assertEquals(2, operation.getAllInputParameters().size());

+        parameter = wOperation.addInputParameter("Parameter4");

+        assertEquals(3, operation.getAllInputParameters().size());

+        wOperation.removeInputParameter(parameter);

+        assertEquals(2, operation.getAllInputParameters().size());

+        assertTrue("Parameter4 is not deleted", operation.getInputParameter("Parameter4").isEmpty());

+        wOperation.removeInputParameter(operation.getInputParameter("Parameter1").get(0));

+        assertEquals(1, operation.getAllInputParameters().size());

+

+        assertEquals(2, operation.getAllOutputParameters().size());

+        parameter = wOperation.addOutputParameter("Parameter4");

+        assertEquals(3, operation.getAllOutputParameters().size());

+        wOperation.removeOutputParameter(parameter);

+        assertEquals(2, operation.getAllOutputParameters().size());

+        assertTrue("Parameter4 is not deleted", operation.getOutputParameter("Parameter4").isEmpty());

+        wOperation.removeOutputParameter(operation.getOutputParameter("Parameter2").get(0));

+        assertEquals(1, operation.getAllOutputParameters().size());

+

+        assertEquals(2, operation.getAllFaults().size());

+        wOperation.removeFault(operation.getFault("fault2").get(0));

+        assertTrue("fault2 is not deleted", operation.getFault("fault2").isEmpty());

+        assertEquals(1, operation.getAllFaults().size());

+        wOperation.removeFault(operation.getFault("fault1").get(0));

+        assertTrue("fault1 is not deleted", operation.getFault("fault1").isEmpty());

+        assertEquals(0, operation.getAllFaults().size());

+

+        operation = interfaceObj.getOperation("ASyncOperation").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        parameter = wOperation.addInputParameter("parameter1");

+        assertEquals(2, operation.getAllInputParameters().size());

+        wOperation.removeInputParameter(parameter);

+        assertEquals(1, operation.getAllInputParameters().size());

+        wOperation.removeInputParameter(operation.getInputParameter("parameters").get(0));

+        assertEquals(0, operation.getAllInputParameters().size());

+

+        operation = interfaceObj.getOperation("SyncOperation1").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+        wOperation.setOperationType(OperationType.ASYNCHRONOUS);

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+

+        operation = interfaceObj.getOperation("ASyncOperation1").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+        wOperation.setOperationType(OperationType.REQUEST_RESPONSE);

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+

+        operation = interfaceObj.getOperation("SyncOperation2").get(0);

+        wOperation = (IOperation) mm.getWriteSupport(operation);

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertEquals(4, parameters.size());

+

+        wOperation.removeOutputParameter(operation.getOutputParameter("Parameter1").get(0));

+        parameters = operation.getAllOutputParameters();

+        assertEquals(3, parameters.size());

+        wDesc = (IDescription) mm.getWriteSupport(description);

+        wDesc.save();

+

+        modelRoot = getModelRoot(fileName);

+        description = modelRoot.getDescription();

+

+        // Test if removal changes are saved

+        interfaceObj = description.getInterface("Operations").get(0);

+

+        operation = interfaceObj.getOperation("SyncOperation").get(0);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertTrue("Parameter4 is not deleted", operation.getInputParameter("Parameter4").isEmpty());

+        assertTrue("Parameter1 is not deleted", operation.getInputParameter("Parameter1").isEmpty());

+

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertTrue("Parameter4 is not deleted", operation.getOutputParameter("Parameter4").isEmpty());

+        assertTrue("Parameter2 is not deleted", operation.getOutputParameter("Parameter2").isEmpty());

+        assertEquals(0, operation.getAllFaults().size());

+

+        operation = interfaceObj.getOperation("ASyncOperation").get(0);

+        assertEquals(0, operation.getAllInputParameters().size());

+

+        operation = interfaceObj.getOperation("SyncOperation1").get(0);

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+

+        operation = interfaceObj.getOperation("ASyncOperation1").get(0);

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+

+        operation = interfaceObj.getOperation("SyncOperation2").get(0);

+        parameters = operation.getAllInputParameters();

+        assertEquals(4, parameters.size());

+        Iterator<IParameter> paramIter = parameters.iterator();

+        assertEquals("Parameter1", paramIter.next().getName());

+        assertEquals("Parameter2", paramIter.next().getName());

+        assertEquals("Parameter3", paramIter.next().getName());

+        assertEquals("Parameter4", paramIter.next().getName());

+

+        operation.getOutputParameter("Parameter1");

+        parameters = operation.getAllOutputParameters();

+        assertEquals(3, parameters.size());

+        paramIter = parameters.iterator();

+        assertEquals("Parameter2", paramIter.next().getName());

+        assertEquals("Parameter3", paramIter.next().getName());

+        assertEquals("Parameter4", paramIter.next().getName());

+    }

+

+    @Test

+    public void test_Parameter() throws Exception {

+        final String fileName = "TestParameter.wsdl";

+        IFile file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "po.xsd", Document_FOLDER_NAME,

+                this.getProject(), "po.xsd");

+        assertTrue("File po.xsd could not be obtained", file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "example.xsd", Document_FOLDER_NAME,

+                this.getProject(), "example.xsd");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "NullNamespace.xsd",

+                Document_FOLDER_NAME, this.getProject(), "NullNamespace.xsd");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "ParameterType.xsd",

+                Document_FOLDER_NAME, this.getProject(), "ParameterType.xsd");

+        assertTrue("File example.xsd could not be obtained", file.exists());

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("ParameterType.wsdl", fileName);

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation;

+        IParameter parameter;

+

+        description = modelRoot.getDescription();

+        final ModelManager mm = ModelManager.getInstance();

+

+        // check add and remove operations for old serviceinterface

+        interfaceObj = description.getInterface("ServiceInterface").get(0);

+        operation = interfaceObj.getOperation("Operation").get(0);

+        parameter = operation.getInputParameter("parameters").get(0);

+        org.eclipse.wst.sse.sieditor.model.write.wsdl.api.IParameter wParameter;

+

+        wParameter = (org.eclipse.wst.sse.sieditor.model.write.wsdl.api.IParameter) mm.getWriteSupport(parameter);

+        wParameter.setName("Parameter1");

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals("", parameter.getDocumentation());

+        wParameter.setDocumentation("Documentation");

+        assertEquals("Documentation", parameter.getDocumentation());

+

+        ISchema inlineSchema = description.getSchema("http://sap.com/xi/Purchasing")[0];

+

+        // Set Type and Element from same WSDL

+        assertEquals("NewOperation", parameter.getType().getName());

+        wParameter.setType(inlineSchema.getType(false, "Address"), false);

+        assertEquals("Address", parameter.getType().getName());

+        wParameter.setType(inlineSchema.getType(false, "BusinessTransactionDocumentID"), false);

+        assertEquals("BusinessTransactionDocumentID", parameter.getType().getName());

+        wParameter.setType(inlineSchema.getType(false, "LanguageCode"), false);

+        assertEquals("LanguageCode", parameter.getType().getName());

+        wParameter.setType(inlineSchema.getType(false, "BusinessTransactionDocumentID"), false);

+        wParameter.setType(inlineSchema.getType(true, "PurchaseOrderConfirmationRequest"), false);

+        assertEquals("PurchaseOrderConfirmationRequest", parameter.getType().getName());

+        inlineSchema = description.getSchema("http://www.example.org/ParameterType/")[0];

+        wParameter.setType(inlineSchema.getType(true, "NewOperation"), false);

+        assertEquals("NewOperation", parameter.getType().getName());

+        wParameter.setType(inlineSchema.getType(false, "complexType"), false);

+        assertEquals("complexType", parameter.getType().getName());

+

+        SchemaNamespaceCondition condition = new SchemaNamespaceCondition("");

+

+        // Set Type and Element from imported XSD

+        condition.setNamespace("http://www.example.com/");

+        inlineSchema = getSchema(description.getAllVisibleSchemas(), condition);

+        wParameter.setType(inlineSchema.getType(false, "Address"), false);

+        assertEquals("Address", parameter.getType().getName());

+        wParameter.setType(inlineSchema.getType(true, "purchaseOrder"), false);

+        assertEquals("purchaseOrder", parameter.getType().getName());

+        // Set Type from included XSD

+        condition.setNamespace("http://www.example.com/IPO");

+

+        ISchema[] ipoSchemas = description.getSchema("http://www.example.com/IPO");

+        assertEquals(3, ipoSchemas.length);

+        inlineSchema = getSchema1(ipoSchemas[0].getAllReferredSchemas(), condition);

+        if (inlineSchema == null || inlineSchema.getType(false, "Address") == null) {

+            inlineSchema = getSchema1(ipoSchemas[1].getAllReferredSchemas(), condition);

+        }

+        if (inlineSchema == null || inlineSchema.getType(false, "Address") == null) {

+            inlineSchema = getSchema1(ipoSchemas[2].getAllReferredSchemas(), condition);

+        }

+

+        wParameter.setType(inlineSchema.getType(false, "Address"), false);

+        assertEquals("Address", parameter.getType().getName());

+        wParameter.setType(inlineSchema.getType(true, "purchaseOrder"), false);

+        assertEquals("purchaseOrder", parameter.getType().getName());

+        // Set Type form XSD With Null namespace

+        inlineSchema = description.getSchema("http://www.example.com/IPO/Include/NullNamespace")[0];

+        condition.setNamespace(null);

+        inlineSchema = getSchema1(inlineSchema.getAllReferredSchemas(), condition);

+        wParameter.setType(inlineSchema.getType(false, "Address"), false);

+        assertEquals("Address", parameter.getType().getName());

+        wParameter.setType(inlineSchema.getType(true, "purchaseOrder"), false);

+        assertEquals("purchaseOrder", parameter.getType().getName());

+        // Set Type from XSD With Same Namespace

+        condition.setNamespace("http://www.example.org/ParameterType/");

+        inlineSchema = getSchema(description.getContainedSchemas(), condition);

+        wParameter.setType(inlineSchema.getType(true, "NewOperation"), false);

+        assertEquals("NewOperation", parameter.getType().getName());

+        wParameter.setType(inlineSchema.getType(false, "complexType"), false);

+        assertEquals("complexType", parameter.getType().getName());

+

+        ResourceUtils.createFolderInProject(getProject(), "src");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported.xsd", SOURCE_FOLDER, this

+                .getProject(), "Imported.xsd");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "SupplierInvoice.wsdl", SOURCE_FOLDER,

+                this.getProject(), "SupplierInvoice.wsdl");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestSingleSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestSingleSchema.wsdl");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestMultipleSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestMultipleSchema.wsdl");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestExternal.xsd",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestExternal.xsd");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestImportedSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestImportedSchema.wsdl");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestIncludedSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestIncludedSchema.wsdl");

+

+        modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "ParameterTypeTwo.wsdl");

+        description = modelRoot.getDescription();

+        interfaceObj = description.getInterface("PurchaseOrderConfirmation").get(0);

+        operation = interfaceObj.getOperation("PurchaseOrderConfirmationRequestResponse_In").get(0);

+        parameter = operation.getInputParameter("parameters").get(0);

+        wParameter = (org.eclipse.wst.sse.sieditor.model.write.wsdl.api.IParameter) mm.getWriteSupport(parameter);

+    }

+

+    @Test

+    public void test_Fault() throws Exception {

+        // check for referenced documents

+        final String fileName = "TestOperationFault.wsdl";

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("Operations.wsdl", fileName);

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter parameter;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault faultObj;

+        description = modelRoot.getDescription();

+        final ModelManager mm = ModelManager.getInstance();

+

+        interfaceObj = description.getInterface("Operations").get(0);

+        operation = interfaceObj.getOperation("TestFault").get(0);

+        faultObj = operation.getFault("fault1").get(0);

+        IFault wFaultObj = (IFault) mm.getWriteSupport(faultObj);

+        assertEquals("fault1", faultObj.getName());

+        wFaultObj.setName("newFault");

+        assertEquals("newFault", faultObj.getName());

+        assertEquals("", faultObj.getDocumentation());

+        wFaultObj.setDocumentation("Documentation");

+        assertEquals("Documentation", faultObj.getDocumentation());

+        wFaultObj.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", faultObj.getDocumentation());

+        assertEquals(1, faultObj.getParameters().size());

+        parameter = wFaultObj.addParameter("Parameter1");

+        parameter = wFaultObj.addParameter("Parameter2");

+        assertEquals(3, faultObj.getParameters().size());

+        wFaultObj.removeParameter(faultObj.getParameter("parameters").get(0));

+        assertEquals(2, faultObj.getParameters().size());

+        wFaultObj.removeParameter(parameter);

+        assertEquals(1, faultObj.getParameters().size());

+

+        faultObj = operation.getFault("fault2").get(0);

+        wFaultObj = (IFault) mm.getWriteSupport(faultObj);

+        assertEquals(4, faultObj.getParameters().size());

+

+        faultObj = operation.getFault("faultWithMissingMessage").get(0);

+        assertEquals(0, faultObj.getParameters().size());

+        wFaultObj = (IFault) mm.getWriteSupport(faultObj);

+        parameter = wFaultObj.addParameter("Parameter1");

+        parameter = wFaultObj.addParameter("Parameter2");

+        assertEquals(2, faultObj.getParameters().size());

+        wFaultObj.removeParameter(parameter);

+        assertEquals(1, faultObj.getParameters().size());

+

+        faultObj = operation.getFault("faultWithNoMessage").get(0);

+        assertEquals(0, faultObj.getParameters().size());

+        wFaultObj = (IFault) mm.getWriteSupport(faultObj);

+        parameter = wFaultObj.addParameter("Parameter1");

+        parameter = wFaultObj.addParameter("Parameter2");

+        assertEquals(2, faultObj.getParameters().size());

+        wFaultObj.removeParameter(parameter);

+        assertEquals(1, faultObj.getParameters().size());

+

+        operation = interfaceObj.getOperation("ASyncOperation").get(0);

+        assertEquals(0, operation.getAllFaults().size());

+        IOperation wOperation = (IOperation) mm.getWriteSupport(operation);

+        faultObj = wOperation.addFault("newFault");

+        wFaultObj = (IFault) mm.getWriteSupport(faultObj);

+        wFaultObj.addParameter("Parameter1");

+        assertEquals(2, faultObj.getParameters().size());

+

+        IDescription wDescription = (IDescription) mm.getWriteSupport(description);

+        wDescription.save();

+

+        modelRoot = getModelRoot("TestOperationFault.wsdl");

+        interfaceObj = description.getInterface("Operations").get(0);

+        operation = interfaceObj.getOperation("TestFault").get(0);

+        faultObj = operation.getFault("newFault").get(0);

+        assertEquals(1, faultObj.getParameters().size());

+        assertEquals("NewDocumentation", faultObj.getDocumentation());

+        assertFalse("Could not find parameter Parameter1", faultObj.getParameter("Parameter1").isEmpty());

+        assertNotNull("Could not find parameter Parameter1", faultObj.getParameter("Parameter1").get(0));

+

+        faultObj = operation.getFault("fault2").get(0);

+        assertEquals(4, faultObj.getParameters().size());

+        Iterator<IParameter> paramIter = faultObj.getParameters().iterator();

+        assertEquals("Parameter1", paramIter.next().getName());

+        assertEquals("Parameter2", paramIter.next().getName());

+        assertEquals("Parameter3", paramIter.next().getName());

+        assertEquals("Parameter4", paramIter.next().getName());

+

+        faultObj = operation.getFault("faultWithMissingMessage").get(0);

+        assertEquals(1, faultObj.getParameters().size());

+

+        faultObj = operation.getFault("faultWithNoMessage").get(0);

+        assertEquals(1, faultObj.getParameters().size());

+

+        operation = interfaceObj.getOperation("ASyncOperation").get(0);

+        faultObj = operation.getFault("newFault").get(0);

+        assertEquals(2, faultObj.getParameters().size());

+        assertFalse("Could not find parameter Parameter1", faultObj.getParameter("Parameter1").isEmpty());

+        assertNotNull("Could not find parameter Parameter1", faultObj.getParameter("Parameter1").get(0));

+

+    }

+

+    private ISchema getSchema(final Collection<ISchema> schemas, ICondition<ISchema> condition) {

+        for (ISchema schema : schemas) {

+            if (condition.isSatisfied(schema))

+                return schema;

+        }

+        return null;

+    }

+

+    private ISchema getSchema1(final Collection<ISchema> schemas, ICondition<ISchema> condition) {

+        for (ISchema schema : schemas) {

+            if (condition.isSatisfied(schema))

+                return schema;

+        }

+        return null;

+    }

+

+    interface ICondition<T> {

+        boolean isSatisfied(T in);

+    }

+

+    private class SchemaNamespaceCondition implements ICondition<ISchema> {

+

+        private String _namespace;

+

+        public SchemaNamespaceCondition(final String namespace) {

+            this._namespace = namespace;

+        }

+

+        public boolean isSatisfied(ISchema in) {

+            if ((null == _namespace && null == in.getNamespace()) || (null != _namespace && _namespace.equals(in.getNamespace())))

+                return true;

+            return false;

+        }

+

+        public void setNamespace(final String namespace) {

+            this._namespace = namespace;

+        }

+

+    }

+

+    private IWsdlModelRoot copyAndGetModelRoot(final String fileName, final String targetName) throws Exception {

+        return getWSDLModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV + fileName, targetName);

+    }

+

+    private IWsdlModelRoot getModelRoot(final String fileName) throws Exception {

+        final IFile file = (IFile) getProject().findMember(new Path(Document_FOLDER_NAME + IPath.SEPARATOR + fileName));

+        assertTrue(file.exists());

+        final IWsdlModelRoot modelRoot = ModelManager.getInstance().getWsdlModelRoot(new FileEditorInput(file));

+

+        setupEnvironment(modelRoot);

+

+        return modelRoot;

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/SetAPIXSDWriteTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/SetAPIXSDWriteTest.java
new file mode 100644
index 0000000..713e062
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/SetAPIXSDWriteTest.java
@@ -0,0 +1,1288 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.Collection;

+import java.util.Collections;

+import java.util.HashMap;

+import java.util.List;

+import java.util.Map;

+

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.runtime.IPath;

+import org.eclipse.core.runtime.Path;

+import org.eclipse.ui.part.FileEditorInput;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.eclipse.xsd.XSDComplexTypeDefinition;

+import org.eclipse.xsd.XSDDerivationMethod;

+import org.eclipse.xsd.XSDElementDeclaration;

+import org.eclipse.xsd.XSDModelGroup;

+import org.eclipse.xsd.XSDNamedComponent;

+import org.eclipse.xsd.XSDParticle;

+import org.eclipse.xsd.XSDSimpleTypeDefinition;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.mm.ModelManager;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.generic.IllegalInputException;

+import org.eclipse.wst.sse.sieditor.model.utils.EmfXsdUtils;

+import org.eclipse.wst.sse.sieditor.model.write.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.write.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.write.xsd.api.ISimpleType;

+import org.eclipse.wst.sse.sieditor.model.write.xsd.api.IStructureType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IElement;

+import org.eclipse.wst.sse.sieditor.model.xsd.impl.StructureType;

+

+/*

+ * Those tests should be removed after the xsd write API gets removed.

+ */

+@SuppressWarnings("nls")

+public class SetAPIXSDWriteTest extends SIEditorBaseTest {

+

+    private static final String SOURCE_FOLDER = "src/wsdl";

+

+    protected String getProjectName() {

+        return "XSDWriteTest";

+    }

+

+    @Test

+    public void testSchema() throws Exception {

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "TestWriteSchema1.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        description = modelRoot.getDescription();

+        final ModelManager mm = ModelManager.getInstance();

+

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://sap.com/xi/Purchasing")[0];

+        ISchema wSchema = (ISchema) mm.getWriteSupport(schema);

+        assertEquals("http://sap.com/xi/Purchasing", schema.getNamespace());

+        wSchema.setNamespace("http://sap.com/xi/Purchasing/New");

+        assertEquals("http://sap.com/xi/Purchasing/New", schema.getNamespace());

+        assertEquals("", schema.getDocumentation());

+        wSchema.setDocumentation("Documentation");

+        assertEquals("Documentation", schema.getDocumentation());

+        wSchema.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", schema.getDocumentation());

+

+        // test creation of global type from anonymous

+        org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType address = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema

+                .getType(false, "Address");

+        IElement officeElement = address.getElements("Office").iterator().next();

+        wSchema.createGlobalTypeFromAnonymous(officeElement, "Office");

+        assertNotNull(schema.getType(false, "Office"));

+

+        IDescription wDescription = (IDescription) mm.getWriteSupport(description);

+        wDescription.save();

+

+        modelRoot = getModelRoot("TestWriteSchema1.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://sap.com/xi/Purchasing/New")[0];

+        assertEquals("NewDocumentation", schema.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "TestWriteSchema2.wsdl");

+        description = modelRoot.getDescription();

+        wDescription = (IDescription) mm.getWriteSupport(description);

+        schema = description.getSchema("http://sap.com/xi/Purchasing")[0];

+        wSchema = (ISchema) mm.getWriteSupport(schema);

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType simpleType = wSchema.addSimpleType("NewSimpleType");

+        assertNotNull("Could not find Newly added type NewSimpleType", schema.getType(false, "NewSimpleType"));

+        assertEquals("string", simpleType.getBaseType().getName());

+        wSchema.addStructureType("NewStructureType", false);

+        assertNotNull("Could not find Newly added type NewStructureType", schema.getType(false, "NewStructureType"));

+        assertNotNull("Could not find element PurchaseOrderConfirmationRequest", schema.getType(true,

+                "PurchaseOrderConfirmationRequest"));

+        wSchema.removeType(schema.getType(true, "PurchaseOrderConfirmationRequest"));

+        assertNull("Element PurchaseOrderConfirmationRequest is not deleted", schema.getType(true,

+                "PurchaseOrderConfirmationRequest"));

+        assertNotNull("Could not find SimpleType ActionCode", schema.getType(false, "ActionCode"));

+        wSchema.removeType(schema.getType(false, "ActionCode"));

+        assertNull("SimpleType ActionCode is not deleted", schema.getType(false, "ActionCode"));

+        assertNotNull("Could not find StructureType Attachment", schema.getType(false, "Attachment"));

+        wSchema.removeType(schema.getType(false, "Attachment"));

+        assertNull("StructureType Attachment is not deleted", schema.getType(false, "Attachment"));

+        wDescription.save();

+

+        modelRoot = getModelRoot("TestWriteSchema2.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://sap.com/xi/Purchasing")[0];

+        assertNotNull("Could not find Newly added type NewSimpleType", schema.getType(false, "NewSimpleType"));

+        assertNotNull("Could not find Newly added type NewStructureType", schema.getType(false, "NewStructureType"));

+        assertNull("Element PurchaseOrderConfirmationRequest is not deleted", schema.getType(true,

+                "PurchaseOrderConfirmationRequest"));

+        assertNull("SimpleType ActionCode is not deleted", schema.getType(false, "ActionCode"));

+        assertNull("StructureType Attachment is not deleted", schema.getType(false, "Attachment"));

+    }

+

+    @Test

+    public void testSimpleType() throws Exception {

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("SimpleType.wsdl", "TestSimpleType.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        ISimpleType wSimpleType;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType simpleType;

+        description = modelRoot.getDescription();

+        final ModelManager mm = ModelManager.getInstance();

+

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/SimpleType/")[0];

+        assertNotNull("Could not find schema http://www.example.org/SimpleType/", schema);

+

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "stringType");

+        assertEquals("stringType", simpleType.getName());

+        wSimpleType = (ISimpleType) mm.getWriteSupport(simpleType);

+        wSimpleType.setName("NewType");

+        assertEquals("NewType", simpleType.getName());

+        assertNotNull("Could not find SimpleType NewType", schema.getType(false, "NewType"));

+        assertEquals("Documentation", simpleType.getDocumentation());

+        wSimpleType.setDocumentation("DocumentationOne");

+        assertEquals("DocumentationOne", simpleType.getDocumentation());

+        wSimpleType.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", simpleType.getDocumentation());

+        IDescription wDescription = (IDescription) mm.getWriteSupport(description);

+        wDescription.save();

+

+        modelRoot = getModelRoot("TestSimpleType.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/SimpleType/")[0];

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "NewType");

+        assertEquals("NewType", simpleType.getName());

+        assertEquals("NewDocumentation", simpleType.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("SimpleType.wsdl", "TestSimpleType.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/SimpleType/")[0];

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "stringType");

+        wSimpleType = (ISimpleType) mm.getWriteSupport(simpleType);

+        assertEquals("1", simpleType.getMinLength());

+        wSimpleType.setMinLength(2);

+        assertEquals("2", simpleType.getMinLength());

+        assertEquals("10", simpleType.getMaxLength());

+        wSimpleType.setMaxLength(11);

+        assertEquals("11", simpleType.getMaxLength());

+        assertEquals(2, simpleType.getEnumerations().length);

+        assertEquals("value1", simpleType.getEnumerations()[0].getValue());

+        assertEquals("value2", simpleType.getEnumerations()[1].getValue());

+        wSimpleType.addEnumeration("value4");

+        assertEquals(3, simpleType.getEnumerations().length);

+        assertEquals("value4", simpleType.getEnumerations()[2].getValue());

+        wSimpleType.removeEnumeration(simpleType.getEnumerations()[0]);

+        assertEquals(2, simpleType.getEnumerations().length);

+        assertEquals(2, simpleType.getPatterns().length);

+        assertEquals("value*", simpleType.getPatterns()[0].getValue());

+        assertEquals("v*", simpleType.getPatterns()[1].getValue());

+        wSimpleType.addPattern("va*");

+        assertEquals(3, simpleType.getPatterns().length);

+        assertEquals("va*", simpleType.getPatterns()[2].getValue());

+        wSimpleType.removePattern(simpleType.getPatterns()[0]);

+        assertEquals(2, simpleType.getPatterns().length);

+

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "intType");

+        wSimpleType = (ISimpleType) mm.getWriteSupport(simpleType);

+        assertEquals("1", simpleType.getMinLength());

+        assertEquals("10", simpleType.getMaxLength());

+        wSimpleType.setMaxLength(11);

+        assertEquals("11", simpleType.getMaxLength());

+        assertEquals("1", simpleType.getMinInclusive());

+        wSimpleType.setMinInclusive(4 + "");

+        assertEquals("4", simpleType.getMinInclusive());

+        assertEquals("1098098988", simpleType.getMaxInclusive());

+        wSimpleType.setMaxInclusive("1098098989");

+        assertEquals("1098098989", simpleType.getMaxInclusive());

+        assertEquals("", simpleType.getDocumentation());

+        wSimpleType.setDocumentation("Documentation");

+        assertEquals("Documentation", simpleType.getDocumentation());

+        wSimpleType.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", simpleType.getDocumentation());

+

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "intType1");

+        wSimpleType = (ISimpleType) mm.getWriteSupport(simpleType);

+        assertEquals("1", simpleType.getMinLength());

+        assertEquals("10", simpleType.getMaxLength());

+        wSimpleType.setMaxLength(11);

+        assertEquals("11", simpleType.getMaxLength());

+        assertEquals("1", simpleType.getMinExclusive());

+        wSimpleType.setMinExclusive("4");

+        assertEquals("4", simpleType.getMinExclusive());

+        assertEquals("1098098988", simpleType.getMaxExclusive());

+        wSimpleType.setMaxExclusive("1098098989");

+        assertEquals("1098098989", simpleType.getMaxExclusive());

+        assertEquals("", simpleType.getDocumentation());

+        wSimpleType.setDocumentation("Documentation");

+        assertEquals("Documentation", simpleType.getDocumentation());

+        wSimpleType.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", simpleType.getDocumentation());

+

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "stringType1");

+        wSimpleType = (ISimpleType) mm.getWriteSupport(simpleType);

+        assertEquals("10", simpleType.getLength());

+        wSimpleType.setLength(11);

+        assertEquals("11", simpleType.getLength());

+

+        SchemaNamespaceCondition condition = new SchemaNamespaceCondition("");

+

+        condition.setNamespace(EmfXsdUtils.getSchemaForSchemaNS());

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schemaForSchema = getSchema(description.getAllVisibleSchemas(),

+                condition);

+        assertEquals("string", simpleType.getBaseType().getName());

+        wSimpleType.setBaseType(schemaForSchema.getType(false, "int"));

+        assertEquals("int", simpleType.getBaseType().getName());

+        wSimpleType.setBaseType(schema.getType(false, "stringType"));

+        assertEquals("stringType", simpleType.getBaseType().getName());

+        wSimpleType.setBaseType(schema.getType(false, "intType"));

+        assertEquals("intType", simpleType.getBaseType().getName());

+        wSimpleType.setBaseType(schema.getType(false, "complexType"));

+        assertEquals("intType", simpleType.getBaseType().getName());

+        wSimpleType.setBaseType(schema.getType(true, "NewOperation"));

+        assertEquals("intType", simpleType.getBaseType().getName());

+

+        ResourceUtils.createFolderInProject(getProject(), "src");

+        IFile file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported.xsd", SOURCE_FOLDER,

+                this.getProject(), "Imported.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported.xsd", Document_FOLDER_NAME,

+                this.getProject(), "Imported.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "SupplierInvoice.wsdl", SOURCE_FOLDER,

+                this.getProject(), "SupplierInvoice.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestSingleSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestSingleSchema.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestMultipleSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestMultipleSchema.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestExternal.xsd",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestExternal.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestImportedSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestImportedSchema.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestIncludedSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestIncludedSchema.wsdl");

+        assertTrue(file.exists());

+

+        modelRoot = copyAndGetModelRoot("SimpleTypeWriteTest.wsdl", "TestSimpleType1.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/SimpleType/")[0];

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema2 = description.getSchema("http://sap.com/xi/Purchasing")[0];

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "stringType");

+        wSimpleType = (ISimpleType) mm.getWriteSupport(simpleType);

+        assertEquals("string", simpleType.getBaseType().getName());

+        wSimpleType.setBaseType(schema2.getType(false, "AcceptanceStatusCode"));

+        assertEquals("AcceptanceStatusCode", simpleType.getBaseType().getName());

+        wSimpleType.setBaseType(schema2.getType(false, "ActionCode"));

+        assertEquals("ActionCode", simpleType.getBaseType().getName());

+        condition.setNamespace("http://www.example.com/Imported.xsd");

+        schema2 = getSchema1(schema.getAllReferredSchemas(), condition);

+        wSimpleType.setBaseType(schema2.getType(false, "SKU"));

+        assertEquals("SKU", simpleType.getBaseType().getName());

+    }

+

+    private org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema getSchema1(

+            Collection<org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema> collection, SchemaNamespaceCondition condition) {

+        for (org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema : collection) {

+            if (condition.isSatisfied(schema))

+                return schema;

+        }

+        return null;

+    }

+

+    @Test

+    public void testStructureType() throws Exception {

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        IStructureType wStructureType;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType structureType;

+        description = modelRoot.getDescription();

+        final ModelManager mm = ModelManager.getInstance();

+

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        assertNotNull("Could not find schema http://www.example.org/StructureType/", schema);

+        // Test documentation and name

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        assertEquals("complexType", structureType.getName());

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        wStructureType.setName("NewType");

+        assertEquals("NewType", structureType.getName());

+        assertNotNull("Could not find SimpleType NewType", schema.getType(false, "NewType"));

+        assertEquals("Documentation", structureType.getDocumentation());

+        wStructureType.setDocumentation("DocumentationOne");

+        assertEquals("DocumentationOne", structureType.getDocumentation());

+        wStructureType.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+        assertEquals("complexType", structureType.getName());

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        wStructureType.setName("NewElement");

+        assertEquals("NewElement", structureType.getName());

+        assertNotNull("Could not find StructureType NewElement", schema.getType(true, "NewElement"));

+        assertEquals("Documentation", structureType.getDocumentation());

+        wStructureType.setDocumentation("DocumentationOne");

+        assertEquals("DocumentationOne", structureType.getDocumentation());

+        wStructureType.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", structureType.getDocumentation());

+        IDescription wDescription = (IDescription) mm.getWriteSupport(description);

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctWithAttributes");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals("", structureType.getDocumentation());

+        wStructureType.setDocumentation("Documentation");

+        assertEquals("Documentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals("", structureType.getDocumentation());

+        wStructureType.setDocumentation("Documentation");

+        assertEquals("Documentation", structureType.getDocumentation());

+        wDescription.save();

+

+        modelRoot = getModelRoot("TestStructureType.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "NewType");

+        assertEquals("NewType", structureType.getName());

+        assertEquals("NewDocumentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "NewElement");

+        assertEquals("NewElement", structureType.getName());

+        assertEquals("NewDocumentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctWithAttributes");

+        assertEquals("Documentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+        assertEquals("Documentation", structureType.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType1.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // add an element in complexType with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(2, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        IElement element = wStructureType.addElement("elementParticle2");

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle2").size());

+        wStructureType.removeElement("elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        // add an element in complexType with choice

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema

+                .getType(false, "groupDefinitionType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(6, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = wStructureType.addElement("elementParticle5");

+        assertEquals(7, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        wStructureType.removeElement("elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        // add an element in complexType with all

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "allModelGroupType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(6, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = wStructureType.addElement("elementParticle5");

+        assertEquals(7, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        wStructureType.removeElement("elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        // add an element in element declaration with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(2, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        element = wStructureType.addElement("elementParticle2");

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle2").size());

+        wStructureType.removeElement("elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        // add an element in element declaration with simpleType reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithSimpleTypeRef");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(0, structureType.getAllElements().size());

+        XSDElementDeclaration elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        assertNull("element has anonymous type", elementDecl.getAnonymousTypeDefinition());

+        element = wStructureType.addElement("elementParticle");

+        assertEquals(1, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertNull("referred type name is not null", elementDecl.getTypeDefinition().getName());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in element declaration with complexType reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithComplexTypeRef");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(0, structureType.getAllElements().size());

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        assertNull("element has anonymous type", elementDecl.getAnonymousTypeDefinition());

+        element = wStructureType.addElement("elementParticle");

+        assertEquals(1, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertNull("referred type name is not null", elementDecl.getTypeDefinition().getName());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        wStructureType.removeElement("elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in element declaration with open content

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "openContentElement");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(0, structureType.getAllElements().size());

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        assertNull("element has anonymous type", elementDecl.getAnonymousTypeDefinition());

+        element = wStructureType.addElement("elementParticle");

+        assertEquals(1, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertNull("referred type name is not null", elementDecl.getTypeDefinition().getName());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in element declaration with anonymous simpleType

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithAnonymousSimpleType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(0, structureType.getAllElements().size());

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition);

+        element = wStructureType.addElement("elementParticle");

+        assertEquals(1, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("", structureType.getDocumentation());

+        wStructureType.setDocumentation("Documentation");

+        assertEquals("Documentation", structureType.getDocumentation());

+        wStructureType.removeElement("elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in complexType with complexType extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(4, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = wStructureType.addElement("elementParticle5");

+        assertEquals(5, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        wStructureType.removeElement("elementParticle3");

+        assertEquals(0, structureType.getElements("elementParticle3").size());

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        // add an element in complexType with complexType restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctRestriction");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(2, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        element = wStructureType.addElement("elementParticle2");

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle2").size());

+        wStructureType.removeElement("elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        // add an element in element with complexType with complexType extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "elementCtExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(4, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = wStructureType.addElement("elementParticle5");

+        assertEquals(5, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        wStructureType.removeElement("elementParticle3");

+        assertEquals(0, structureType.getElements("elementParticle3").size());

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        // add an element in complexType with simpleContent extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        assertTrue("ComplexType doesnt have simple content", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        element = wStructureType.addElement("elementParticle");

+        assertEquals(4, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertTrue("ComplexType doesnt have simple content", complexType.getContent() instanceof XSDParticle);

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in complexType with simpleContent restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentRestriction");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        assertTrue("ComplexType doesnt have simple content", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals(2, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        element = wStructureType.addElement("elementParticle");

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertTrue("ComplexType doesnt have simple content", complexType.getContent() instanceof XSDParticle);

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in complexType with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "nestedElements");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(8, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = wStructureType.addElement("elementParticle5");

+        assertEquals(9, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        wStructureType.removeElement("elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        wStructureType.removeElement(element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+

+        // Test Removal

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType1.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // Remove an element in complexType with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("elementParticle1").size());

+        wStructureType.removeElement("elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        // Remove an element in complexType with choice

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema

+                .getType(false, "groupDefinitionType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        wStructureType.removeElement("elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // Remove an element in complexType with all

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "allModelGroupType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        wStructureType.removeElement("elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // Remove an element in element declaration with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        wStructureType.removeElement("elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // Remove an element in complexType with complexType extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("elementParticle3").size());

+        wStructureType.removeElement("elementParticle3");

+        assertEquals(0, structureType.getElements("elementParticle3").size());

+        // Remove an element in complexType with complexType restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctRestriction");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("elementParticle1").size());

+        wStructureType.removeElement("elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        // Remove an element in element with complexType with complexType

+        // extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "elementCtExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("elementParticle3").size());

+        wStructureType.removeElement("elementParticle3");

+        assertEquals(0, structureType.getElements("elementParticle3").size());

+        // Remove an element in complexType with simpleContent extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("attribute1").size());

+        wStructureType.removeElement("attribute1");

+        assertEquals(0, structureType.getElements("attribute1").size());

+        // Remove an element in complexType with simpleContent restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentRestriction");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("attribute1").size());

+        wStructureType.removeElement("attribute1");

+        assertEquals(0, structureType.getElements("attribute1").size());

+        // Remove an element in complexType with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "nestedElements");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        assertEquals(1, structureType.getElements("attribute1").size());

+        wStructureType.removeElement("elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        assertEquals(1, structureType.getElements("attribute1").size());

+        wStructureType.removeElement("attribute1");

+        assertEquals(0, structureType.getElements("attribute1").size());

+

+        // Test Set baseType

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType2.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for element with ST Reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithSimpleTypeRef");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "simpleType"));

+        assertNotNull("anonymous simpleType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        // set CT as baseType for element with CT Reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithComplexTypeRef");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "complexType"));

+        assertNotNull("anonymous complexType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("complexType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        assertTrue(XSDDerivationMethod.EXTENSION_LITERAL.equals(((XSDComplexTypeDefinition) elementDecl

+                .getAnonymousTypeDefinition()).getDerivationMethod()));

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType4.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set CT as baseType for element with ST Reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithSimpleTypeRef");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "complexType"));

+        assertNotNull("anonymous complexType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("complexType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        assertTrue(XSDDerivationMethod.EXTENSION_LITERAL.equals(((XSDComplexTypeDefinition) elementDecl

+                .getAnonymousTypeDefinition()).getDerivationMethod()));

+        // set ST as baseType for element with CT Reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithComplexTypeRef");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "simpleType"));

+        assertNotNull("anonymous simpleType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureTypeOne.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for element with Anonymous ST

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "globalElementWithSt");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "simpleType"));

+        assertNotNull("anonymous simpleType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        // set ST as baseType for element with Anonymous CT

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "simpleType"));

+        assertNotNull("anonymous simpleType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be complexType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("simpleType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        assertTrue(XSDDerivationMethod.EXTENSION_LITERAL.equals(((XSDComplexTypeDefinition) elementDecl

+                .getAnonymousTypeDefinition()).getDerivationMethod()));

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureTypeTwo.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set CT as baseType for element with Anonymous ST

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "globalElementWithSt");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "complexType"));

+        assertNotNull("anonymous complexType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be complexType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("complexType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        // set CT as baseType for element with Anonymous CT

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "complexType"));

+        assertNotNull("anonymous complexType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be complexType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("complexType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        assertTrue(XSDDerivationMethod.RESTRICTION_LITERAL.equals(((XSDComplexTypeDefinition) elementDecl

+                .getAnonymousTypeDefinition()).getDerivationMethod()));

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureTypeFour.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for CT with Sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "simpleType"));

+        assertTrue("content must be complexType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with ctExtension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "simpleType"));

+        assertTrue("content must be complexType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with Restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctRestriction");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "simpleType"));

+        assertTrue("content must be complexType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureTypeFive.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for CT with Sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "complexType"));

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.RESTRICTION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with ctExtension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "complexType"));

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with Restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctRestriction");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "complexType"));

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.RESTRICTION_LITERAL, complexType.getDerivationMethod());

+

+        modelRoot = getModelRoot("TestStructureTypeFive.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set CT as baseType for CT with simpleContent extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "complexType"));

+        assertTrue("content must be XSDParticle", complexType.getContent() instanceof XSDParticle);

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set CT as baseType for CT with simpleContent restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentRestriction");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "complexType"));

+        assertTrue("content must be XSDParticle", complexType.getContent() instanceof XSDParticle);

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.RESTRICTION_LITERAL, complexType.getDerivationMethod());

+

+        modelRoot = getModelRoot("TestStructureTypeFive.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for CT with simpleContent extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "simpleType"));

+        assertTrue("content must be simpleType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with simpleContent restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentRestriction");

+        wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        wStructureType.setBaseType(schema.getType(false, "simpleType"));

+        assertTrue("content must be simpleType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        assertEquals(false, structureType.isAnonymous());

+    }

+

+    @Test

+    public void testElement() throws Exception {

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestElement.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType structureType;

+        org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement wElement;

+        description = modelRoot.getDescription();

+        final ModelManager mm = ModelManager.getInstance();

+

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        assertNotNull("Could not find schema http://www.example.org/StructureType/", schema);

+        // Test documentation and name

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        IElement element = structureType.getElements("elementParticle").iterator().next();

+        wElement = (org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement) mm.getWriteSupport(element);

+        assertEquals("elementParticle", element.getName());

+        wElement.setName("newName");

+        assertEquals("newName", element.getName());

+        assertEquals("Documentation", element.getDocumentation());

+        wElement.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", element.getDocumentation());

+        assertEquals(1, element.getMinOccurs());

+        wElement.setMinOccurs(2);

+        assertEquals(2, element.getMinOccurs());

+        assertEquals(1, element.getMaxOccurs());

+        wElement.setMaxOccurs(4);

+        assertEquals(4, element.getMaxOccurs());

+        assertEquals(false, element.getNillable());

+        wElement.setNillable(true);

+        assertEquals(true, element.getNillable());

+

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctWithAttributes");

+        element = structureType.getElements("elementParticle3").iterator().next();

+        wElement = (org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement) mm.getWriteSupport(element);

+        assertEquals("", element.getDocumentation());

+        wElement.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", element.getDocumentation());

+        element = structureType.getElements("globalElement").iterator().next();

+        wElement = (org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement) mm.getWriteSupport(element);

+        assertEquals(10, element.getMinOccurs());

+        wElement.setMinOccurs(13);

+        assertEquals(13, element.getMinOccurs());

+        assertEquals(100, element.getMaxOccurs());

+        wElement.setMaxOccurs(26);

+        assertEquals(26, element.getMaxOccurs());

+        assertEquals(false, element.getNillable());

+        wElement.setNillable(true);

+        assertEquals(true, element.getNillable());

+        wElement = (org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement) mm.getWriteSupport(element);

+        assertEquals("", element.getDocumentation());

+        wElement.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", element.getDocumentation());

+        element = structureType.getElements("attribute1").iterator().next();

+        wElement = (org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement) mm.getWriteSupport(element);

+        assertEquals("", element.getDocumentation());

+        wElement.setDocumentation("NewDocumentation");

+        assertEquals("NewDocumentation", element.getDocumentation());

+        assertEquals(0, element.getMinOccurs());

+        wElement.setMinOccurs(2);

+        assertEquals(0, element.getMinOccurs());

+        assertEquals(1, element.getMaxOccurs());

+        wElement.setMaxOccurs(4);

+        assertEquals(1, element.getMaxOccurs());

+        assertEquals(false, element.getNillable());

+        wElement.setNillable(true);

+        assertEquals(false, element.getNillable());

+

+        modelRoot = getModelRoot("TestElement.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        assertNotNull("Could not find schema http://www.example.org/StructureType/", schema);

+        // Test type assignment for element

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctWithAttributes");

+        element = structureType.getElements("elementParticle3").iterator().next();

+        wElement = (org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement) mm.getWriteSupport(element);

+        assertEquals("string", element.getType().getName());

+        wElement.setType(schema.getType(false, "complexType"));

+        assertEquals("complexType", element.getType().getName());

+        assertEquals("elementParticle3", element.getName());

+        wElement.setType(schema.getType(false, "simpleType"));

+        assertEquals("simpleType", element.getType().getName());

+        assertEquals("elementParticle3", element.getName());

+        wElement.setAnonymousType(true);

+        wElement.setAnonymousType(false);

+

+        element = structureType.getElements("globalElement").iterator().next();

+        wElement = (org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement) mm.getWriteSupport(element);

+        assertEquals("globalElement", element.getType().getName());

+        wElement.setType(schema.getType(false, "complexType"));

+        assertEquals("complexType", element.getType().getName());

+        assertEquals("globalElement", element.getName());

+        wElement.setType(schema.getType(false, "simpleType"));

+        assertEquals("simpleType", element.getType().getName());

+        assertEquals("globalElement", element.getName());

+        wElement.setAnonymousType(true);

+        wElement.setAnonymousType(false);

+

+        element = structureType.getElements("attribute1").iterator().next();

+        wElement = (org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement) mm.getWriteSupport(element);

+        assertEquals("string", element.getType().getName());

+        wElement.setType(schema.getType(false, "complexType"));

+        assertEquals("string", element.getType().getName());

+        assertEquals("attribute1", element.getName());

+        wElement.setType(schema.getType(false, "simpleType"));

+        assertEquals("simpleType", element.getType().getName());

+        assertEquals("attribute1", element.getName());

+        wElement.setAnonymousType(true);

+        wElement.setAnonymousType(false);

+

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+        element = structureType.getElements("globalAttribute").iterator().next();

+        wElement = (org.eclipse.wst.sse.sieditor.model.write.xsd.api.IElement) mm.getWriteSupport(element);

+        assertNull("Type must be null for attributes", element.getType());

+        wElement.setType(schema.getType(false, "complexType"));

+        assertNull("ComplexType must not be set", element.getType());

+        assertEquals("globalAttribute", element.getName());

+        wElement.setType(schema.getType(false, "simpleType"));

+        assertEquals("simpleType", element.getType().getName());

+        assertEquals("globalAttribute", element.getName());

+    }

+

+    @Test

+    public void testTypeCopyPaste() throws Exception {

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        IWsdlModelRoot modelRoot;

+

+        ResourceUtils.createFolderInProject(getProject(), "src");

+        IFile file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported_copy.xsd",

+                SOURCE_FOLDER, this.getProject(), "Imported_copy.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported1_copy.xsd",

+                Document_FOLDER_NAME, this.getProject(), "Imported1_copy.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Importing_copy.xsd", SOURCE_FOLDER,

+                this.getProject(), "Importing_copy.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Included_copy.xsd", SOURCE_FOLDER, this

+                .getProject(), "Included_copy.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "IncludedTypesInSchema_copy.wsdl",

+                SOURCE_FOLDER, this.getProject(), "IncludedTypesInSchema_copy.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "IncludedTypesInWSDL_copy.wsdl",

+                SOURCE_FOLDER, this.getProject(), "IncludedTypesInWSDL_copy.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "MultipleNamespacesTypes_copy.wsdl",

+                SOURCE_FOLDER, this.getProject(), "MultipleNamespacesTypes_copy.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "NullNamespaceWSDL_copy.wsdl",

+                SOURCE_FOLDER, this.getProject(), "NullNamespaceWSDL_copy.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(

+                Constants.DATA_PUBLIC_SELF_KESHAV + "TypesReferringExternalSchema_copy.wsdl", SOURCE_FOLDER, this.getProject(),

+                "TypesReferringExternalSchema_copy.wsdl");

+        assertTrue(file.exists());

+

+        modelRoot = copyAndGetModelRoot("TestSI.wsdl", "TestSI.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/")[0];

+        assertEquals(2, schema.getAllContainedTypes().size());

+

+        // Multiple Namespaces WSDL

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/SupplierInvoice.wsdl", "http://www.example.org/",

+                "http://sap.com/xi/SupplierInvoicing", "SupplierInvoiceRequest");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/SupplierInvoice.wsdl", "http://www.example.org/",

+                "http://sap.com/xi/SupplierInvoicing", "SupplierInvoiceRequestResponse");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "complexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "secondSimpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElement");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithElementRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+

+        // Schema Types

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "complexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "secondSimpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElement");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithElementRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+

+        // WSDL importing Schema Types

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "complexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "secondSimpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElement");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithElementRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+

+        // Including types from WSDL

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithAnonymousComplexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+

+        // Including types from Schema

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithAnonymousComplexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+

+        modelRoot = copyAndGetModelRoot("TestSI.wsdl", "TestSI.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/")[0];

+        org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema

+                .getType(true, "NewOperation");

+        assertEquals(1, structureType.getElements("in").size());

+

+        // test if form copy is fine

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Source.wsdl", SOURCE_FOLDER, this

+                .getProject(), "Source.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Target.wsdl", SOURCE_FOLDER, this

+                .getProject(), "Target.wsdl");

+        assertTrue(file.exists());

+    }

+

+    private Map<String, XSDElementDeclaration> getElements(final StructureType type) {

+        XSDNamedComponent component = type.getComponent();

+        component = component instanceof XSDElementDeclaration ? ((XSDElementDeclaration) component).getAnonymousTypeDefinition()

+                : component;

+        if (null != component) {

+            XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) component;

+            if (complexType.getContent() instanceof XSDParticle) {

+                XSDParticle particle = (XSDParticle) complexType.getContent();

+                if (particle.getContent() instanceof XSDModelGroup) {

+                    XSDModelGroup modelGroup = (XSDModelGroup) particle.getContent();

+                    List<XSDParticle> particles = modelGroup.getParticles();

+                    Map<String, XSDElementDeclaration> result = new HashMap<String, XSDElementDeclaration>();

+                    XSDElementDeclaration element;

+                    for (XSDParticle elementParticle : particles) {

+                        if (elementParticle.getContent() instanceof XSDElementDeclaration) {

+                            element = (XSDElementDeclaration) elementParticle.getContent();

+                            result.put(element.getName(), element);

+                        }

+                    }

+                    return result;

+                }

+            }

+        }

+        return Collections.emptyMap();

+    }

+

+    public void assertCopyWithNewFile(final String targetFile, final String sourceFile, final String targetNs,

+            final String sourceNs, final String typeName) throws Exception {

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        ISchema wSchema;

+        IWsdlModelRoot modelRoot;

+        final ModelManager mm = ModelManager.getInstance();

+

+        modelRoot = getModelRoot(targetFile);

+        description = modelRoot.getDescription();

+        schema = description.getSchema(targetNs)[0];

+        assertNotNull(schema);

+        wSchema = (ISchema) mm.getWriteSupport(schema);

+        assertNotNull(wSchema);

+    }

+

+    public void assertCopyElement(org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType structureType, IElement element)

+            throws IllegalInputException {

+        final ModelManager mm = ModelManager.getInstance();

+        IStructureType wStructureType = (IStructureType) mm.getWriteSupport(structureType);

+        try {

+            wStructureType.copyElement(element);

+        } catch (ExecutionException e) {

+            throw new IllegalStateException("The command execution failed. See nested exception", e);

+        }

+        assertTrue(structureType.getElements(element.getName()).size() > 0);

+    }

+

+    private org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema getSchema(

+            final Collection<org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema> schemas,

+            ICondition<org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema> condition) {

+        for (org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema : schemas) {

+            if (condition.isSatisfied(schema))

+                return schema;

+        }

+        return null;

+    }

+

+    interface ICondition<T> {

+        boolean isSatisfied(T in);

+    }

+

+    private class SchemaNamespaceCondition implements ICondition<org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema> {

+

+        private String _namespace;

+

+        public SchemaNamespaceCondition(final String namespace) {

+            this._namespace = namespace;

+        }

+

+        public boolean isSatisfied(org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema in) {

+            if ((null == _namespace && null == in.getNamespace()) || (null != _namespace && _namespace.equals(in.getNamespace())))

+                return true;

+            return false;

+        }

+

+        public void setNamespace(final String namespace) {

+            this._namespace = namespace;

+        }

+

+    }

+

+    private IWsdlModelRoot copyAndGetModelRoot(final String fileName, final String targetName) throws Exception {

+        return getWSDLModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV + fileName, targetName);

+    }

+

+    private IWsdlModelRoot getModelRoot(final String fileName) throws Exception {

+        final IFile file = (IFile) getProject().findMember(new Path(Document_FOLDER_NAME + IPath.SEPARATOR + fileName));

+        assertTrue(file.exists());

+        IWsdlModelRoot modelRoot = ModelManager.getInstance().getWsdlModelRoot(new FileEditorInput(file));

+        setupEnvironment(modelRoot);

+        return modelRoot;

+    }

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/TestWSTmodelInSyncWithDOM.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/TestWSTmodelInSyncWithDOM.java
new file mode 100644
index 0000000..f3fe7cd
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/TestWSTmodelInSyncWithDOM.java
@@ -0,0 +1,173 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.ui.IWorkbenchPage;

+import org.eclipse.ui.IWorkbenchWindow;

+import org.eclipse.ui.PlatformUI;

+import org.eclipse.ui.part.FileEditorInput;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.eclipse.wst.sse.sieditor.test.util.ThreadUtils;

+import org.eclipse.xsd.XSDSchema;

+import org.junit.After;

+import org.junit.Test;

+import org.w3c.dom.Document;

+import org.w3c.dom.Element;

+

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.RenameStructureTypeCommand;

+import org.eclipse.wst.sse.sieditor.model.XMLModelNotifierWrapper;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IElement;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IType;

+import org.eclipse.wst.sse.sieditor.model.xsd.impl.StructureType;

+import org.eclipse.wst.sse.sieditor.model.xsd.impl.UnresolvedType;

+import org.eclipse.wst.sse.sieditor.ui.AbstractEditorWithSourcePage;

+import org.eclipse.wst.sse.sieditor.ui.DataTypesEditor;

+import org.eclipse.wst.sse.sieditor.ui.ServiceInterfaceEditor;

+

+public class TestWSTmodelInSyncWithDOM extends SIEditorBaseTest {

+

+    AbstractEditorWithSourcePage editor = null;

+

+    @Override

+    @After

+    public void tearDown() throws Exception {

+        if (editor != null) {

+            editor.close(false);

+        }

+        super.tearDown();

+        // Flush threads that wait UI thread for execution

+        ThreadUtils.waitOutOfUI(100);

+    }

+

+    @Test

+    public void testDOMusesSIEnotifyerForDTE() throws Exception {

+        final IFile file = ResourceUtils.copyFileIntoTestProject("pub/xsd/example.xsd", Document_FOLDER_NAME, this.getProject(),

+                "example.xsd");

+        refreshProjectNFile(file);

+

+        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

+        final FileEditorInput eInput = new FileEditorInput(file);

+        final IWorkbenchPage workbenchActivePage = window.getActivePage();

+

+        editor = (DataTypesEditor) workbenchActivePage.openEditor(eInput, DataTypesEditor.EDITOR_ID);

+        assertFalse(editor.isDirty());

+

+        final XMLModelNotifierWrapper modelNotifier = editor.getModelNotifier();

+

+        final IXSDModelRoot modelRoot = (IXSDModelRoot) editor.getModelRoot();

+        final XSDSchema xsdSchema = modelRoot.getSchema().getComponent();

+        final Document document = xsdSchema.getDocument();

+        final Element documentElement = document.getDocumentElement();

+

+        modelNotifier.getChangedNodes().clear();

+        modelNotifier.getCollectedNotifications().clear();

+

+        final String attributeTNS = documentElement.getAttribute("targetNamespace");

+        documentElement.setAttribute("targetNamespace", attributeTNS + "new");

+

+        assertEquals(1, modelNotifier.getChangedNodes().size());

+        // Assert that there are notifications collected from the changes to the

+        // EMF model.

+        // TEMPORARY COMMENT CHECK, UNTIL CONCRETE IMPLEMENTATION IS DESIGNED

+        // assertTrue(0 != modelNotifier.getCollectedNotifications().size());

+    }

+

+    @Test

+    public void testDOMusesSIEnotifyerForSIE() throws Exception {

+        final IFile file = ResourceUtils.copyFileIntoTestProject("pub/simple/NewWSDLFile.wsdl", Document_FOLDER_NAME, this

+                .getProject(), "NewWSDLFile.wsdl");

+        refreshProjectNFile(file);

+

+        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

+        final FileEditorInput eInput = new FileEditorInput(file);

+        final IWorkbenchPage workbenchActivePage = window.getActivePage();

+

+        editor = (ServiceInterfaceEditor) workbenchActivePage.openEditor(eInput, ServiceInterfaceEditor.EDITOR_ID);

+        assertFalse(editor.isDirty());

+

+        final XMLModelNotifierWrapper modelNotifier = editor.getModelNotifier();

+

+        final IWsdlModelRoot modelRoot = (IWsdlModelRoot) editor.getModelRoot();

+        final ISchema schema = modelRoot.getDescription().getSchema("http://www.example.org/NewWSDLFile/")[0];

+        final XSDSchema xsdSchema = schema.getComponent();

+        final Document document = xsdSchema.getDocument();

+        final Element documentElement = document.getDocumentElement();

+

+        modelNotifier.getChangedNodes().clear();

+        modelNotifier.getCollectedNotifications().clear();

+

+        final String attributeTNS = documentElement.getAttribute("targetNamespace");

+        documentElement.setAttribute("targetNamespace", attributeTNS + "new");

+

+        assertEquals(1, modelNotifier.getChangedNodes().size());

+        // Assert that there are notifications collected from the changes to the

+        // EMF model.

+        // TEMPORARY COMMENT CHECK, UNTIL CONCRETE IMPLEMENTATION IS DESIGNED

+        // assertTrue(0 != modelNotifier.getCollectedNotifications().size());

+    }

+

+    @Test

+    public void testRenamingXSDTypeDoesNotBreakTypeReferencers() throws Exception {

+        final IXSDModelRoot modelRoot = getXSDModelRoot("pub/xsd/example.xsd", "example.xsd");

+

+        final IType addressType = modelRoot.getSchema().getType(false, "Address");

+        final IStructureType purchaseOrderType = (IStructureType) modelRoot.getSchema().getType(false, "PurchaseOrderType");

+        final IElement shipTo = purchaseOrderType.getElements("shipTo").iterator().next();

+

+        assertEquals(StructureType.class, shipTo.getType().getClass());

+

+        // Change Address name

+        final RenameStructureTypeCommand renameCommand = new RenameStructureTypeCommand(modelRoot, (IStructureType) shipTo

+                .getType(), "Address22");

+        modelRoot.getEnv().execute(renameCommand);

+

+        assertEquals("Address22", addressType.getName());

+        assertFalse(UnresolvedType.instance().equals(shipTo.getType()));

+        assertEquals("Address22", shipTo.getType().getName());

+    }

+

+    @Test

+    public void testRenamingXSDTypeDoesNotBreakWSDLPartReferencers() throws Exception {

+        final IWsdlModelRoot modelRoot = getWSDLModelRoot("pub/simple/NewWSDLFile.wsdl", "NewWSDLFile.wsdl");

+

+        final ISchema schema = modelRoot.getDescription().getSchema("http://www.example.org/NewWSDLFile/")[0];

+        final IType newOperationType = schema.getType(true, "NewOperation");

+

+        final IServiceInterface newWSDLFile_Interface = modelRoot.getDescription().getInterface("NewWSDLFile").get(0);

+        final IOperation newOperation = newWSDLFile_Interface.getOperation("NewOperation").get(0);

+        final IParameter inputParameter = newOperation.getInputParameter("parameters").get(0);

+

+        assertEquals(StructureType.class, inputParameter.getType().getClass());

+

+        // Change NewOperation type name

+        final RenameStructureTypeCommand renameCommand = new RenameStructureTypeCommand(modelRoot,

+                (IStructureType) newOperationType, "NewOperation22");

+        modelRoot.getEnv().execute(renameCommand);

+

+        assertEquals("NewOperation22", newOperationType.getName());

+        assertFalse(UnresolvedType.instance().equals(inputParameter.getType()));

+        assertEquals("NewOperation22", inputParameter.getType().getName());

+    }

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/UriEncodingsOnImportTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/UriEncodingsOnImportTest.java
new file mode 100644
index 0000000..29d96c4
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/UriEncodingsOnImportTest.java
@@ -0,0 +1,54 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Assert;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetElementTypeCommand;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IElement;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IType;

+import org.eclipse.wst.sse.sieditor.model.xsd.impl.UnresolvedType;

+

+public class UriEncodingsOnImportTest extends SIEditorBaseTest {

+

+    @Test

+    public void test() throws ExecutionException {

+        IWsdlModelRoot wsdlModelRoot = null;

+        IXSDModelRoot xsdModelRoot = null;

+        try {

+            wsdlModelRoot = getWSDLModelRoot("pub/self/mix/TypesInternalImporting.wsdl", "TypesInternalImporting.wsdl");

+            xsdModelRoot = getXSDModelRoot("pub/xsd/example2.xsd", "test with space.xsd");

+        } catch (Exception e) {

+            fail(e.toString());

+        }

+

+        final ISchema schema = wsdlModelRoot.getDescription().getSchema("http://www.example.com/")[0];

+

+        IStructureType structure = (IStructureType) schema.getType(false, "Address");

+        IElement element = structure.getElements("name").iterator().next();

+        IType type = xsdModelRoot.getSchema().getType(false, "Address");

+

+        SetElementTypeCommand setElementTypeCommand = new SetElementTypeCommand(wsdlModelRoot, element, type);

+        wsdlModelRoot.getEnv().execute(setElementTypeCommand);

+        Assert.assertNotSame(UnresolvedType.instance(), element.getType());

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/WSDLReadAPITest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/WSDLReadAPITest.java
new file mode 100644
index 0000000..9ff0072
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/WSDLReadAPITest.java
@@ -0,0 +1,291 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.Collection;

+import java.util.List;

+

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.OperationType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IType;

+import org.eclipse.wst.sse.sieditor.model.xsd.impl.StructureType;

+

+@SuppressWarnings("nls")

+public class WSDLReadAPITest extends SIEditorBaseTest {

+

+    protected static final String WSDL_FILE_NAME = "ChangePurchaseOrder_WSD.wsdl";

+    protected static final int NUMBER_OF_INTERFACES_IN_FILE = 1;

+    protected static final String INTERFACE_NAME = "PurchaseOrderChangeRequestConfirmation_In";

+    protected static final int NUMBER_OF_CONTAINED_SCHEMAS = 2;

+    protected static final int NUMBER_OF_VISIBLE_SCHEMAS = 3;

+    protected static final int NUMBER_OF_REFERENCED_SERVICES = 0;

+    protected static final String DESCRIPTION_LOCATION = "/WSDLReadAPITests/data/ChangePurchaseOrder_WSD.wsdl";

+    protected static final String DESCRIPTION_NAMESPACE = "http://sap.com/xi/APPL/SE/Global";

+    protected static final int NUMBER_OF_OPERATIONS = 1;

+    protected static final String TESTED_OPERATION = "PurchaseOrderChangeRequestConfirmation_In";

+    protected static final OperationType OPERATION_TYPE = OperationType.REQUEST_RESPONSE;

+    protected static final int NUMBER_OF_INPUT_PARAMETERS = 1;

+    protected static final String TESTED_INPUT_PARAMETER = "PurchaseOrderChangeRequest_sync";

+    protected static final int NUMBER_OF_OUTPUT_PARAMETERS = 1;

+    protected static final String TESTED_OUTPUT_PARAMETER = "PurchaseOrderChangeConfirmation_sync";

+    protected static final int NUMBER_OF_FAULTS = 1;

+    protected static final String TESTED_FAULT = "StandardMessageFault";

+    protected static final int NUMBER_OF_PARAMETERS_IN_FAULT = 1;

+    protected static final String TESTED_PARAMETER_IN_FAULT = "StandardMessageFault";

+    protected static final String[] SCHEMA_NAMESPACES = new String[] { "http://sap.com/xi/APPL/SE/Global",

+            "http://sap.com/xi/SAPGlobal20/Global" };

+    protected static final String SCHEMA_FOR_SCHEMANS = "http://www.w3.org/2001/XMLSchema";

+

+    protected String getProjectName() {

+        return "WSDLReadAPITests";

+    }

+

+    @Test

+    public void test_ModelAccess() throws Exception {

+        final IWsdlModelRoot root = getModelRoot(WSDL_FILE_NAME);

+        assertNotNull("Model could not be acquired", root);

+        assertNotNull("Description could not be acquired", root.getDescription());

+    }

+

+    @Test

+    public void test_Description() throws Exception {

+        IWsdlModelRoot root = getModelRoot(WSDL_FILE_NAME);

+

+        IDescription description = root.getDescription();

+

+        String nameSpace = description.getNamespace();

+        assertEquals("http://sap.com/xi/APPL/SE/Global", nameSpace);

+

+        Collection<IServiceInterface> interfaces = description.getAllInterfaces();

+        assertTrue(interfaces.size() + " interfaces returned instead of " + NUMBER_OF_INTERFACES_IN_FILE,

+                NUMBER_OF_INTERFACES_IN_FILE == interfaces.size()); // @Test-0001

+        interfaces = description.getAllInterfaces();

+        assertTrue(interfaces.size() + " interfaces returned instead of " + NUMBER_OF_INTERFACES_IN_FILE,

+                NUMBER_OF_INTERFACES_IN_FILE == interfaces.size()); // @Test-0001

+

+        List<IServiceInterface> sIs = description.getInterface(INTERFACE_NAME);

+        assertFalse(sIs.isEmpty());

+        IServiceInterface service1 = sIs.get(0);

+        assertNotNull("Null returned for getInterface", service1); // @Test-0002

+

+        sIs = description.getInterface("foo");

+        assertTrue("Interface exists with name foo",sIs.isEmpty());

+        

+        Collection<ISchema> schemas = description.getContainedSchemas();

+        assertTrue(schemas.size() + " Contained schemas returned instead of " + NUMBER_OF_CONTAINED_SCHEMAS,

+                NUMBER_OF_CONTAINED_SCHEMAS == schemas.size()); // @Test-0003

+

+        Collection<ISchema> visibleSchemas = description.getAllVisibleSchemas();

+        assertTrue(visibleSchemas.size() + " Visible Schemas returned instead of " + NUMBER_OF_VISIBLE_SCHEMAS,

+                NUMBER_OF_VISIBLE_SCHEMAS == visibleSchemas.size()); // @Test-0004

+

+        boolean exists = false;

+        for(ISchema schema : visibleSchemas) {

+        	if(SCHEMA_FOR_SCHEMANS.equals(schema.getNamespace())) {

+        		exists = true;

+        		break;

+        	}

+        }

+        assertTrue("Return Visible schema is not schema for schema", exists);

+

+        for (String schemans : SCHEMA_NAMESPACES) {

+            ISchema[] schemaArray = description.getSchema(schemans);

+            assertTrue("No schema returned for namespace '" + schemans + "'", 1 == schemaArray.length); // @Test-0005

+            assertEquals("Wrong Schema returned for namespace '" + schemans + "'", schemans, schemaArray[0].getNamespace());

+        }

+

+        ISchema[] schemaArray = description.getSchema("foo");

+        assertTrue("Schemas exists for namespace 'foo'", 0 == schemaArray.length); // @Test-0005

+

+        Collection<IDescription> referencedServices = description.getReferencedServices();

+        assertTrue("Referenced services exist", NUMBER_OF_REFERENCED_SERVICES == referencedServices.size()); // @Test-0006

+

+        String location = description.getLocation();

+        assertTrue(location.endsWith(DESCRIPTION_LOCATION)); // @Test-007

+

+        String namespace = description.getNamespace();

+        assertEquals("'" + namespace + "' returned as namespace instead of '" + DESCRIPTION_NAMESPACE + "'",

+                DESCRIPTION_NAMESPACE, namespace); // @Test-0008

+        assertTrue(description.getParent() == null);

+        assertTrue(description.getRoot() == null);

+    }

+

+    @Test

+    public void test_ServiceInterface() throws Exception {

+        IWsdlModelRoot root = getModelRoot(WSDL_FILE_NAME);

+

+        IDescription description = root.getDescription();

+        List<IServiceInterface> interfaces = description.getInterface(INTERFACE_NAME);

+        assertFalse(interfaces.isEmpty());

+        IServiceInterface service = interfaces.get(0);

+        assertNotNull("No interface returned for name " + INTERFACE_NAME + " is  null", service);

+        assertTrue("Wrong interface returned for name " + INTERFACE_NAME, INTERFACE_NAME.equals(service.getName()));

+

+        Collection<IOperation> operations = service.getAllOperations();

+        assertEquals(operations.size() + " operations returned instead of " + NUMBER_OF_OPERATIONS, NUMBER_OF_OPERATIONS,

+                operations.size()); // @Test-0009

+        operations = service.getAllOperations();

+        assertEquals(operations.size() + " operations returned instead of " + NUMBER_OF_OPERATIONS, NUMBER_OF_OPERATIONS,

+                operations.size()); // @Test-0009

+

+        List<IOperation> ops = service.getOperation(TESTED_OPERATION);

+        assertFalse(ops.isEmpty());

+        IOperation operation = ops.get(0);

+        assertNotNull("No operation returned for name " + TESTED_OPERATION, operation); // @Test-0010

+        assertTrue("Wrong Operaiton returned for name " + TESTED_OPERATION, TESTED_OPERATION.equals(operation.getName()));

+

+        assertTrue(description == service.getParent());

+        assertTrue(description == service.getRoot());

+    }

+

+    @Test

+    public void test_Operation() throws Exception {

+        IWsdlModelRoot root = getModelRoot(WSDL_FILE_NAME);

+

+        IDescription description = root.getDescription();

+        IServiceInterface service = description.getInterface(INTERFACE_NAME).get(0);

+        IOperation operation = service.getOperation(TESTED_OPERATION).get(0);

+

+        OperationType operationType = operation.getOperationStyle();

+        assertTrue("Returned operation is not Request-Response", OPERATION_TYPE == operationType); // @Test-0012

+

+        Collection<IParameter> inputParameters = operation.getAllInputParameters();

+        assertEquals(inputParameters.size() + " in parameters returned instead of " + NUMBER_OF_INPUT_PARAMETERS,

+                NUMBER_OF_INPUT_PARAMETERS, inputParameters.size()); // @Test-0013

+        inputParameters = operation.getAllInputParameters();

+        assertEquals(inputParameters.size() + " in parameters returned instead of " + NUMBER_OF_INPUT_PARAMETERS,

+                NUMBER_OF_INPUT_PARAMETERS, inputParameters.size()); // @Test-0013

+

+        List<IParameter> params = operation.getInputParameter(TESTED_INPUT_PARAMETER);

+        assertFalse(params.isEmpty());

+        IParameter inputParameter = params.get(0);

+        assertNotNull("No input parameter returned for name " + TESTED_INPUT_PARAMETER, inputParameter); // @Test-0014

+        assertTrue("Wrong in parameter returned for name " + TESTED_INPUT_PARAMETER, TESTED_INPUT_PARAMETER.equals(inputParameter

+                .getName()));

+        assertTrue(operation == inputParameter.getParent());

+        assertTrue(description == inputParameter.getRoot());

+

+        Collection<IParameter> outputParameters = operation.getAllOutputParameters();

+        assertEquals(outputParameters.size() + " out parameters returned instead of " + NUMBER_OF_OUTPUT_PARAMETERS,

+                NUMBER_OF_OUTPUT_PARAMETERS, outputParameters.size()); // @Test-0015

+        outputParameters = operation.getAllOutputParameters();

+        assertEquals(outputParameters.size() + " out parameters returned instead of " + NUMBER_OF_OUTPUT_PARAMETERS,

+                NUMBER_OF_OUTPUT_PARAMETERS, outputParameters.size()); // @Test-0015

+

+        params = operation.getOutputParameter(TESTED_OUTPUT_PARAMETER);

+        assertFalse(params.isEmpty());

+        IParameter outputParameter = params.get(0);

+        assertNotNull("No out parameter returned for name " + TESTED_OUTPUT_PARAMETER, outputParameter); // @Test-0016

+        assertTrue("Wrong out parameter returned for name " + TESTED_OUTPUT_PARAMETER, TESTED_OUTPUT_PARAMETER

+                .equals(outputParameter.getName()));

+        assertTrue(operation == outputParameter.getParent());

+        assertTrue(description == outputParameter.getRoot());

+

+        Collection<IFault> faults = operation.getAllFaults();

+        assertEquals(faults.size() + " faults returned instead of " + NUMBER_OF_FAULTS, NUMBER_OF_FAULTS, faults.size()); // @Test-0017

+        faults = operation.getAllFaults();

+        assertEquals(faults.size() + " faults returned instead of " + NUMBER_OF_FAULTS, NUMBER_OF_FAULTS, faults.size()); // @Test-0017

+

+        List<IFault> flts = operation.getFault(TESTED_FAULT);

+        assertFalse(flts.isEmpty());

+        IFault fault = flts.get(0);

+        assertNotNull("No Fault returned for name " + TESTED_FAULT, fault); // @Test-0018

+        assertTrue("Wrong fault returned for name " + TESTED_FAULT, TESTED_FAULT.equals(fault.getName()));

+        assertTrue(operation == fault.getParent());

+        assertTrue(description == fault.getRoot());

+

+        assertTrue(service == operation.getParent());

+        assertTrue(description == operation.getRoot());

+    }

+

+    @Test

+    public void test_OperationParameter() throws Exception {

+        IWsdlModelRoot root = getModelRoot(WSDL_FILE_NAME);

+        IDescription description = root.getDescription();

+

+        IServiceInterface service = description.getInterface(INTERFACE_NAME).get(0);

+        IOperation operation = service.getOperation(TESTED_OPERATION).get(0);

+        IParameter parameter = operation.getInputParameter(TESTED_INPUT_PARAMETER).get(0);

+

+        String name = parameter.getName();

+        assertNotNull("Null returned for name", name);

+        assertTrue("Wrong name returned for parameter " + TESTED_INPUT_PARAMETER, TESTED_INPUT_PARAMETER.equals(name));

+

+        IType type = parameter.getType();

+        assertNotNull("Null returned for type" + type); // @Test-0019

+        assertTrue("Wrong type returned for parameter", "PurchaseOrderChangeRequest_sync".equals(type.getName()));

+        assertTrue("Type must be StructureType", type instanceof StructureType);

+

+        parameter = operation.getOutputParameter(TESTED_OUTPUT_PARAMETER).get(0);

+

+        name = parameter.getName();

+        assertNotNull("Null returned for name", name);

+        assertTrue("Wrong name returned for parameter " + TESTED_OUTPUT_PARAMETER, TESTED_OUTPUT_PARAMETER.equals(name));

+

+        type = parameter.getType();

+        assertNotNull("Null returned for type" + type); // @Test-0019

+        assertTrue("Wrong type returned for parameter", "PurchaseOrderChangeConfirmation_sync".equals(type.getName()));

+        assertTrue("Type must be StructureType", type instanceof StructureType);

+        assertTrue("Returned Type is not an Element", ((StructureType) type).isElement());

+    }

+

+    @Test

+    public void test_OperationFault() throws Exception {

+        IWsdlModelRoot root = getModelRoot(WSDL_FILE_NAME);

+        IDescription description = root.getDescription();

+        IServiceInterface service = description.getInterface(INTERFACE_NAME).get(0);

+        IOperation operation = service.getOperation(TESTED_OPERATION).get(0);

+

+        IFault fault = operation.getFault(TESTED_FAULT).get(0);

+        final String name = fault.getName();

+        assertNotNull("Null returned for name", name);

+        assertEquals("Wrong fault name returned ", TESTED_FAULT, name);

+

+        Collection<IParameter> parameters = fault.getParameters();

+        assertEquals(parameters.size() + " Fault parameters returned instead of " + NUMBER_OF_PARAMETERS_IN_FAULT,

+                NUMBER_OF_PARAMETERS_IN_FAULT, parameters.size()); // @Test-0020

+        IParameter parameter = fault.getParameter(TESTED_PARAMETER_IN_FAULT).get(0);

+        parameters = fault.getParameters();

+        assertEquals(parameters.size() + " Fault parameters returned instead of " + NUMBER_OF_PARAMETERS_IN_FAULT,

+                NUMBER_OF_PARAMETERS_IN_FAULT, parameters.size()); // @Test-0020

+        assertTrue(operation == fault.getParent());

+        assertTrue(description == fault.getRoot());

+

+        assertNotNull("No parameter returned for name " + TESTED_PARAMETER_IN_FAULT, parameter); // @Test-0021

+        assertEquals("Wrong parameter returned for name " + TESTED_PARAMETER_IN_FAULT, TESTED_PARAMETER_IN_FAULT, parameter

+                .getName());

+    }

+

+    private IWsdlModelRoot getModelRoot(String fileName) throws Exception {

+        final String fullPath = Constants.DATA_PUBLIC_SELF_MIX2 + fileName;

+        final IWsdlModelRoot modelRoot = getWSDLModelRoot(fullPath, fileName);

+        assertNotNull("Could not Acquire Model Root for " + fullPath, modelRoot);

+        return modelRoot;

+    }

+

+    public void dispose() throws Exception {

+

+        super.dispose();

+    }

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/WSDLWriteTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/WSDLWriteTest.java
new file mode 100644
index 0000000..d76a9a5
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/WSDLWriteTest.java
@@ -0,0 +1,1031 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.Collection;

+import java.util.Iterator;

+import java.util.List;

+

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.runtime.IPath;

+import org.eclipse.core.runtime.Path;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.emf.common.util.EList;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.eclipse.wst.wsdl.Binding;

+import org.eclipse.wst.wsdl.BindingFault;

+import org.eclipse.wst.wsdl.BindingOperation;

+import org.eclipse.wst.wsdl.Definition;

+import org.eclipse.wst.wsdl.WSDLElement;

+import org.eclipse.wst.wsdl.binding.soap.SOAPFault;

+import org.junit.Assert;

+import org.junit.Test;

+import org.w3c.dom.Node;

+import org.w3c.dom.NodeList;

+

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.AddFaultCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.AddFaultParameterCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.AddInParameterCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.AddNewSchemaCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.AddOperationCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.AddOutParameterCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.AddServiceInterfaceCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.ChangeOperationTypeCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.DeleteFaultCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.DeleteFaultParameterCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.DeleteInParameterCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.DeleteOperationCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.DeleteOutParameterCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.DeleteServiceInterfaceCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.RemoveSchemaCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.RenameFaultCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.RenameOperationCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.RenameParameterCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.RenameServiceInterfaceCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.SetDocumentationCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.SetParameterTypeCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.tns.ChangeDefinitionTNSCompositeCommand;

+import org.eclipse.wst.sse.sieditor.model.api.IModelObject;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.OperationType;

+import org.eclipse.wst.sse.sieditor.model.wsdl.impl.AbstractWSDLComponent;

+import org.eclipse.wst.sse.sieditor.model.wsdl.impl.Description;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IType;

+import org.eclipse.wst.sse.sieditor.model.xsd.impl.AbstractType;

+

+@SuppressWarnings("nls")

+public class WSDLWriteTest extends SIEditorBaseTest {

+

+    private static final String SOURCE_FOLDER = "src/wsdl";

+

+    protected String getProjectName() {

+        return "WSDLWriteTest";

+    }

+

+    @Test

+    public void test_Description() throws Exception {

+        // check for referenced documents

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "One.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        description = modelRoot.getDescription();

+

+        AddServiceInterfaceCommand cmd = new AddServiceInterfaceCommand(modelRoot, description, "newInterface");

+        modelRoot.getEnv().execute(cmd);

+        interfaceObj = cmd.getInterface();

+        assertEquals("newInterface", interfaceObj.getName());

+        assertEquals("http://sap.com/xi/Purchasing", interfaceObj.getNamespace());

+        assertFalse("Could not find service new SI", description.getInterface("newInterface").isEmpty());

+        assertNotNull("Could not find service new SI", description.getInterface("newInterface").get(0));

+        assertEquals(0, interfaceObj.getAllOperations().size());

+

+        DeleteServiceInterfaceCommand deletecmd = new DeleteServiceInterfaceCommand(modelRoot, description, interfaceObj);

+        modelRoot.getEnv().execute(deletecmd);

+        assertTrue("newInterface is not removed", description.getInterface("newInterface").isEmpty());

+

+        cmd = new AddServiceInterfaceCommand(modelRoot, description, "newInterface");

+        modelRoot.getEnv().execute(cmd);

+        interfaceObj = cmd.getInterface();

+        assertEquals("newInterface", interfaceObj.getName());

+        assertEquals("http://sap.com/xi/Purchasing", interfaceObj.getNamespace());

+        List<IServiceInterface> interfaces = description.getInterface("newInterface");

+        assertFalse(interfaces.isEmpty());

+        assertNotNull("Could not find service new SI", interfaces.get(0));

+        assertEquals(0, interfaceObj.getAllOperations().size());

+

+        // Implement these methods

+        /*

+         * Exception error = null; try { wDesc.addExtension(null); } catch

+         * (Exception e) { error = e; } assertNotNull(error); error = null; try

+         * { wDesc.removeExtension(null); } catch (Exception e) { error = e; }

+         * assertNotNull(error);

+         */

+

+        deletecmd = new DeleteServiceInterfaceCommand(modelRoot, description, description.getInterface(

+                "PurchaseOrderConfirmation").get(0));

+        modelRoot.getEnv().execute(deletecmd);

+        assertTrue("PurchaseOrderConfirmation is not removed", description.getInterface("PurchaseOrderConfirmation").isEmpty());

+

+        AddNewSchemaCommand newschemacmd = new AddNewSchemaCommand(modelRoot, "http://newNs");

+        modelRoot.getEnv().execute(newschemacmd);

+        schema = newschemacmd.getNewSchema();

+        assertNotNull("Schema http://newNs is not added", schema);

+        assertEquals("http://newNs", schema.getNamespace());

+        assertEquals(description, schema.getRoot());

+        assertEquals(description, schema.getParent());

+        assertTrue("Schema location is not WSDL Location", schema.getLocation().endsWith("One.wsdl"));

+        assertNotNull("new Schema could not be obtained", description.getSchema("http://newNs"));

+        assertEquals(0, schema.getAllContainedTypes().size());

+

+        RemoveSchemaCommand removeschemacmd = new RemoveSchemaCommand(modelRoot, schema);

+        modelRoot.getEnv().execute(removeschemacmd);

+        assertNotNull("new Schema is not deleted", description.getSchema("http://newNs"));

+

+        newschemacmd = new AddNewSchemaCommand(modelRoot, "http://newNs");

+        modelRoot.getEnv().execute(newschemacmd);

+        schema = newschemacmd.getNewSchema();

+        assertNotNull("Schema http://newNs is not added", schema);

+        assertEquals("http://newNs", schema.getNamespace());

+        assertEquals(description, schema.getRoot());

+        assertEquals(description, schema.getParent());

+        assertTrue("Schema location is not WSDL Location", schema.getLocation().endsWith("One.wsdl"));

+        assertNotNull("new Schema could not be obtained", description.getSchema("http://newNs"));

+        assertEquals(0, schema.getAllContainedTypes().size());

+

+        setDocumentation(modelRoot, (AbstractWSDLComponent) description, "Documentation");

+        assertEquals("Documentation", description.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) description, "NewDocumentation");

+        assertEquals("NewDocumentation", description.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "Two.wsdl");

+        description = modelRoot.getDescription();

+        modelRoot.getEnv().execute(new AddServiceInterfaceCommand(modelRoot, description, "newInterface"));

+        modelRoot.getEnv().execute(

+                new DeleteServiceInterfaceCommand(modelRoot, description, description.getInterface("PurchaseOrderConfirmation")

+                        .get(0)));

+        modelRoot.getEnv().execute(new AddNewSchemaCommand(modelRoot, "http://newNs"));

+

+        // TODO Remove schema by name is not implemented by command

+        schema = description.getSchema("http://sap.com/xi/SRM/Basis/Global")[0];

+        removeSchema(modelRoot, schema);

+

+        setDocumentation(modelRoot, (AbstractWSDLComponent) description, "Documentation");

+        setDocumentation(modelRoot, (AbstractWSDLComponent) description, "NewDocumentation");

+        ((Description) description).save();

+

+        modelRoot = getModelRoot("Two.wsdl");

+        description = modelRoot.getDescription();

+        assertFalse("Could not find service new SI", description.getInterface("newInterface").isEmpty());

+        assertNotNull("Could not find service new SI", description.getInterface("newInterface").get(0));

+        assertNotNull("new Schema is not deleted", description.getSchema("http://newNs"));

+        assertEquals("Schema http://sap.com/xi/SRM/Basis/Global is not deleted", 0, description

+                .getSchema("http://sap.com/xi/SRM/Basis/Global").length);

+        assertTrue("PurchaseOrderConfirmation is not removed", description.getInterface("PurchaseOrderConfirmation").isEmpty());

+        assertEquals("NewDocumentation", description.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("Documentation.wsdl", "Documentation.wsdl");

+        description = modelRoot.getDescription();

+        assertEquals("Documentation", description.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) description, "NewDocumentation");

+        assertEquals("NewDocumentation", description.getDocumentation());

+        ((Description) description).save();

+

+        modelRoot = getModelRoot("Documentation.wsdl");

+        description = modelRoot.getDescription();

+        assertEquals("NewDocumentation", description.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("PrefixWSDL.wsd", "PrefixWSDL.wsdl");

+        description = modelRoot.getDescription();

+        setDocumentation(modelRoot, (AbstractWSDLComponent) description, "Documentation");

+        assertEquals("Documentation", description.getDocumentation());

+

+        setDescriptionNamespace(modelRoot, description, "http://example.org");

+        assertEquals("http://example.org", description.getNamespace());

+        ((Description) description).save();

+        modelRoot = getModelRoot("PrefixWSDL.wsdl");

+        description = modelRoot.getDescription();

+        assertEquals("http://example.org", description.getNamespace());

+    }

+

+    @Test

+    public void test_ServiceInterface() throws Exception {

+        // check for referenced documents

+        final String fileName = "Three.wsdl";

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", fileName);

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation;

+        description = modelRoot.getDescription();

+

+        // check add and remove operations for old serviceinterface

+        interfaceObj = description.getInterface("PurchaseOrderConfirmation").get(0);

+        operation = addOperation(modelRoot, interfaceObj, "newReqResponseOperation", OperationType.REQUEST_RESPONSE);

+        assertNotNull("New operation 'newReqResponseOperation' could not be added successfully", operation);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllFaults().size());

+        assertEquals("newReqResponseOperation", operation.getName());

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+        assertEquals(operation.getParent(), interfaceObj);

+        assertEquals(operation.getRoot(), description);

+        assertEquals(2, interfaceObj.getAllOperations().size());

+

+        operation = addOperation(modelRoot, interfaceObj, "newAsyncOperation", OperationType.ASYNCHRONOUS);

+        assertNotNull("New operation 'newAsyncOperation' could not be added successfully", operation);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllFaults().size());

+        assertEquals("newAsyncOperation", operation.getName());

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+        assertEquals(operation.getParent(), interfaceObj);

+        assertEquals(operation.getRoot(), description);

+        assertEquals(3, interfaceObj.getAllOperations().size());

+

+        setDocumentation(modelRoot, (AbstractWSDLComponent) interfaceObj, "Documentation");

+        assertEquals("Documentation", interfaceObj.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) interfaceObj, "NewDocumentation");

+        assertEquals("NewDocumentation", interfaceObj.getDocumentation());

+

+        AddServiceInterfaceCommand addintfcmd = new AddServiceInterfaceCommand(modelRoot, description, "newInterface");

+        modelRoot.getEnv().execute(addintfcmd);

+        interfaceObj = addintfcmd.getInterface();

+        operation = addOperation(modelRoot, interfaceObj, "newReqResponseOperation", OperationType.REQUEST_RESPONSE);

+        assertNotNull("New operation 'newReqResponseOperation' could not be added successfully", operation);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllFaults().size());

+        assertEquals("newReqResponseOperation", operation.getName());

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+        assertEquals(operation.getParent(), interfaceObj);

+        assertEquals(operation.getRoot(), description);

+        assertEquals(1, interfaceObj.getAllOperations().size());

+

+        operation = addOperation(modelRoot, interfaceObj, "newAsyncOperation", OperationType.ASYNCHRONOUS);

+        assertNotNull("New operation 'newAsyncOperation' could not be added successfully", operation);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllFaults().size());

+        assertEquals("newAsyncOperation", operation.getName());

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+        assertEquals(operation.getParent(), interfaceObj);

+        assertEquals(operation.getRoot(), description);

+        assertEquals(2, interfaceObj.getAllOperations().size());

+

+        setDocumentation(modelRoot, (AbstractWSDLComponent) interfaceObj, "Documentation");

+        assertEquals("Documentation", interfaceObj.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) interfaceObj, "NewDocumentation");

+        assertEquals("NewDocumentation", interfaceObj.getDocumentation());

+

+        DeleteOperationCommand deleteOperationCmd = new DeleteOperationCommand(modelRoot, interfaceObj, interfaceObj

+                .getOperation("newReqResponseOperation").get(0));

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(deleteOperationCmd));

+        assertTrue(interfaceObj.getOperation("newReqResponseOperation").isEmpty());

+

+        deleteOperationCmd = new DeleteOperationCommand(modelRoot, interfaceObj, operation);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(deleteOperationCmd));

+        assertTrue(interfaceObj.getOperation("newAsyncOperation").isEmpty());

+

+        modelRoot = getModelRoot("Documentation.wsdl");

+        description = modelRoot.getDescription();

+        List<IServiceInterface> interfaces = description.getInterface("PurchaseOrderConfirmation");

+        assertFalse(interfaces.isEmpty());

+        interfaceObj = interfaces.get(0);

+        assertEquals("Documentation\n\t\t", interfaceObj.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) interfaceObj, "NewDocumentation");

+        assertEquals("NewDocumentation", interfaceObj.getDocumentation());

+        RenameServiceInterfaceCommand renameCmd = new RenameServiceInterfaceCommand(modelRoot, interfaceObj,

+                "NewPurchaseOrderConfirmation");

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(renameCmd));

+        assertEquals("NewPurchaseOrderConfirmation", interfaceObj.getName());

+        assertFalse("Could not find interface after renaming", description.getInterface("NewPurchaseOrderConfirmation").isEmpty());

+        assertNotNull("Could not find interface after renaming", description.getInterface("NewPurchaseOrderConfirmation").get(0));

+        ((Description) description).save();

+

+        // Test if changes are saved

+        modelRoot = getModelRoot("Documentation.wsdl");

+        description = modelRoot.getDescription();

+        interfaceObj = description.getInterface("NewPurchaseOrderConfirmation").get(0);

+        assertEquals("NewPurchaseOrderConfirmation", interfaceObj.getName());

+        assertEquals("NewDocumentation", interfaceObj.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", fileName);

+        description = modelRoot.getDescription();

+        interfaceObj = description.getInterface("PurchaseOrderConfirmation").get(0);

+

+        operation = addOperation(modelRoot, interfaceObj, "NewOperation", OperationType.REQUEST_RESPONSE);

+        assertEquals(2, interfaceObj.getAllOperations().size());

+

+        deleteOperationCmd = new DeleteOperationCommand(modelRoot, interfaceObj, operation);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(deleteOperationCmd));

+        assertEquals(1, interfaceObj.getAllOperations().size());

+

+        deleteOperationCmd = new DeleteOperationCommand(modelRoot, interfaceObj, interfaceObj.getOperation(

+                "PurchaseOrderConfirmationRequestResponse_In").get(0));

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(deleteOperationCmd));

+        assertEquals(0, interfaceObj.getAllOperations().size());

+    }

+

+    @Test

+    public void test_Operation() throws Exception {

+        // check for referenced documents

+        final String fileName = "TestOperation.wsdl";

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("Operations.wsdl", fileName);

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter parameter;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault faultObj;

+        description = modelRoot.getDescription();

+

+        // check add and remove operations for old serviceinterface

+        interfaceObj = description.getInterface("Operations").get(0);

+        operation = interfaceObj.getOperation("SyncOperation").get(0);

+

+        // Test parameter addition and deletion

+        assertEquals(1, operation.getAllInputParameters().size());

+        // AddInParameterCommand addInParameterCmd = new

+        parameter = addInputParameter(modelRoot, operation, "Parameter1");

+        assertEquals(2, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        parameter = addOutputParameter(modelRoot, operation, "Parameter2");

+        assertEquals(2, operation.getAllOutputParameters().size());

+        assertEquals("Parameter2", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        assertEquals("Documentation", operation.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) operation, "NewDocumentation");

+        assertEquals("NewDocumentation", operation.getDocumentation());

+        faultObj = addFault(modelRoot, operation, "fault2");

+        assertNotNull("New Fault is null", faultObj);

+        assertEquals("fault2", faultObj.getName());

+

+        operation = interfaceObj.getOperation("SyncOperationWithNoMessage").get(0);

+        // Test parameter addition and deletion

+        assertEquals(0, operation.getAllInputParameters().size());

+        parameter = addInputParameter(modelRoot, operation, "Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        parameter = addOutputParameter(modelRoot, operation, "Parameter2");

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals("Parameter2", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) operation, "NewDocumentation");

+        assertEquals("NewDocumentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("SyncOperationWithMissingMessages").get(0);

+        // Test parameter addition and deletion

+        assertEquals(0, operation.getAllInputParameters().size());

+        parameter = addInputParameter(modelRoot, operation, "Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        parameter = addOutputParameter(modelRoot, operation, "Parameter2");

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals("Parameter2", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        assertEquals("", operation.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) operation, "Documentation");

+        assertEquals("Documentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("ASyncOperationWithNoMessage").get(0);

+        // Test parameter addition and deletion

+        assertEquals(0, operation.getAllInputParameters().size());

+        parameter = addInputParameter(modelRoot, operation, "Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        assertEquals("", operation.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) operation, "Documentation");

+        assertEquals("Documentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("ASyncOperationWithMissingMessage").get(0);

+        // Test parameter addition and deletion

+        assertEquals(0, operation.getAllInputParameters().size());

+        parameter = addInputParameter(modelRoot, operation, "Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+        renameOperation(modelRoot, operation, "NewASyncOperationWithMissingMessage");

+        assertEquals("NewASyncOperationWithMissingMessage", operation.getName());

+        assertFalse("Could not find operation after renaming", interfaceObj.getOperation("NewASyncOperationWithMissingMessage")

+                .isEmpty());

+        assertNotNull("Could not find operation after renaming", interfaceObj.getOperation("NewASyncOperationWithMissingMessage")

+                .get(0));

+        assertTrue("Old operation is not renamed", interfaceObj.getOperation("ASyncOperationWithMissingMessage").isEmpty());

+

+        operation = interfaceObj.getOperation("OperationWithNoInputOutput1").get(0);

+        // Test adding input parameter

+        assertEquals(0, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        parameter = addInputParameter(modelRoot, operation, "Parameter1");

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+

+        operation = interfaceObj.getOperation("OperationWithNoInputOutput2").get(0);

+        // Test adding output parameter

+        assertEquals(0, operation.getAllInputParameters().size());

+        assertEquals(0, operation.getAllOutputParameters().size());

+        parameter = addOutputParameter(modelRoot, operation, "Parameter1");

+        assertEquals(0, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals(operation, parameter.getParent());

+        assertEquals(description, parameter.getRoot());

+

+        ((Description) description).save();

+

+        modelRoot = getModelRoot(fileName);

+        description = modelRoot.getDescription();

+

+        // Test if changes are saved

+        interfaceObj = description.getInterface("Operations").get(0);

+        operation = interfaceObj.getOperation("SyncOperation").get(0);

+        assertEquals(2, operation.getAllInputParameters().size());

+        assertEquals(2, operation.getAllOutputParameters().size());

+        assertFalse(operation.getInputParameter("Parameter1").isEmpty());

+        assertNotNull(operation.getInputParameter("Parameter1").get(0));

+        assertFalse(operation.getOutputParameter("Parameter2").isEmpty());

+        assertNotNull(operation.getOutputParameter("Parameter2").get(0));

+        assertEquals("NewDocumentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("SyncOperationWithNoMessage").get(0);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertFalse(operation.getInputParameter("Parameter1").isEmpty());

+        assertNotNull(operation.getInputParameter("Parameter1").get(0));

+        assertFalse(operation.getOutputParameter("Parameter2").isEmpty());

+        assertNotNull(operation.getOutputParameter("Parameter2").get(0));

+        assertEquals("NewDocumentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("SyncOperationWithMissingMessages").get(0);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertFalse(operation.getInputParameter("Parameter1").isEmpty());

+        assertNotNull(operation.getInputParameter("Parameter1").get(0));

+        assertFalse(operation.getOutputParameter("Parameter2").isEmpty());

+        assertNotNull(operation.getOutputParameter("Parameter2").get(0));

+        assertEquals("Documentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("ASyncOperationWithNoMessage").get(0);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertNotNull(operation.getInputParameter("Parameter1"));

+        assertEquals("Documentation", operation.getDocumentation());

+

+        operation = interfaceObj.getOperation("NewASyncOperationWithMissingMessage").get(0);

+        assertNotNull("Operation NewASyncOperationWithMissingMessage could not be found", operation);

+

+        operation = interfaceObj.getOperation("OperationWithNoInputOutput1").get(0);

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(1, operation.getAllInputParameters().size());

+

+        operation = interfaceObj.getOperation("OperationWithNoInputOutput2").get(0);

+        assertEquals(1, operation.getAllOutputParameters().size());

+        assertEquals(0, operation.getAllInputParameters().size());

+

+        // Test Removal of parameters and faults

+        operation = interfaceObj.getOperation("SyncOperation").get(0);

+        assertEquals(2, operation.getAllInputParameters().size());

+        parameter = addInputParameter(modelRoot, operation, "Parameter4");

+        assertEquals(3, operation.getAllInputParameters().size());

+        removeInputParameter(modelRoot, operation, parameter);

+        assertEquals(2, operation.getAllInputParameters().size());

+        assertTrue("Parameter4 is not deleted", operation.getInputParameter("Parameter4").isEmpty());

+        removeInputParameter(modelRoot, operation, operation.getInputParameter("Parameter1").get(0));

+        assertEquals(1, operation.getAllInputParameters().size());

+

+        assertEquals(2, operation.getAllOutputParameters().size());

+        parameter = addOutputParameter(modelRoot, operation, "Parameter4");

+        assertEquals(3, operation.getAllOutputParameters().size());

+        removeOutputParameter(modelRoot, operation, parameter);

+        assertEquals(2, operation.getAllOutputParameters().size());

+        assertTrue("Parameter4 is not deleted", operation.getOutputParameter("Parameter4").isEmpty());

+        removeOutputParameter(modelRoot, operation, operation.getOutputParameter("Parameter2").get(0));

+        assertEquals(1, operation.getAllOutputParameters().size());

+

+        assertEquals(2, operation.getAllFaults().size());

+        removeFault(modelRoot, operation, operation.getFault("fault2").get(0));

+        assertTrue("fault2 is not deleted", operation.getFault("fault2").isEmpty());

+        assertEquals(1, operation.getAllFaults().size());

+        removeFault(modelRoot, operation, operation.getFault("fault1").get(0));

+        assertTrue("fault1 is not deleted", operation.getFault("fault1").isEmpty());

+        assertEquals(0, operation.getAllFaults().size());

+

+        operation = interfaceObj.getOperation("ASyncOperation").get(0);

+        parameter = addInputParameter(modelRoot, operation, "parameter1");

+        assertEquals(2, operation.getAllInputParameters().size());

+        removeInputParameter(modelRoot, operation, parameter);

+        assertEquals(1, operation.getAllInputParameters().size());

+        removeInputParameter(modelRoot, operation, operation.getInputParameter("parameters").get(0));

+        assertEquals(0, operation.getAllInputParameters().size());

+

+        operation = interfaceObj.getOperation("SyncOperation1").get(0);

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+        setOperationType(modelRoot, operation, OperationType.ASYNCHRONOUS);

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+

+        operation = interfaceObj.getOperation("ASyncOperation1").get(0);

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+        setOperationType(modelRoot, operation, OperationType.REQUEST_RESPONSE);

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+

+        operation = interfaceObj.getOperation("SyncOperation2").get(0);

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertEquals(4, parameters.size());

+

+        parameter = operation.getOutputParameter("Parameter1").get(0);

+        removeOutputParameter(modelRoot, operation, parameter);

+        parameters = operation.getAllOutputParameters();

+        assertEquals(3, parameters.size());

+        ((Description) description).save();

+

+        modelRoot = getModelRoot(fileName);

+        description = modelRoot.getDescription();

+

+        // Test if removal changes are saved

+        interfaceObj = description.getInterface("Operations").get(0);

+

+        operation = interfaceObj.getOperation("SyncOperation").get(0);

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertTrue("Parameter4 is not deleted", operation.getInputParameter("Parameter4").isEmpty());

+        assertTrue("Parameter1 is not deleted", operation.getInputParameter("Parameter1").isEmpty());

+

+        assertEquals(1, operation.getAllInputParameters().size());

+        assertTrue("Parameter4 is not deleted", operation.getOutputParameter("Parameter4").isEmpty());

+        assertTrue("Parameter2 is not deleted", operation.getOutputParameter("Parameter2").isEmpty());

+        assertEquals(0, operation.getAllFaults().size());

+

+        operation = interfaceObj.getOperation("ASyncOperation").get(0);

+        assertEquals(0, operation.getAllInputParameters().size());

+

+        operation = interfaceObj.getOperation("SyncOperation1").get(0);

+        assertEquals(0, operation.getAllOutputParameters().size());

+        assertEquals(OperationType.ASYNCHRONOUS, operation.getOperationStyle());

+

+        operation = interfaceObj.getOperation("ASyncOperation1").get(0);

+        assertEquals(OperationType.REQUEST_RESPONSE, operation.getOperationStyle());

+

+        operation = interfaceObj.getOperation("SyncOperation2").get(0);

+        parameters = operation.getAllInputParameters();

+        assertEquals(4, parameters.size());

+        Iterator<IParameter> paramIter = parameters.iterator();

+        assertEquals("Parameter1", paramIter.next().getName());

+        assertEquals("Parameter2", paramIter.next().getName());

+        assertEquals("Parameter3", paramIter.next().getName());

+        assertEquals("Parameter4", paramIter.next().getName());

+

+        parameters = operation.getAllOutputParameters();

+        assertEquals(3, parameters.size());

+        paramIter = parameters.iterator();

+        assertEquals("Parameter2", paramIter.next().getName());

+        assertEquals("Parameter3", paramIter.next().getName());

+        assertEquals("Parameter4", paramIter.next().getName());

+    }

+

+    @Test

+    public void test_Parameter() throws Exception {

+        final String fileName = "TestParameter.wsdl";

+        IFile file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "po.xsd", Document_FOLDER_NAME,

+                this.getProject(), "po.xsd");

+        assertTrue("File po.xsd could not be obtained", file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "example.xsd", Document_FOLDER_NAME,

+                this.getProject(), "example.xsd");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "NullNamespace.xsd",

+                Document_FOLDER_NAME, this.getProject(), "NullNamespace.xsd");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "ParameterType.xsd",

+                Document_FOLDER_NAME, this.getProject(), "ParameterType.xsd");

+        assertTrue("File example.xsd could not be obtained", file.exists());

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("ParameterType.wsdl", fileName);

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation;

+        IParameter parameter;

+

+        description = modelRoot.getDescription();

+

+        // check add and remove operations for old serviceinterface

+        interfaceObj = description.getInterface("ServiceInterface").get(0);

+        operation = interfaceObj.getOperation("Operation").get(0);

+        parameter = operation.getInputParameter("parameters").get(0);

+

+        setParameterName(modelRoot, parameter, "Parameter1");

+        assertEquals("Parameter1", parameter.getName());

+        assertEquals("", parameter.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) parameter, "Documentation");

+        assertEquals("Documentation", parameter.getDocumentation());

+

+        ISchema inlineSchema = description.getSchema("http://sap.com/xi/Purchasing")[0];

+

+        // Set Type and Element from same WSDL

+        assertEquals("NewOperation", parameter.getType().getName());

+        setParameterType(modelRoot, parameter, inlineSchema.getType(false, "Address"), false);

+        assertEquals("Address", parameter.getType().getName());

+        setParameterType(modelRoot, parameter, inlineSchema.getType(false, "BusinessTransactionDocumentID"), false);

+        assertEquals("BusinessTransactionDocumentID", parameter.getType().getName());

+        setParameterType(modelRoot, parameter, inlineSchema.getType(false, "LanguageCode"), false);

+        assertEquals("LanguageCode", parameter.getType().getName());

+        setParameterType(modelRoot, parameter, inlineSchema.getType(false, "BusinessTransactionDocumentID"), false);

+        setParameterType(modelRoot, parameter, inlineSchema.getType(true, "PurchaseOrderConfirmationRequest"), false);

+        assertEquals("PurchaseOrderConfirmationRequest", parameter.getType().getName());

+        ISchema[] schemas = description.getSchema("http://www.example.org/ParameterType/");

+        inlineSchema = schemas[0].getType(true, "NewOperation") == null ? schemas[1] : schemas[0];

+        setParameterType(modelRoot, parameter, inlineSchema.getType(true, "NewOperation"), false);

+        assertEquals("NewOperation", parameter.getType().getName());

+        setParameterType(modelRoot, parameter, inlineSchema.getType(false, "complexType"), false);

+        assertEquals("complexType", parameter.getType().getName());

+

+        SchemaNamespaceCondition condition = new SchemaNamespaceCondition("");

+

+        // Set Type and Element from imported XSD

+        condition.setNamespace("http://www.example.com/");

+        inlineSchema = getSchema(description.getAllVisibleSchemas(), condition);

+        setParameterType(modelRoot, parameter, inlineSchema.getType(false, "Address"), false);

+        assertEquals("Address", parameter.getType().getName());

+        setParameterType(modelRoot, parameter, inlineSchema.getType(true, "purchaseOrder"), false);

+        assertEquals("purchaseOrder", parameter.getType().getName());

+        // Set Type from included XSD

+        condition.setNamespace("http://www.example.com/IPO");

+

+        ISchema[] ipoSchemas = description.getSchema("http://www.example.com/IPO");

+        assertEquals(3, ipoSchemas.length);

+        inlineSchema = getSchema1(ipoSchemas[0].getAllReferredSchemas(), condition);

+        if (inlineSchema == null || inlineSchema.getType(false, "Address") == null) {

+            inlineSchema = getSchema1(ipoSchemas[1].getAllReferredSchemas(), condition);

+        }

+        if (inlineSchema == null || inlineSchema.getType(false, "Address") == null) {

+            inlineSchema = getSchema1(ipoSchemas[2].getAllReferredSchemas(), condition);

+        }

+

+        setParameterType(modelRoot, parameter, inlineSchema.getType(false, "Address"), false);

+        assertEquals("Address", parameter.getType().getName());

+        setParameterType(modelRoot, parameter, inlineSchema.getType(true, "purchaseOrder"), false);

+        assertEquals("purchaseOrder", parameter.getType().getName());

+        // Set Type form XSD With Null namespace

+        inlineSchema = description.getSchema("http://www.example.com/IPO/Include/NullNamespace")[0];

+        condition.setNamespace(null);

+        inlineSchema = getSchema1(inlineSchema.getAllReferredSchemas(), condition);

+

+		setParameterType(modelRoot, parameter, inlineSchema.getType(false,

+				"Address"), false);

+		assertEquals("Address", parameter.getType().getName());

+		setParameterType(modelRoot, parameter, inlineSchema.getType(true,

+				"purchaseOrder"), false);

+		assertEquals("purchaseOrder", parameter.getType().getName());

+

+        // Set Type from XSD With Same Namespace

+        condition.setNamespace("http://www.example.org/ParameterType/");

+        inlineSchema = getSchema(description.getContainedSchemas(), condition);

+        setParameterType(modelRoot, parameter, inlineSchema.getType(true, "NewOperation"), false);

+        assertEquals("NewOperation", parameter.getType().getName());

+        setParameterType(modelRoot, parameter, inlineSchema.getType(false, "complexType"), false);

+        assertEquals("complexType", parameter.getType().getName());

+

+        ResourceUtils.createFolderInProject(getProject(), "src");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported.xsd", SOURCE_FOLDER, this

+                .getProject(), "Imported.xsd");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "SupplierInvoice.wsdl", SOURCE_FOLDER,

+                this.getProject(), "SupplierInvoice.wsdl");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestSingleSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestSingleSchema.wsdl");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestMultipleSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestMultipleSchema.wsdl");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestExternal.xsd",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestExternal.xsd");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestImportedSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestImportedSchema.wsdl");

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestIncludedSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestIncludedSchema.wsdl");

+

+        modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "ParameterTypeTwo.wsdl");

+        description = modelRoot.getDescription();

+        interfaceObj = description.getInterface("PurchaseOrderConfirmation").get(0);

+        operation = interfaceObj.getOperation("PurchaseOrderConfirmationRequestResponse_In").get(0);

+        parameter = operation.getInputParameter("parameters").get(0); // What **

+        // does

+        // this

+        // line

+        // test?

+    }

+

+    @Test

+    public void test_Fault() throws Exception {

+        // check for referenced documents

+        final String fileName = "TestOperationFault.wsdl";

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("Operations.wsdl", fileName);

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter parameter;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault faultObj;

+        description = modelRoot.getDescription();

+

+        interfaceObj = description.getInterface("Operations").get(0);

+        operation = interfaceObj.getOperation("TestFault").get(0);

+        faultObj = operation.getFault("fault1").get(0);

+        assertEquals("fault1", faultObj.getName());

+        setFaultName(modelRoot, faultObj, "newFault");

+        assertEquals("newFault", faultObj.getName());

+

+        assertEquals("", faultObj.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) faultObj, "Documentation");

+        assertEquals("Documentation", faultObj.getDocumentation());

+        setDocumentation(modelRoot, (AbstractWSDLComponent) faultObj, "NewDocumentation");

+        assertEquals("NewDocumentation", faultObj.getDocumentation());

+        assertEquals(1, faultObj.getParameters().size());

+        parameter = addFaultParameter(modelRoot, faultObj, "Parameter1", operation);

+        parameter = addFaultParameter(modelRoot, faultObj, "Parameter2", operation);

+        assertEquals(3, faultObj.getParameters().size());

+        removeFaultParameter(modelRoot, faultObj, operation, faultObj.getParameter("parameters").get(0));

+        ;

+        assertEquals(2, faultObj.getParameters().size());

+        removeFaultParameter(modelRoot, faultObj, operation, parameter);

+        assertEquals(1, faultObj.getParameters().size());

+

+        faultObj = operation.getFault("fault2").get(0);

+        assertEquals(4, faultObj.getParameters().size());

+

+        faultObj = operation.getFault("faultWithMissingMessage").get(0);

+        assertEquals(0, faultObj.getParameters().size());

+        parameter = addFaultParameter(modelRoot, faultObj, "Parameter1", operation);

+        parameter = addFaultParameter(modelRoot, faultObj, "Parameter2", operation);

+        assertEquals(2, faultObj.getParameters().size());

+        removeFaultParameter(modelRoot, faultObj, operation, parameter);

+        assertEquals(1, faultObj.getParameters().size());

+

+        faultObj = operation.getFault("faultWithNoMessage").get(0);

+        assertEquals(0, faultObj.getParameters().size());

+        parameter = addFaultParameter(modelRoot, faultObj, "Parameter1", operation);

+        parameter = addFaultParameter(modelRoot, faultObj, "Parameter2", operation);

+        assertEquals(2, faultObj.getParameters().size());

+        removeFaultParameter(modelRoot, faultObj, operation, parameter);

+        assertEquals(1, faultObj.getParameters().size());

+

+        operation = interfaceObj.getOperation("ASyncOperation").get(0);

+        assertEquals(0, operation.getAllFaults().size());

+

+        faultObj = addFault(modelRoot, operation, "newFault");

+        addFaultParameter(modelRoot, faultObj, "Parameter1", operation);

+        assertEquals(2, faultObj.getParameters().size());

+

+        ((Description) description).save();

+

+        modelRoot = getModelRoot("TestOperationFault.wsdl");

+        interfaceObj = description.getInterface("Operations").get(0);

+        operation = interfaceObj.getOperation("TestFault").get(0);

+        faultObj = operation.getFault("newFault").get(0);

+        assertEquals(1, faultObj.getParameters().size());

+        assertEquals("NewDocumentation", faultObj.getDocumentation());

+        assertFalse("Could not find parameter Parameter1", faultObj.getParameter("Parameter1").isEmpty());

+        assertNotNull("Could not find parameter Parameter1", faultObj.getParameter("Parameter1").get(0));

+

+        faultObj = operation.getFault("fault2").get(0);

+        assertEquals(4, faultObj.getParameters().size());

+        Iterator<IParameter> paramIter = faultObj.getParameters().iterator();

+        assertEquals("Parameter1", paramIter.next().getName());

+        assertEquals("Parameter2", paramIter.next().getName());

+        assertEquals("Parameter3", paramIter.next().getName());

+        assertEquals("Parameter4", paramIter.next().getName());

+

+        faultObj = operation.getFault("faultWithMissingMessage").get(0);

+        assertEquals(1, faultObj.getParameters().size());

+

+        faultObj = operation.getFault("faultWithNoMessage").get(0);

+        assertEquals(1, faultObj.getParameters().size());

+

+        operation = interfaceObj.getOperation("ASyncOperation").get(0);

+        faultObj = operation.getFault("newFault").get(0);

+        assertEquals(2, faultObj.getParameters().size());

+        assertFalse("Could not find parameter Parameter1", faultObj.getParameter("Parameter1").isEmpty());

+        assertNotNull("Could not find parameter Parameter1", faultObj.getParameter("Parameter1").get(0));

+

+    }

+

+    @Test

+    public void testRenameFault() throws Exception {

+

+        final String fileName = "TestOperationFault.wsdl";

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("Operations.wsdl", fileName);

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface interfaceObj;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation;

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault faultObj;

+        description = modelRoot.getDescription();

+

+        interfaceObj = description.getInterface("Operations").get(0);

+        operation = interfaceObj.getOperation("TestFault").get(0);

+        faultObj = operation.getFault("fault1").get(0);

+        assertEquals("fault1", faultObj.getName());

+        setFaultName(modelRoot, faultObj, "newFault");

+        assertEquals("newFault", faultObj.getName());

+        EList eBindings = ((Definition) description.getComponent()).getEBindings();

+        assertFalse(eBindings.isEmpty());

+        for (Object binding : eBindings) {

+            EList operations = ((Binding) binding).getEBindingOperations();

+            for (Object op : operations) {

+                EList faults = ((BindingOperation) op).getEBindingFaults();

+                for (Object fault : faults) {

+                    assertEquals(faultObj.getComponent(), ((BindingFault) fault).getFault());

+                    EList elements = ((BindingFault) fault).getEExtensibilityElements();

+                    for (Object soapFault : elements) {

+                        assertEquals("newFault", ((SOAPFault) soapFault).getName());

+                    }

+                }

+            }

+        }

+    }

+

+    private ISchema getSchema(final Collection<ISchema> schemas, ICondition<ISchema> condition) {

+        for (ISchema schema : schemas) {

+            if (condition.isSatisfied(schema))

+                return schema;

+        }

+        return null;

+    }

+

+    private ISchema getSchema1(final Collection<ISchema> schemas, ICondition<ISchema> condition) {

+        for (ISchema schema : schemas) {

+            if (condition.isSatisfied(schema))

+                return schema;

+        }

+        return null;

+    }

+

+    interface ICondition<T> {

+        boolean isSatisfied(T in);

+    }

+

+    private class SchemaNamespaceCondition implements ICondition<ISchema> {

+

+        private String _namespace;

+

+        public SchemaNamespaceCondition(final String namespace) {

+            this._namespace = namespace;

+        }

+

+        public boolean isSatisfied(ISchema in) {

+            if ((null == _namespace && null == in.getNamespace()) || (null != _namespace && _namespace.equals(in.getNamespace())))

+                return true;

+            return false;

+        }

+

+        public void setNamespace(final String namespace) {

+            this._namespace = namespace;

+        }

+

+    }

+

+    private IWsdlModelRoot copyAndGetModelRoot(final String fileName, final String targetName) throws Exception {

+        return getWSDLModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV + fileName, targetName);

+    }

+

+    private IWsdlModelRoot getModelRoot(final String fileName) throws Exception {

+        final IFile file = (IFile) getProject().findMember(new Path(Document_FOLDER_NAME + IPath.SEPARATOR + fileName));

+        assertTrue(file.exists());

+        return getWSDLModelRoot(file);

+    }

+

+    private static IParameter addInputParameter(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation, String name) throws ExecutionException {

+        AddInParameterCommand cmd = new AddInParameterCommand(modelRoot, operation, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        return cmd.getParameter();

+    }

+

+    private static IParameter addOutputParameter(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation, String name) throws ExecutionException {

+        AddOutParameterCommand cmd = new AddOutParameterCommand(modelRoot, operation, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        return cmd.getParameter();

+    }

+

+    private static void removeInputParameter(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation, IParameter parameter) throws ExecutionException {

+        DeleteInParameterCommand cmd = new DeleteInParameterCommand(modelRoot, operation, parameter);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void removeOutputParameter(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation, IParameter parameter) throws ExecutionException {

+        DeleteOutParameterCommand cmd = new DeleteOutParameterCommand(modelRoot, operation, parameter);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault addFault(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation, String name) throws ExecutionException {

+        AddFaultCommand cmd = new AddFaultCommand(modelRoot, operation, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        return cmd.getFault();

+    }

+

+    private static void removeFault(IWsdlModelRoot modelRoot, org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault fault) throws ExecutionException {

+        DeleteFaultCommand cmd = new DeleteFaultCommand(modelRoot, operation, fault);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void renameOperation(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation, String name) throws ExecutionException {

+        RenameOperationCommand cmd = new RenameOperationCommand(modelRoot, operation, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void setOperationType(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation, OperationType operationType)

+            throws ExecutionException {

+        ChangeOperationTypeCommand cmd = new ChangeOperationTypeCommand(modelRoot, operation, operationType, false);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void setParameterName(IWsdlModelRoot modelRoot, IParameter parameter, String name) throws ExecutionException {

+        RenameParameterCommand cmd = new RenameParameterCommand(modelRoot, parameter, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void setParameterType(IWsdlModelRoot modelRoot, IParameter parameter, IType newType, boolean createWrapper)

+            throws ExecutionException {

+        SetParameterTypeCommand cmd = new SetParameterTypeCommand(parameter, (AbstractType) newType);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void setFaultName(IWsdlModelRoot modelRoot, org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault fault,

+            String name) throws ExecutionException {

+        RenameFaultCommand cmd = new RenameFaultCommand(modelRoot, fault, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static IParameter addFaultParameter(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault fault, String name,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation) throws ExecutionException {

+        AddFaultParameterCommand cmd = new AddFaultParameterCommand(modelRoot, fault, name, operation);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        return cmd.getParameter();

+    }

+

+    private static void removeFaultParameter(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault fault,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation operation, IParameter parameter) throws ExecutionException {

+        DeleteFaultParameterCommand cmd = new DeleteFaultParameterCommand(modelRoot, fault, parameter, operation);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void setDescriptionNamespace(IWsdlModelRoot modelRoot,

+            org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description, String namespace) throws ExecutionException {

+        ChangeDefinitionTNSCompositeCommand cmd = new ChangeDefinitionTNSCompositeCommand(modelRoot, description, namespace);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void removeSchema(IWsdlModelRoot modelRoot, ISchema schema) throws ExecutionException {

+        RemoveSchemaCommand cmd = new RemoveSchemaCommand(modelRoot, schema);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static IOperation addOperation(IWsdlModelRoot modelRoot, IServiceInterface serviceInterface, String name,

+            OperationType operationType) throws ExecutionException {

+        AddOperationCommand cmd = new AddOperationCommand(modelRoot, serviceInterface, name, operationType);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        return cmd.getOperation();

+    }

+

+    private static void setDocumentation(IWsdlModelRoot modelRoot, AbstractWSDLComponent modelObject, String documentation)

+            throws ExecutionException {

+        SetDocumentationCommand cmd = new SetDocumentationCommand(modelRoot, modelObject,

+                modelObject.getComponent().getElement(), documentation);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        validateDocumentationElement(modelObject, true);

+    }

+

+    private static void validateDocumentationElement(IModelObject modelObject, boolean hasDocumentation) {

+        NodeList childNodes = ((WSDLElement) modelObject.getComponent()).getElement().getChildNodes();

+        int found = 0;

+        for (int ndx = 0; ndx < childNodes.getLength(); ndx++) {

+            Node node = childNodes.item(ndx);

+            if (node.getNodeType() == Node.ELEMENT_NODE

+                    && ("wsdl:documentation".equals(node.getNodeName()) || "documentation".equals(node.getNodeName()))) {

+                found++;

+            }

+        }

+

+        if (!hasDocumentation && found > 0) {

+            Assert.fail("No documentation nodes were expected, but " + found + " were found");

+        }

+

+        if (hasDocumentation && found > 1) {

+            Assert.fail("More than one documentation node was found: " + found);

+        }

+

+        if (hasDocumentation && found == 0) {

+            Assert.fail("Documentation node was not found");

+        }

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/WsdlMultipleComponentsTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/WsdlMultipleComponentsTest.java
new file mode 100644
index 0000000..9ba64c1
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/WsdlMultipleComponentsTest.java
@@ -0,0 +1,326 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import static org.eclipse.wst.sse.sieditor.test.util.SIEditorUtils.findNamedObject;

+import static org.eclipse.wst.sse.sieditor.test.util.SIEditorUtils.validateNamedComponents;

+

+import java.util.Arrays;

+import java.util.Collection;

+import java.util.List;

+

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IFault;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IServiceInterface;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.OperationType;

+import org.eclipse.wst.sse.sieditor.model.wsdl.impl.OperationParameter;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+

+@SuppressWarnings("nls")

+public class WsdlMultipleComponentsTest extends SIEditorBaseTest {

+

+    protected String getProjectName() {

+        return "WsdlNComponentsTest";

+    }

+

+    @Test

+    public void testMultipleComponents() throws Exception {

+        final String INTERFACE_NAME = "SecondPurchaseOrderConfirmation";

+        final String OPERATION_NAME = "SecondPurchaseOrderConfirmationRequestResponse_In";

+        final String FAULT_NAME = "exception01";

+        final IDescription description = getModelRoot("MultipleComponents.wsdl");

+

+        // Multiple Interfaces

+        final Collection<IServiceInterface> interfaces = description.getAllInterfaces();

+        assertEquals(interfaces.size() + " interfaces returned instead of 3", 3, interfaces.size());

+        validateNamedComponents(interfaces, Arrays.asList("PurchaseOrderConfirmation", "SecondPurchaseOrderConfirmation"));

+

+        // Multiple Operations

+        final IServiceInterface serviceInterface = findNamedObject(interfaces, INTERFACE_NAME);

+        assertNotNull("No service interface found for name ", serviceInterface);

+

+        final Collection<IOperation> operations = serviceInterface.getAllOperations();

+        assertEquals(operations.size() + " operations returned instead of 2", 2, operations.size());

+        validateNamedComponents(operations, Arrays.asList("PurchaseOrderConfirmationRequestResponse_In",

+                "SecondPurchaseOrderConfirmationRequestResponse_In"));

+

+        // Multiple Faults

+        final IOperation operation = findNamedObject(operations, OPERATION_NAME);

+        assertNotNull("No operation found for name ", operation);

+

+        final Collection<IFault> faults = operation.getAllFaults();

+        assertEquals(faults.size() + " faults returned instead of 2", 2, faults.size());

+        validateNamedComponents(faults, Arrays.asList("exception00", "exception01"));

+

+        // MultipleParameters

+        final Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertEquals(parameters.size() + " parameters returned instead of 2", 2, parameters.size());

+        validateNamedComponents(parameters, Arrays.asList("firstInParameter", "secondInParameter"));

+

+        final Collection<IParameter> outparameters = operation.getAllOutputParameters();

+        assertEquals(outparameters.size() + " out parameters returned instead of 2", 2, outparameters.size());

+        validateNamedComponents(outparameters, Arrays.asList("firstOutParameter", "secondOutParameter"));

+

+        // MultipleFaultParameters

+        final IFault fault = findNamedObject(faults, FAULT_NAME);

+        assertNotNull("No Fault found with name " + FAULT_NAME, fault);

+        final Collection<IParameter> faultParameters = fault.getParameters();

+        validateNamedComponents(faultParameters, Arrays.asList("exception00", "exception01", "exception02"));

+    }

+

+    @Test

+    public void testNoPortTypes() throws Exception {

+        // No Service Interfaces

+        final IDescription description = getModelRoot("NoPortTypes.wsdl");

+

+        final Collection<IServiceInterface> interfaces = description.getAllInterfaces();

+        assertNotNull("Null returned for no PortTypes in a file", interfaces);

+        assertTrue(interfaces.size() == 0);

+

+    }

+

+    @Test

+    public void testNoSchemas() throws Exception {

+        // No Service Interfaces

+        IDescription description = getModelRoot("NoTypes.wsdl");

+

+        Collection<ISchema> schemas = description.getContainedSchemas();

+        assertNotNull("Empty collection must be returned when there are no schemas", schemas);

+        assertEquals(0, schemas.size());

+

+        description = getModelRoot("NoSchemas.wsdl");

+        schemas = description.getContainedSchemas();

+        assertNotNull("Empty collection must be returned when there are no schemas", schemas);

+        assertEquals(0, schemas.size());

+    }

+

+    @Test

+    public void testNoComponents() throws Exception {

+        final IDescription description = getModelRoot("NoComponents.wsdl");

+

+        // No Operations

+        final Collection<IServiceInterface> interfaces = description.getAllInterfaces();

+        assertNotNull(interfaces);

+        assertTrue(interfaces.size() == 3);

+

+        IServiceInterface serviceInterface = findNamedObject(interfaces, "PortTypeWithNoOperations");

+        assertNotNull(serviceInterface);

+        Collection<IOperation> operations = serviceInterface.getAllOperations();

+        assertNotNull("Null returned when there are no operations", operations);

+        assertTrue(operations.size() == 0);

+

+        serviceInterface = findNamedObject(interfaces, "PortType");

+        assertNotNull(serviceInterface);

+

+        operations = serviceInterface.getAllOperations();

+        assertTrue(operations.size() == 5);

+

+        // NoParameters

+        // No Faults

+        IOperation operation = findNamedObject(operations, "OperationWithNoInParametersAndFaults");

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertNotNull("Empty Collecitons should be returned when there are no in parametes", parameters);

+        assertTrue(parameters.size() == 0);

+        Collection<IFault> faults = operation.getAllFaults();

+        assertNotNull("Empty Collecitons must be returned when there are no faults", faults);

+        assertTrue(faults.size() == 0);

+

+        operation = findNamedObject(operations, "OperationWithNoOutParameters");

+        parameters = operation.getAllOutputParameters();

+        assertNotNull("Empty Collecitons must be returned when there are no out parametes", parameters);

+        assertTrue(parameters.size() == 0);

+

+        operation = findNamedObject(operations, "OperationWithNoFaults");

+        faults = operation.getAllFaults();

+        assertNotNull("Empty Collecitons must be returned when there are no faults", faults);

+        assertTrue(faults.size() == 0);

+

+        // No Fault Parameters

+        operation = findNamedObject(operations, "OperationWithNoFaultParameters");

+        faults = operation.getAllFaults();

+        IFault fault = findNamedObject(faults, "fault");

+        parameters = fault.getParameters();

+        assertNotNull("Empty Collecitons must be returned when there are no fault parametes", parameters);

+        assertTrue(parameters.size() == 0);

+

+        operation = findNamedObject(operations, "OperationWithNoInputOutput");

+        parameters = operation.getAllInputParameters();

+        assertNotNull("Empty Collecitons must be returned when there are no in parametes", parameters);

+        assertTrue(parameters.size() == 0);

+        parameters = operation.getAllOutputParameters();

+        assertNotNull("Empty Collecitons must be returned when there are no out parametes", parameters);

+        assertTrue(parameters.size() == 0);

+

+        // PortType with invalid operations

+        serviceInterface = findNamedObject(interfaces, "PortTypeWithInvalidOperations");

+        assertNotNull(serviceInterface);

+

+        operations = serviceInterface.getAllOperations();

+        assertTrue(operations.size() == 0);

+    }

+

+    @Test

+    public void testDuplicateComponents() throws Exception {

+        final IDescription description = getModelRoot("DuplicateComponents.wsdl");

+        // Duplicate Interfaces

+

+        final Collection<IServiceInterface> interfaces = description.getAllInterfaces();

+        assertNotNull(interfaces);

+        assertTrue(interfaces.size() == 3);

+

+        List<IServiceInterface> sIs = description.getInterface("DuplicatePortType");

+        assertFalse(sIs.isEmpty());

+        IServiceInterface serviceInterface = description.getInterface("DuplicatePortType").get(0);

+        assertNotNull(serviceInterface);

+

+        sIs =description.getInterface("PortType");

+        assertFalse(sIs.isEmpty());

+        serviceInterface =  sIs.get(0);

+        assertNotNull(serviceInterface);

+

+        // Duplicate Operations

+        Collection<IOperation> operations = serviceInterface.getAllOperations();

+        assertTrue(operations.size() == 3);

+

+        List<IOperation> ops = serviceInterface.getOperation("DuplicateOperation");

+        assertFalse(ops.isEmpty());

+        IOperation operation = ops.get(0);

+        assertNotNull(operation);

+        ops = serviceInterface.getOperation("Operation");

+        assertFalse(ops.isEmpty());

+        operation = ops.get(0);

+        assertNotNull(operation);

+

+        // Duplicate Faults

+        Collection<IFault> faults = operation.getAllFaults();

+        assertTrue(faults.size() == 3);

+        List<IFault> flts = operation.getFault("duplicatefault");

+        assertFalse(flts.isEmpty());

+        IFault fault = flts.get(0);

+        assertNotNull(fault);

+        flts = operation.getFault("fault");

+        assertFalse(flts.isEmpty());

+        fault = flts.get(0);

+        assertNotNull(fault);

+

+        // Duplicate Parameters

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertTrue(parameters.size() == 3);

+        List<IParameter> prms = operation.getInputParameter("duplicateparameter");

+        assertFalse(prms.isEmpty());

+        IParameter parameter = prms.get(0);

+        assertNotNull(parameter);

+        prms = operation.getInputParameter("parameter");

+        assertFalse(prms.isEmpty());

+        parameter = prms.get(0);

+        assertNotNull(parameter);

+        parameters = operation.getAllOutputParameters();

+        assertTrue(parameters.size() == 3);

+        prms = operation.getOutputParameter("duplicateparameter");

+        assertFalse(prms.isEmpty());

+        parameter = prms.get(0);

+        assertNotNull(parameter);

+        prms = operation.getOutputParameter("parameter");

+        assertFalse(prms.isEmpty());

+        parameter = prms.get(0);

+        assertNotNull(parameter);

+

+        // Duplicate Fault Parameters

+        parameters = fault.getParameters();

+        assertTrue(parameters.size() == 3);

+        prms = operation.getInputParameter("duplicateparameter");

+        assertFalse(prms.isEmpty());

+        parameter = prms.get(0);

+        assertNotNull(parameter);

+        prms = operation.getInputParameter("parameter");

+        assertFalse(prms.isEmpty());

+        parameter = prms.get(0);

+        assertNotNull(parameter);

+    }

+

+    @Test

+    public void testSharedMessages() throws Exception {

+        final IDescription description = getModelRoot("SharedMessage.wsdl");

+

+        List<IServiceInterface> sIs = description.getInterface("SharedMessage");

+        assertFalse(sIs.isEmpty());

+        IServiceInterface serviceInterface = sIs.get(0);

+        assertNotNull(serviceInterface);

+

+        List<IOperation> ops = serviceInterface.getOperation("Operation");

+        assertFalse(ops.isEmpty());

+        IOperation operation = ops.get(0);

+        assertNotNull(operation);

+

+        List<IFault> flts = operation.getFault("fault");

+        assertFalse(flts.isEmpty());

+        IFault fault = flts.get(0);

+        assertNotNull(fault);

+

+        // Duplicate Parameters

+        Collection<IParameter> parameters = operation.getAllInputParameters();

+        assertTrue(parameters.size() == 1);

+        parameters = operation.getAllOutputParameters();

+        assertTrue(parameters.size() == 1);

+

+        // Duplicate Fault Parameters

+        parameters = fault.getParameters();

+        assertTrue(parameters.size() == 1);

+    }

+

+    @Test

+    public void testOperationType() throws Exception {

+        final IDescription description = getModelRoot("MultipleComponents.wsdl");

+        List<IServiceInterface> sIs = description.getInterface("OperationTypes");

+        assertFalse(sIs.isEmpty());

+        IServiceInterface serviceInterface = sIs.get(0);

+        assertNotNull("No interface returned for name OperationTypes", serviceInterface);

+        Collection<IOperation> operations = serviceInterface.getAllOperations();

+        assertEquals(4, operations.size());

+

+        IOperation operation = serviceInterface.getOperation("SyncOperationWithFault").get(0);

+        OperationType style = operation.getOperationStyle();

+        assertNotNull("style is null for SyncOperationWithFault", style);

+        assertTrue("style for SyncOperationWithFault is not REQUEST_RESPONSE", OperationType.REQUEST_RESPONSE == style);

+

+        operation = serviceInterface.getOperation("SyncOperationWithNoFault").get(0);

+        style = operation.getOperationStyle();

+        assertNotNull("style is null for SyncOperationWithNoFault", style);

+        assertTrue("style for SyncOperationWithNoFault is not REQUEST_RESPONSE", OperationType.REQUEST_RESPONSE == style);

+

+        operation = serviceInterface.getOperation("ASyncOperationWithFault").get(0);

+        style = operation.getOperationStyle();

+        assertNotNull("style is null for ASyncOperationWithFault", style);

+        assertTrue("style for ASyncOperationWithFault is not ASYNCHRONOUS", OperationType.ASYNCHRONOUS == style);

+

+        operation = serviceInterface.getOperation("ASyncOperationWithNoFault").get(0);

+        style = operation.getOperationStyle();

+        assertNotNull("style is null for ASyncOperationWithNoFault", style);

+        assertTrue("style for ASyncOperationWithNoFault is not ASYNCHRONOUS", OperationType.ASYNCHRONOUS == style);

+    }

+

+    private IDescription getModelRoot(String fileName) throws Exception {

+        final String fullPath = Constants.DATA_PUBLIC_SELF_KESHAV + fileName;

+        final IWsdlModelRoot modelRoot = getWSDLModelRoot(fullPath, fileName);

+        assertNotNull("Could not Acquire Model Root for " + fullPath, modelRoot);

+        return modelRoot.getDescription();

+    }

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDMultipleComponentsTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDMultipleComponentsTest.java
new file mode 100644
index 0000000..0fe1e2e
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDMultipleComponentsTest.java
@@ -0,0 +1,127 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.Collection;

+

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IElement;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IType;

+

+@SuppressWarnings("nls")

+public class XSDMultipleComponentsTest extends SIEditorBaseTest {

+

+    protected String getProjectName() {

+        return "XSDMultipleComponentsTest";

+    }

+

+    @Test

+    public void testMultipleComponents() throws Exception {

+        // check for referenced documents

+        final IWsdlModelRoot modelRoot = getModelRoot("TypesMultipleComponents.wsdl");

+        final IDescription description = modelRoot.getDescription();

+        assertNotNull(description);

+

+        final ISchema[] refSchemas = description.getSchema("http://www.example.org/StructureType/");

+        assertEquals(2, refSchemas.length);

+        ISchema schema = refSchemas[0].getAllContainedTypes().size() == 17 ? refSchemas[0] : refSchemas[1];

+

+        final Collection<IType> types = schema.getAllContainedTypes();

+        assertEquals(17, types.size());

+

+        ISimpleType simpleType = (ISimpleType) schema.getType(false, "simpleType");

+        assertNotNull("Type is null", simpleType);

+

+        IStructureType structureType = (IStructureType) schema.getType(false, "complexType");

+        assertNotNull("Type is null", structureType);

+        structureType = (IStructureType) schema.getType(true, "complexType");

+        assertNotNull("Type is null", structureType);

+

+        assertNotNull("Type is null", schema.getType(false, "sameType"));

+

+        structureType = (IStructureType) schema.getType(false, "ctExtension");

+        Collection<IElement> elements = structureType.getElements("complexType");

+        assertEquals(2, elements.size());

+        IElement[] elementsArray = elements.toArray(new IElement[2]);

+        IElement element = elementsArray[0];

+        assertNotNull("Type is null", element.getType());

+        element = elementsArray[1];

+        assertNotNull("Type is null", element.getType());

+        elements = structureType.getElements("elementParticle1");

+        assertEquals(2, elements.size());

+        elementsArray = elements.toArray(new IElement[2]);

+        element = elementsArray[0];

+        assertNotNull("Type is null", element.getType());

+        assertTrue("Type is not StructureType", element.getType() instanceof IStructureType);

+        element = elementsArray[1];

+        assertNotNull("Type is null", element.getType());

+        assertTrue("Type is not SimpleType", element.getType() instanceof ISimpleType);

+        elements = structureType.getElements("elementParticle4");

+        element = elements.iterator().next();

+        assertNotNull("Type is null", element.getType());

+        assertEquals("sameType", element.getType().getName());

+        elements = structureType.getElements("attribute1");

+        assertEquals(2, elements.size());

+        elementsArray = elements.toArray(new IElement[2]);

+        element = elementsArray[0];

+        assertNotNull("Type is null", element.getType());

+        assertTrue("Type is not SimpleType", element.getType() instanceof ISimpleType);

+        element = elementsArray[1];

+        assertNotNull("Type is null", element.getType());

+        assertTrue("Type is not SimpleType", element.getType() instanceof ISimpleType);

+        elements = structureType.getElements("globalAttribute1");

+        assertEquals(2, elements.size());

+        elementsArray = elements.toArray(new IElement[2]);

+        element = elementsArray[0];

+        assertNull("Type is not null", element.getType());

+        element = elementsArray[1];

+        assertNull("Type is not null", element.getType());

+    }

+

+    @Test

+    public void testNoComponents() throws Exception {

+        // check for referenced documents

+        final IWsdlModelRoot modelRoot = getModelRoot("TypesMultipleComponents.wsdl");

+        final IDescription description = modelRoot.getDescription();

+        assertNotNull(description);

+

+        ISchema[] refSchemas = description.getSchema("http://www.example.org/StructureType/NoComponents");

+        assertEquals(1, refSchemas.length);

+        ISchema schema = refSchemas[0];

+        Collection<IType> types = schema.getAllContainedTypes();

+        assertEquals(0, types.size());

+        refSchemas = description.getSchema("http://www.example.org/StructureType/NoElements");

+        assertEquals(1, refSchemas.length);

+        schema = refSchemas[0];

+        types = schema.getAllContainedTypes();

+        assertEquals(2, types.size());

+        IStructureType structureType = (IStructureType) schema.getType(false, "complexTypeWithModelGroup");

+        assertEquals(0, structureType.getAllElements().size());

+        structureType = (IStructureType) schema.getType(false, "complexTypeWithNoModelGroup");

+        assertEquals(0, structureType.getAllElements().size());

+    }

+

+    private IWsdlModelRoot getModelRoot(final String fileName) throws Exception {

+        return getWSDLModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV + fileName, fileName);

+    }

+

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDReadAPITest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDReadAPITest.java
new file mode 100644
index 0000000..e6488e4
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDReadAPITest.java
@@ -0,0 +1,466 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import static org.eclipse.wst.sse.sieditor.test.util.SIEditorUtils.validateNamedComponents;

+

+import java.util.Arrays;

+import java.util.Collection;

+

+import junit.framework.Assert;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.emf.common.util.URI;

+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.RenameNamedComponent;

+import org.eclipse.wst.sse.sieditor.core.common.IEnvironment;

+import org.eclipse.wst.sse.sieditor.core.editorfwk.ModelHandler;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IElement;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IFacet;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IType;

+

+@SuppressWarnings("nls")

+public class XSDReadAPITest extends SIEditorBaseTest {

+

+    protected static final String DATA_PUBLIC_SELF_GF_REL_PATH = "pub/self/mix2/";

+

+    protected String getProjectName() {

+        return "XSDReadAPITests";

+    }

+

+    @Test

+    public void test_Schema() throws Exception {

+        final IFile file = ResourceUtils.copyFileIntoTestProject("pub/self/mix2/ChangePurchaseOrder_WSD.wsdl",

+                Document_FOLDER_NAME, this.getProject(), "One.wsdl");

+        final ResourceSetImpl resourceSet = new ResourceSetImpl();

+        IWsdlModelRoot root = (IWsdlModelRoot) ModelHandler.retrieveModelObject(resourceSet, URI.createFileURI(file.getLocation()

+                .toFile().getAbsolutePath()), false);

+        setupEnvironment(root);

+

+        final IDescription description = root.getDescription();

+        Collection<ISchema> containedSchemas = description.getContainedSchemas();

+        description.getContainedSchemas();

+        assertEquals(2, containedSchemas.size());

+

+        ISchema[] schemas = description.getSchema("http://sap.com/xi/SAPGlobal20/Global");

+        assertNotNull(schemas);

+        assertEquals(1, schemas.length);

+

+        ISchema schema = schemas[0];

+        Assert.assertEquals("http://sap.com/xi/SAPGlobal20/Global", schema.getNamespace()); // @Test-0030

+

+        Collection<IType> types = schema.getAllContainedTypes();

+        Assert.assertEquals(3, types.size()); // @Test-0031

+        validateNamedComponents(types, Arrays.asList("StandardMessageFault", "PurchaseOrderChangeRequest_sync",

+                "PurchaseOrderChangeConfirmation_sync"));

+

+        Collection<ISchema> referredSchemas = schema.getAllReferredSchemas();

+        assertEquals(2, referredSchemas.size());

+

+        IType type = schema.getType(true, "PurchaseOrderChangeRequest_sync");

+        assertNotNull("Null returned for type PurchaseOrderChangeRequest_sync" + type);

+        type = schema.getType(true, "StandardMessageFault");

+        assertNotNull("Null returned for type StandardMessageFault" + type);

+

+        schemas = description.getSchema("http://sap.com/xi/APPL/SE/Global");

+        assertNotNull(schemas);

+        assertEquals(1, schemas.length);

+

+        schema = schemas[0];

+        Assert.assertEquals("http://sap.com/xi/APPL/SE/Global", schema.getNamespace()); // @Test-0030

+

+        types = schema.getAllContainedTypes();

+        Assert.assertEquals(67, types.size()); // @Test-0031

+

+        referredSchemas = schema.getAllReferredSchemas();

+        assertNotNull("Empty collection must be returned when there are no referred schems", referredSchemas);

+        assertEquals(1, referredSchemas.size());

+        schema.getAllReferredSchemas();

+

+        type = schema.getType(false, "LocationInternalIDContent");

+        assertNotNull("Null returned for type LocationInternalIDContent" + type);

+        type = schema.getType(false, "ExchangeFaultData");

+        assertNotNull("Null returned for type ExchangeFaultData" + type);

+        type = schema.getType(false, "PurchaseOrderChangeConfirmationMessage_sync");

+        assertNotNull("Null returned for type PurchaseOrderChangeConfirmationMessage_sync" + type);

+        type = schema.getType(true, "StandardMessageFault");

+        assertNotNull("Null returned for element StandardMessageFault" + type);

+        type = schema.getType(false, "adsdfsfdsxyz");

+        assertNull("Null should be returned for not existing type", type);

+

+        IType[] allTypes = schema.getAllTypes("LocationInternalIDContent");

+        assertEquals(1, allTypes.length);

+        final IType faultType = schema.getType(false, "ExchangeFaultData");

+

+        RenameNamedComponent renameNamedComponent = new RenameNamedComponent(root, faultType, "LocationInternalIDContent");

+        IEnvironment env = root.getEnv();

+        env.execute(renameNamedComponent);

+

+        allTypes = schema.getAllTypes("LocationInternalIDContent");

+        assertEquals(2, allTypes.length);

+        for (IType currentType : allTypes) {

+            assertEquals("LocationInternalIDContent", currentType.getName());

+        }

+

+        String location = schema.getLocation();

+        assertNotNull("Location is null", location);

+        assertTrue("Location returned is not OK", schema.getLocation().endsWith("/data/One.wsdl"));

+

+        assertTrue(description == schema.getParent());

+        assertTrue(description == schema.getRoot());

+

+        assertEquals("Documentation", schema.getDocumentation());

+    }

+

+    @Test

+    public void test_SimpleType() throws Exception {

+        IWsdlModelRoot root = getModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV, "SimpleType.wsdl");

+        IDescription description = root.getDescription();

+

+        ISchema schema = description.getSchema("http://www.example.org/SimpleType/")[0];

+        IType type = schema.getType(false, "stringType");

+        assertTrue("Type is not instanceof ISimpleType", type instanceof ISimpleType);

+        assertTrue("Wrong type returned for stringType", "stringType".equals(type.getName()));

+        assertTrue("Wrong type returned for stringType", "http://www.example.org/SimpleType/".equals(type.getNamespace()));

+

+        ISimpleType simpleType = (ISimpleType) type;

+        assertTrue("BaseType is null", null != simpleType.getBaseType());

+        assertEquals("string", simpleType.getBaseType().getName());

+        assertTrue("Wrong parent returned", schema.equals(simpleType.getParent()));

+        assertTrue("Wrong root returned", description.equals(simpleType.getRoot()));

+        assertEquals("Documentation returned is wrong", "Documentation", simpleType.getDocumentation());

+        IFacet[] facets = simpleType.getEnumerations();

+        assertEquals(2, facets.length);

+        assertEquals("value1", facets[0].getValue());

+        assertEquals("value2", facets[1].getValue());

+        facets = simpleType.getPatterns();

+        assertEquals(2, facets.length);

+        assertEquals("value*", facets[0].getValue());

+        assertEquals("v*", facets[1].getValue());

+        assertEquals("1", simpleType.getMinLength());

+        assertEquals("10", simpleType.getMaxLength());

+        assertNull("length Facet is not null", simpleType.getLength());

+        assertNull("minInclusive Facet is not null", simpleType.getMinInclusive());

+        assertNull("minExclusive Facet is not null", simpleType.getMinExclusive());

+        assertNull("maxInclusive Facet is not null", simpleType.getMaxInclusive());

+        assertNull("maxExclusive Facet is not null", simpleType.getMaxExclusive());

+

+        simpleType = (ISimpleType) schema.getType(false, "intType");

+        assertTrue("BaseType is null", null != simpleType.getBaseType());

+        assertEquals("int", simpleType.getBaseType().getName());

+        facets = simpleType.getEnumerations();

+        assertEquals(3, facets.length);

+        assertEquals("1", facets[0].getValue());

+        assertEquals("2", facets[1].getValue());

+        assertEquals("43647489", facets[2].getValue());

+        facets = simpleType.getPatterns();

+        assertEquals(2, facets.length);

+        assertEquals("*9*", facets[0].getValue());

+        assertEquals("*8*", facets[1].getValue());

+        assertEquals("1", simpleType.getMinLength());

+        assertEquals("10", simpleType.getMaxLength());

+        assertNull("length Facet is not null", simpleType.getLength());

+        assertEquals("1", simpleType.getMinInclusive());

+        assertEquals("1098098988", simpleType.getMaxInclusive());

+        assertNull("minExclusive Facet is not null", simpleType.getMinExclusive());

+        assertNull("maxExclusive Facet is not null", simpleType.getMaxExclusive());

+

+        simpleType = (ISimpleType) schema.getType(false, "intType1");

+        assertEquals("1", simpleType.getMinExclusive());

+        assertEquals("1098098988", simpleType.getMaxExclusive());

+        assertNull("minExclusive Facet is not null", simpleType.getMinInclusive());

+        assertNull("maxExclusive Facet is not null", simpleType.getMaxInclusive());

+

+        simpleType = (ISimpleType) schema.getType(false, "stWithSimpleBaseType");

+        assertTrue("BaseType is null", null != simpleType.getBaseType());

+        assertEquals("stringType", simpleType.getBaseType().getName());

+

+        simpleType = (ISimpleType) schema.getType(false, "stListType");

+        assertEquals("anySimpleType", simpleType.getBaseType().getName());

+

+        simpleType = (ISimpleType) schema.getType(false, "stUnionType");

+        assertEquals("anySimpleType", simpleType.getBaseType().getName());

+    }

+

+    @Test

+    public void test_StructureType() throws Exception {

+        IWsdlModelRoot root = getModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV, "StructureType.wsdl");

+        IDescription description = root.getDescription();

+

+        ISchema schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        IType type = schema.getType(false, "complexType");

+        assertTrue("Type is not instanceof IStructureType", type instanceof IStructureType);

+        assertTrue("Wrong type returned for complexType", "complexType".equals(type.getName()));

+        assertTrue("Wrong type returned for complexType", "http://www.example.org/StructureType/".equals(type.getNamespace()));

+

+        IStructureType structureType = (IStructureType) type;

+        assertTrue("BaseType is null", null != structureType.getBaseType());

+        assertEquals("anyType", structureType.getBaseType().getName());

+        assertTrue("Wrong parent returned", schema.equals(structureType.getParent()));

+        assertTrue("Wrong root returned", description.equals(structureType.getRoot()));

+        assertEquals("Documentation returned is wrong", "Documentation", structureType.getDocumentation());

+        Collection<IElement> elements = structureType.getAllElements();

+        assertEquals(2, elements.size());

+        IElement[] elementsArray = elements.toArray(new IElement[2]);

+        assertEquals("elementParticle", elementsArray[0].getName());

+        assertEquals("elementParticle1", elementsArray[1].getName());

+        elements = structureType.getElements("elementParticle");

+        assertEquals(1, elements.size());

+        assertEquals("elementParticle", elements.iterator().next().getName());

+        elements = structureType.getElements("elementParticle1");

+        assertEquals(1, elements.size());

+        assertEquals("elementParticle1", elements.iterator().next().getName());

+

+        structureType = (IStructureType) schema.getType(true, "complexType");

+        assertNotNull("Could not find element 'complexType'", structureType);

+        assertNotNull("BaseType for element complexType is null", structureType.getBaseType());

+        assertEquals("anyType", structureType.getBaseType().getName());

+        elements = structureType.getAllElements();

+        assertEquals(2, elements.size());

+        elementsArray = elements.toArray(new IElement[2]);

+        assertEquals("elementParticle", elementsArray[0].getName());

+        assertEquals("elementParticle1", elementsArray[1].getName());

+        elements = structureType.getElements("elementParticle");

+        assertEquals(1, elements.size());

+        assertEquals("elementParticle", elements.iterator().next().getName());

+        elements = structureType.getElements("elementParticle1");

+        assertEquals(1, elements.size());

+        assertEquals("elementParticle1", elements.iterator().next().getName());

+

+        structureType = (IStructureType) schema.getType(true, "globalElement");

+        assertNotNull("Could not find element 'globalElement'", structureType);

+        assertNull(structureType.getBaseType());

+        elements = structureType.getAllElements();

+        assertNotNull("Empty collection must be returned when there are not elements", elements);

+        assertEquals(0, elements.size());

+        assertEquals("Documentation", structureType.getDocumentation());

+

+        structureType = (IStructureType) schema.getType(true, "globalElementWithSt");

+        assertNotNull("Could not find element 'globalElementWithSt'", structureType);

+        assertNotNull("BaseType for element complexType is null", structureType.getBaseType());

+        assertEquals("string", structureType.getBaseType().getName());

+        elements = structureType.getAllElements();

+        assertNotNull("Empty collection must be returned when there are not elements", elements);

+        assertEquals(0, elements.size());

+

+        structureType = (IStructureType) schema.getType(false, "ctWithAttributes");

+        assertNotNull("Could not find element 'ctWithAttributes'", structureType);

+        assertNotNull("BaseType for complexType ctWithAttributes is null", structureType.getBaseType());

+        assertEquals("anyType", structureType.getBaseType().getName());

+        elements = structureType.getAllElements();

+        assertEquals(3, elements.size());

+        elementsArray = elements.toArray(new IElement[3]);

+        assertEquals("globalElement", elementsArray[0].getName());

+        assertEquals("elementParticle3", elementsArray[1].getName());

+        assertEquals("attribute1", elementsArray[2].getName());

+

+        structureType = (IStructureType) schema.getType(false, "ctExtension");

+        assertNotNull("Could not find element 'ctExtension'", structureType);

+        assertNotNull("BaseType for complexType ctExtension is null", structureType.getBaseType());

+        assertEquals("complexType", structureType.getBaseType().getName());

+        elements = structureType.getAllElements();

+        structureType.getAllElements();

+        assertEquals(4, elements.size());

+        elementsArray = elements.toArray(new IElement[4]);

+        assertEquals("globalElement", elementsArray[0].getName());

+        assertEquals("elementParticle3", elementsArray[1].getName());

+        assertEquals("elementParticle4", elementsArray[2].getName());

+        assertEquals("attribute1", elementsArray[3].getName());

+        structureType = (IStructureType) schema.getType(true, "elementCtExtension");

+        assertNotNull("Could not find element 'elementCtExtension'", structureType);

+        assertNotNull("BaseType for element elementCtExtension is null", structureType.getBaseType());

+        assertEquals("complexType", structureType.getBaseType().getName());

+        elements = structureType.getAllElements();

+        assertEquals(4, elements.size());

+        elementsArray = elements.toArray(new IElement[4]);

+        assertEquals("globalElement", elementsArray[0].getName());

+        assertEquals("elementParticle3", elementsArray[1].getName());

+        assertEquals("attribute1", elementsArray[2].getName());

+        assertEquals("attribute2", elementsArray[3].getName());

+

+        structureType = (IStructureType) schema.getType(false, "ctRestriction");

+        assertNotNull("Could not find type 'ctRestriction'", structureType);

+        assertNotNull("BaseType for type ctRestriction is null", structureType.getBaseType());

+        assertEquals("complexType", structureType.getBaseType().getName());

+        elements = structureType.getAllElements();

+        assertEquals(2, elements.size());

+        elementsArray = elements.toArray(new IElement[2]);

+        assertEquals("elementParticle", elementsArray[0].getName());

+        assertEquals("elementParticle1", elementsArray[1].getName());

+

+        structureType = (IStructureType) schema.getType(false, "ctSimpleContentExtension");

+        assertNotNull("Could not find type 'ctSimpleContentExtension'", structureType);

+        assertNotNull("BaseType for type ctSimpleContentExtension is null", structureType.getBaseType());

+        assertEquals("string", structureType.getBaseType().getName());

+        elements = structureType.getAllElements();

+        assertEquals(3, elements.size());

+        elementsArray = elements.toArray(new IElement[3]);

+        assertEquals("attribute1", elementsArray[0].getName());

+        assertEquals("attribute2", elementsArray[1].getName());

+        assertEquals("globalAttribute", elementsArray[2].getName());

+

+        structureType = (IStructureType) schema.getType(false, "ctSimpleContentRestriction");

+        assertNotNull("Could not find type 'ctSimpleContentRestriction'", structureType);

+        assertNotNull("BaseType for type ctSimpleContentRestriction is null", structureType.getBaseType());

+        assertEquals("ctSimpleContentExtension", structureType.getBaseType().getName());

+        elements = structureType.getAllElements();

+        assertEquals(2, elements.size());

+        elementsArray = elements.toArray(new IElement[2]);

+        assertEquals("attribute1", elementsArray[0].getName());

+        assertEquals("attribute2", elementsArray[1].getName());

+

+        structureType = (IStructureType) schema.getType(false, "nestedElements");

+        assertNotNull("Could not find type 'nestedElements'", structureType);

+        elements = structureType.getAllElements();

+        assertEquals(8, elements.size());

+        elementsArray = elements.toArray(new IElement[8]);

+        assertEquals("globalElement", elementsArray[0].getName());

+        assertEquals("elementParticle", elementsArray[1].getName());

+        assertEquals("elementParticle1", elementsArray[2].getName());

+        assertEquals("elementParticle2", elementsArray[3].getName());

+        assertEquals("elementParticle3", elementsArray[4].getName());

+        assertEquals("elementParticle4", elementsArray[5].getName());

+        assertEquals("attribute1", elementsArray[6].getName());

+        assertEquals("attribute2", elementsArray[7].getName());

+

+        structureType = (IStructureType) schema.getType(false, "allModelGroupType");

+        assertNotNull("Could not find type 'allModelGroupType'", structureType);

+        elements = structureType.getAllElements();

+        assertEquals(6, elements.size());

+        elementsArray = elements.toArray(new IElement[6]);

+        assertEquals("globalElement", elementsArray[0].getName());

+        assertEquals("elementParticle", elementsArray[1].getName());

+        assertEquals("elementParticle1", elementsArray[2].getName());

+        assertEquals("elementParticle2", elementsArray[3].getName());

+        assertEquals("elementParticle3", elementsArray[4].getName());

+        assertEquals("elementParticle4", elementsArray[5].getName());

+

+        structureType = (IStructureType) schema.getType(true, "elementWithGlobalType");

+        assertNotNull("Could not find type 'elementWithGlobalType'", structureType);

+        elements = structureType.getAllElements();

+        assertEquals(0, elements.size());

+    }

+

+    @Test

+    public void test_Element() throws Exception {

+        IWsdlModelRoot root = getModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV, "StructureType.wsdl");

+        IDescription description = root.getDescription();

+

+        ISchema schema = description.getSchema("http://www.example.org/StructureType/")[0];

+

+        IStructureType structureType = (IStructureType) schema.getType(false, "complexType");

+        Collection<IElement> elements = structureType.getAllElements();

+        IElement[] elementsArray = elements.toArray(new IElement[2]);

+        IElement element = elementsArray[0];

+        assertEquals("elementParticle", element.getName());

+        assertEquals("Documentation", element.getDocumentation());

+        assertEquals(1, element.getMinOccurs());

+        assertEquals(1, element.getMaxOccurs());

+        assertFalse(element.getNillable());

+        assertEquals(structureType, element.getParent());

+        assertEquals(description, element.getRoot());

+        element = elementsArray[1];

+        assertEquals("elementParticle1", element.getName());

+        assertEquals("", element.getDocumentation());

+        assertEquals(2, element.getMinOccurs());

+        assertEquals(5, element.getMaxOccurs());

+        assertTrue(element.getNillable());

+

+        structureType = (IStructureType) schema.getType(false, "ctWithAttributes");

+        elements = structureType.getElements("globalElement");

+        assertEquals(1, elements.size());

+        element = elements.iterator().next();

+        assertEquals(10, element.getMinOccurs());

+        assertEquals(100, element.getMaxOccurs());

+        assertFalse(element.getNillable());

+        elements = structureType.getElements("elementParticle3");

+        assertEquals(1, elements.size());

+        element = elements.iterator().next();

+        assertEquals(1, element.getMinOccurs());

+        assertEquals(1, element.getMaxOccurs());

+        elements = structureType.getElements("attribute1");

+        assertEquals(1, elements.size());

+        element = elements.iterator().next();

+        assertEquals(0, element.getMinOccurs());

+        assertEquals(1, element.getMaxOccurs());

+        assertFalse(element.getNillable());

+

+        structureType = (IStructureType) schema.getType(true, "elementCtExtension");

+        elements = structureType.getElements("attribute2");

+        assertEquals(1, elements.size());

+        element = elements.iterator().next();

+        IType type = element.getType();

+        assertNotNull("Type for element attribute2 is null", type);

+        assertTrue("type returned is not a simpleType", type instanceof ISimpleType);

+        assertNull("Type is not anonymous", type.getName());

+        ISimpleType simpleType = (ISimpleType) type;

+        assertTrue("Type is not anonymous", null == simpleType.getName());

+        structureType = (IStructureType) schema.getType(false, "ctRestriction");

+        elements = structureType.getElements("elementParticle");

+        assertEquals(1, elements.size());

+        element = elements.iterator().next();

+        type = element.getType();

+        element.getType();

+        assertNotNull("Type for element elementParticle is null", type);

+        assertTrue("type returned is not a simpleType", type instanceof ISimpleType);

+        assertNull("Type is not anonymous", type.getName());

+        simpleType = (ISimpleType) type;

+        assertTrue("Type is not anonymous", null == simpleType.getName());

+        structureType = (IStructureType) schema.getType(false, "ctExtension");

+        elements = structureType.getElements("elementParticle4");

+        assertEquals(1, elements.size());

+        element = elements.iterator().next();

+        type = element.getType();

+        assertNotNull("Type for element elementParticle is null", type);

+        assertTrue("type returned is not a simpleType", type instanceof ISimpleType);

+        assertEquals("simpleType", type.getName());

+

+        structureType = (IStructureType) schema.getType(true, "globalElementWithElements");

+        elements = structureType.getElements("elementParticle");

+        assertEquals(1, elements.size());

+        element = elements.iterator().next();

+        structureType = (IStructureType) element.getType();

+        assertNull("Type is not anonymous", structureType.getName());

+        assertTrue("Elements do not match", 11 == structureType.getAllElements().size());

+        elements = structureType.getElements("anyContentElement");

+        element = elements.iterator().next();

+        type = element.getType();

+        assertEquals("anyType", type.getName());

+        elements = structureType.getElements("globalAttribute");

+        element = elements.iterator().next();

+        assertNull("Type must be null for referenced AttributeDeclaration", element.getType());

+        elements = structureType.getElements("attribute4");

+        element = elements.iterator().next();

+        assertEquals("simpleType", element.getType().getName());

+        assertEquals("Documentation", element.getDocumentation());

+        elements = structureType.getElements("globalElement");

+        element = elements.iterator().next();

+        assertNotNull("Type must be not null for referenced ElementDeclaration", element.getType());

+        assertEquals("globalElement", element.getType().getName());

+    }

+

+    private IWsdlModelRoot getModelRoot(final String folder, final String fileName) throws Exception {

+        return getWSDLModelRoot(folder + fileName, fileName);

+    }

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDReferencedDocumentsTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDReferencedDocumentsTest.java
new file mode 100644
index 0000000..b930d12
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDReferencedDocumentsTest.java
@@ -0,0 +1,433 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.ArrayList;

+import java.util.Collection;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IElement;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType;

+

+@SuppressWarnings("nls")

+public class XSDReferencedDocumentsTest extends SIEditorBaseTest {

+

+    protected String getProjectName() {

+        return "XSDReferencedDocumentsTest";

+    }

+

+    @Test

+    public void testExternalImportedDocuments() throws Exception {

+        /*

+         * Check cases for below Schema - Referred schemas SimpleType - baseType

+         * - both for global and anonymous types in element and attribute

+         * ComplextType - baseType - restriction, extension , Simple Content

+         * Element - ref, type Attribute - ref, type

+         */

+

+        IFile file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "po.xsd", Document_FOLDER_NAME,

+                this.getProject(), "po.xsd");

+        assertTrue(null != file && file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "example.xsd", Document_FOLDER_NAME,

+                this.getProject(), "example.xsd");

+        assertTrue(null != file && file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Included.xsd", Document_FOLDER_NAME,

+                this.getProject(), "Included.xsd");

+        assertTrue(null != file && file.exists());

+

+        // check for referenced documents

+        final IWsdlModelRoot modelRoot = getModelRoot("TypesExternalImporting.wsdl");

+        final IDescription description = modelRoot.getDescription();

+        assertNotNull(description);

+

+        ISchema schema = description.getSchema("http://www.example.org/TypesImporting/")[0];

+        if (schema.getAllReferredSchemas().size() != 4) {

+            schema = description.getSchema("http://www.example.org/TypesImporting/")[1];

+        }

+        final Collection<ISchema> referredSchemas = schema.getAllReferredSchemas();

+        assertEquals(4, referredSchemas.size());

+        final ISchema[] schemas = referredSchemas.toArray(new ISchema[4]);

+        ArrayList<String> importedNamespaces = new ArrayList<String>();

+        importedNamespaces.add("http://www.example.com/");

+        importedNamespaces.add("http://www.example.com/IPO");

+        importedNamespaces.add("http://www.example.org/TypesImporting/");

+        importedNamespaces.add("http://www.w3.org/2001/XMLSchema");

+        for (ISchema refSchema : schemas) {

+            assertNotNull(importedNamespaces.remove(refSchema.getNamespace()));

+        }

+        assertTrue("Not all referred documents are returned (" + importedNamespaces + ")", 0 == importedNamespaces.size());

+

+        ISimpleType simpleType = (ISimpleType) schema.getType(false, "simpleType");

+        assertTrue("BaseType is null", null != simpleType.getBaseType());

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.com/IPO", simpleType.getBaseType().getNamespace());

+

+        IStructureType structureType = (IStructureType) schema.getType(false, "complexType");

+        Collection<IElement> elements = structureType.getElements("elementParticle");

+        IElement element = elements.iterator().next();

+        structureType = (IStructureType) element.getType();

+        assertEquals("Address", structureType.getName());

+        assertEquals("http://www.example.com/", structureType.getNamespace());

+        structureType = (IStructureType) schema.getType(true, "complexType");

+        elements = structureType.getElements("elementParticle");

+        element = elements.iterator().next();

+        assertEquals("Address", element.getType().getName());

+        assertEquals("http://www.example.com/", element.getType().getNamespace());

+        elements = structureType.getElements("comment");

+        element = elements.iterator().next();

+        structureType = (IStructureType) element.getType();

+        assertNotNull("Type must not be null for referenced Element Declaration", structureType);

+        assertEquals("comment", structureType.getName());

+

+        structureType = (IStructureType) schema.getType(false, "ctExtension");

+        assertTrue("BaseType is null", null != structureType.getBaseType());

+        assertEquals("Items", structureType.getBaseType().getName());

+        assertEquals("http://www.example.com/", structureType.getBaseType().getNamespace());

+        elements = structureType.getElements("comment");

+        element = elements.iterator().next();

+        structureType = (IStructureType) element.getType();

+

+        structureType = (IStructureType) schema.getType(false, "ctRestriction");

+        elements = structureType.getElements("elementParticle");

+        element = elements.iterator().next();

+        simpleType = (ISimpleType) element.getType();

+        assertTrue("BaseType is null", null != simpleType.getBaseType());

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.com/IPO", simpleType.getBaseType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "ctSimpleContentExtension");

+        simpleType = (ISimpleType) structureType.getBaseType();

+        assertTrue("BaseType is null", null != simpleType);

+        assertEquals("SKU", simpleType.getName());

+        assertEquals("http://www.example.com/", simpleType.getNamespace());

+        elements = structureType.getElements("globalAttribute");

+        element = elements.iterator().next();

+        assertEquals("globalAttribute", element.getName());

+        elements = structureType.getElements("attribute1");

+        element = elements.iterator().next();

+        assertEquals("SKU", element.getType().getName());

+        assertEquals("http://www.example.com/", element.getType().getNamespace());

+        elements = structureType.getElements("attribute2");

+        element = elements.iterator().next();

+        assertEquals("SKU", element.getType().getName());

+        assertEquals("http://www.example.com/IPO", element.getType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "ctSimpleContentRestriction");

+        elements = structureType.getElements("attribute1");

+        element = elements.iterator().next();

+        assertEquals("attribute1", element.getName());

+        simpleType = (ISimpleType) element.getType().getBaseType();

+        assertTrue("BaseType is null", null != simpleType);

+        assertEquals("SKU", simpleType.getName());

+        assertEquals("http://www.example.com/", simpleType.getNamespace());

+

+        structureType = (IStructureType) schema.getType(true, "globalElementWithElements");

+        elements = structureType.getElements("elementParticle");

+        element = elements.iterator().next();

+        structureType = (IStructureType) element.getType();

+        elements = structureType.getElements("globalAttributeDeclaration");

+        element = elements.iterator().next();

+        assertEquals("globalAttributeDeclaration", element.getName());

+        assertNull("Type for referred attribute must be null", element.getType());

+

+        structureType = (IStructureType) schema.getType(false, "ctImportedExtension");

+        structureType = (IStructureType) structureType.getBaseType();

+        assertTrue("BaseType is null", null != structureType);

+        assertEquals("Address", structureType.getName());

+        assertEquals("http://www.example.com/", structureType.getNamespace());

+        structureType = (IStructureType) schema.getType(false, "ctImportedRestriction");

+        structureType = (IStructureType) structureType.getBaseType();

+        assertTrue("BaseType is null", null != structureType);

+        assertEquals("Address", structureType.getName());

+        assertEquals("http://www.example.com/IPO", structureType.getNamespace());

+    }

+

+    @Test

+    public void testInternalImportedDocuments() throws Exception {

+        /*

+         * Check cases for below Schema - Referred schemas SimpleType - baseType

+         * - both for global and anonymous types in element and attribute

+         * ComplextType - baseType - restriction, extension , Simple Content

+         * Element - ref, type Attribute - ref, type

+         */

+

+        // check for referenced documents

+        final IWsdlModelRoot modelRoot = getModelRoot("TypesInternalImporting.wsdl");

+        final IDescription description = modelRoot.getDescription();

+        assertNotNull(description);

+

+        final ISchema[] refSchemas = description.getSchema("http://www.example.org/TypesImporting/");

+        assertEquals(2, refSchemas.length);

+        ISchema schema = refSchemas[0].getAllReferredSchemas().size() == 4 ? refSchemas[0] : refSchemas[1];

+        final Collection<ISchema> referredSchemas = schema.getAllReferredSchemas();

+        assertEquals(4, referredSchemas.size());

+        final ISchema[] schemas = referredSchemas.toArray(new ISchema[4]);

+        ArrayList<String> importedNamespaces = new ArrayList<String>();

+        importedNamespaces.add("http://www.example.com/");

+        importedNamespaces.add("http://www.example.com/IPO");

+        importedNamespaces.add("http://www.example.org/TypesImporting/");

+        importedNamespaces.add("http://www.w3.org/2001/XMLSchema");

+        for (ISchema refSchema : schemas) {

+            assertTrue(importedNamespaces.remove(refSchema.getNamespace()));

+        }

+        assertTrue("Not all referred documents are returned (" + importedNamespaces + ")", 0 == importedNamespaces.size());

+

+        ISimpleType simpleType = (ISimpleType) schema.getType(false, "simpleType");

+        assertTrue("BaseType is null", null != simpleType.getBaseType());

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.com/IPO", simpleType.getBaseType().getNamespace());

+

+        IStructureType structureType = (IStructureType) schema.getType(false, "complexType");

+        Collection<IElement> elements = structureType.getElements("elementParticle");

+        IElement element = elements.iterator().next();

+        structureType = (IStructureType) element.getType();

+        assertEquals("Address", structureType.getName());

+        assertEquals("http://www.example.com/", structureType.getNamespace());

+        structureType = (IStructureType) schema.getType(true, "complexType");

+        elements = structureType.getElements("elementParticle");

+        element = elements.iterator().next();

+        assertEquals("Address", element.getType().getName());

+        assertEquals("http://www.example.com/", element.getType().getNamespace());

+        elements = structureType.getElements("comment");

+        element = elements.iterator().next();

+        structureType = (IStructureType) element.getType();

+        assertNotNull("Type must not be null for referenced Element Declaration", structureType);

+        assertEquals("comment", structureType.getName());

+

+        structureType = (IStructureType) schema.getType(false, "ctExtension");

+        assertTrue("BaseType is null", null != structureType.getBaseType());

+        assertEquals("Items", structureType.getBaseType().getName());

+        assertEquals("http://www.example.com/", structureType.getBaseType().getNamespace());

+        elements = structureType.getElements("comment");

+        element = elements.iterator().next();

+        structureType = (IStructureType) element.getType();

+

+        structureType = (IStructureType) schema.getType(false, "ctRestriction");

+        elements = structureType.getElements("elementParticle");

+        element = elements.iterator().next();

+        simpleType = (ISimpleType) element.getType();

+        assertTrue("BaseType is null", null != simpleType.getBaseType());

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.com/IPO", simpleType.getBaseType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "ctSimpleContentExtension");

+        simpleType = (ISimpleType) structureType.getBaseType();

+        assertTrue("BaseType is null", null != simpleType);

+        assertEquals("SKU", simpleType.getName());

+        assertEquals("http://www.example.com/", simpleType.getNamespace());

+        elements = structureType.getElements("globalAttribute");

+        element = elements.iterator().next();

+        assertEquals("globalAttribute", element.getName());

+        elements = structureType.getElements("attribute1");

+        element = elements.iterator().next();

+        assertEquals("SKU", element.getType().getName());

+        assertEquals("http://www.example.com/", element.getType().getNamespace());

+        elements = structureType.getElements("attribute2");

+        element = elements.iterator().next();

+        assertEquals("SKU", element.getType().getName());

+        assertEquals("http://www.example.com/IPO", element.getType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "ctSimpleContentRestriction");

+        elements = structureType.getElements("attribute1");

+        element = elements.iterator().next();

+        assertEquals("attribute1", element.getName());

+        simpleType = (ISimpleType) element.getType().getBaseType();

+        assertTrue("BaseType is null", null != simpleType);

+        assertEquals("SKU", simpleType.getName());

+        assertEquals("http://www.example.com/", simpleType.getNamespace());

+

+        structureType = (IStructureType) schema.getType(true, "globalElementWithElements");

+        elements = structureType.getElements("elementParticle");

+        element = elements.iterator().next();

+        structureType = (IStructureType) element.getType();

+        elements = structureType.getElements("globalAttributeDeclaration");

+        element = elements.iterator().next();

+        assertEquals("globalAttributeDeclaration", element.getName());

+        assertNull("Type for referred attribute must be null", element.getType());

+

+        structureType = (IStructureType) schema.getType(false, "ctImportedExtension");

+        structureType = (IStructureType) structureType.getBaseType();

+        assertTrue("BaseType is null", null != structureType);

+        assertEquals("Address", structureType.getName());

+        assertEquals("http://www.example.com/", structureType.getNamespace());

+        structureType = (IStructureType) schema.getType(false, "ctImportedRestriction");

+        structureType = (IStructureType) structureType.getBaseType();

+        assertTrue("BaseType is null", null != structureType);

+        assertEquals("Address", structureType.getName());

+        assertEquals("http://www.example.com/IPO", structureType.getNamespace());

+    }

+

+    @Test

+    public void testExternalIncludedDocuments() throws Exception {

+        /*

+         * Check cases for below Schema - Referred schemas SimpleType - baseType

+         * - both for global and anonymous types in element and attribute

+         * ComplextType - baseType - restriction, extension , Simple Content

+         * Element - ref, type Attribute - ref, type

+         */

+

+        // check for referenced documents

+        final IWsdlModelRoot modelRoot = getModelRoot("TypesExternalIncluding.wsdl");

+        final IDescription description = modelRoot.getDescription();

+        assertNotNull(description);

+

+        final ISchema[] refSchemas = description.getSchema("http://www.example.org/TypesImporting/");

+        assertEquals(2, refSchemas.length);

+        ISchema schema = refSchemas[0];

+        if (schema.getType(false, "simpleType") == null) {

+            schema = refSchemas[1];

+        }

+

+        final Collection<ISchema> referredSchemas = schema.getAllReferredSchemas();

+        assertEquals(2, referredSchemas.size());

+        final ISchema[] schemas = referredSchemas.toArray(new ISchema[2]);

+        ArrayList<String> importedNamespaces = new ArrayList<String>();

+        importedNamespaces.add("http://www.example.org/TypesImporting/");

+        importedNamespaces.add("http://www.w3.org/2001/XMLSchema");

+        for (ISchema refSchema : schemas) {

+            assertTrue(importedNamespaces.remove(refSchema.getNamespace()));

+        }

+        assertTrue("Not all referred documents are returned (" + importedNamespaces + ")", 0 == importedNamespaces.size());

+

+        ISimpleType simpleType = (ISimpleType) schema.getType(false, "simpleType");

+        assertTrue("BaseType is null", null != simpleType.getBaseType());

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getBaseType().getNamespace());

+

+        IStructureType structureType = (IStructureType) schema.getType(true, "globalElementWithSt");

+        assertTrue("BaseType is null", null != structureType.getBaseType());

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getBaseType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "complexType");

+        Collection<IElement> elements = structureType.getElements("attribute1");

+        IElement element = elements.iterator().next();

+        simpleType = (ISimpleType) element.getType();

+        assertEquals("SKU", simpleType.getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getNamespace());

+        elements = structureType.getElements("elementParticle1");

+        element = elements.iterator().next();

+        simpleType = (ISimpleType) element.getType();

+        assertEquals("SKU", simpleType.getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getNamespace());

+        elements = structureType.getElements("comment");

+        element = elements.iterator().next();

+        assertEquals("comment", element.getName());

+        elements = structureType.getElements("attribute2");

+        element = elements.iterator().next();

+        simpleType = (ISimpleType) element.getType();

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getBaseType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "ctImportedExtension");

+        assertEquals("Address", structureType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", structureType.getBaseType().getNamespace());

+        structureType = (IStructureType) schema.getType(false, "ctImportedRestriction");

+        assertEquals("Address", structureType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", structureType.getBaseType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "ctSimpleContentExtension");

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getBaseType().getNamespace());

+        elements = structureType.getElements("globalAttributeDeclaration");

+        element = elements.iterator().next();

+        assertEquals("globalAttributeDeclaration", element.getName());

+    }

+

+    @Test

+    public void testInternalIncludedDocuments() throws Exception {

+        /*

+         * Check cases for below Schema - Referred schemas SimpleType - baseType

+         * - both for global and anonymous types in element and attribute

+         * ComplextType - baseType - restriction, extension , Simple Content

+         * Element - ref, type Attribute - ref, type

+         */

+

+        // check for referenced documents

+        final IWsdlModelRoot modelRoot = getModelRoot("TypesInternalIncluding.wsdl");

+        final IDescription description = modelRoot.getDescription();

+        assertNotNull(description);

+

+        final ISchema[] refSchemas = description.getSchema("http://www.example.org/TypesImporting/");

+        assertEquals(2, refSchemas.length);

+        ISchema schema = refSchemas[0].getType(false, "simpleType") == null ? refSchemas[1] : refSchemas[0];

+        final Collection<ISchema> referredSchemas = schema.getAllReferredSchemas();

+        assertEquals(2, referredSchemas.size());

+        final ISchema[] schemas = referredSchemas.toArray(new ISchema[2]);

+        ArrayList<String> importedNamespaces = new ArrayList<String>();

+        importedNamespaces.add("http://www.example.org/TypesImporting/");

+        importedNamespaces.add("http://www.w3.org/2001/XMLSchema");

+        for (ISchema refSchema : schemas) {

+            assertTrue(importedNamespaces.remove(refSchema.getNamespace()));

+        }

+        assertTrue("Not all referred documents are returned (" + importedNamespaces + ")", 0 == importedNamespaces.size());

+

+        ISimpleType simpleType = (ISimpleType) schema.getType(false, "simpleType");

+        assertTrue("BaseType is null", null != simpleType.getBaseType());

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getBaseType().getNamespace());

+

+        IStructureType structureType = (IStructureType) schema.getType(true, "globalElementWithSt");

+        assertTrue("BaseType is null", null != structureType.getBaseType());

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getBaseType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "complexType");

+        Collection<IElement> elements = structureType.getElements("attribute1");

+        IElement element = elements.iterator().next();

+        simpleType = (ISimpleType) element.getType();

+        assertEquals("SKU", simpleType.getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getNamespace());

+        elements = structureType.getElements("elementParticle1");

+        element = elements.iterator().next();

+        simpleType = (ISimpleType) element.getType();

+        assertEquals("SKU", simpleType.getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getNamespace());

+        elements = structureType.getElements("comment");

+        element = elements.iterator().next();

+        assertEquals("comment", element.getName());

+        elements = structureType.getElements("attribute2");

+        element = elements.iterator().next();

+        simpleType = (ISimpleType) element.getType();

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getBaseType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "ctImportedExtension");

+        assertEquals("Address", structureType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", structureType.getBaseType().getNamespace());

+        structureType = (IStructureType) schema.getType(false, "ctImportedRestriction");

+        assertEquals("Address", structureType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", structureType.getBaseType().getNamespace());

+

+        structureType = (IStructureType) schema.getType(false, "ctSimpleContentExtension");

+        assertEquals("SKU", simpleType.getBaseType().getName());

+        assertEquals("http://www.example.org/TypesImporting/", simpleType.getBaseType().getNamespace());

+        elements = structureType.getElements("globalAttributeDeclaration");

+        element = elements.iterator().next();

+        assertEquals("globalAttributeDeclaration", element.getName());

+    }

+

+    private IWsdlModelRoot getModelRoot(final String fileName) throws Exception {

+        return getWSDLModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV + fileName, fileName);

+    }

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDWriteTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDWriteTest.java
new file mode 100644
index 0000000..3f54940
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/XSDWriteTest.java
@@ -0,0 +1,1451 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model;

+

+import java.util.Collection;

+

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.runtime.IPath;

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.core.runtime.Path;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.ui.part.FileEditorInput;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.eclipse.xsd.XSDComplexTypeDefinition;

+import org.eclipse.xsd.XSDDerivationMethod;

+import org.eclipse.xsd.XSDElementDeclaration;

+import org.eclipse.xsd.XSDParticle;

+import org.eclipse.xsd.XSDSimpleTypeDefinition;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.AddElementCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.AddFacetCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.AddSimpleTypeCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.AddStructureTypeCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.CopyElementCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.CreateGlobalTypeFromAnonymousCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.DeleteElementCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.DeleteFacetCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.FacetsCommandFactory;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.RemoveTypeCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.RenameElementCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.RenameNamedComponent;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetAnonymousCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetBaseTypeCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetDocumentationCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetElementNillableCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetElementOccurences;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetElementTypeCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.xsd.SetNamespaceCommand;

+import org.eclipse.wst.sse.sieditor.mm.ModelManager;

+import org.eclipse.wst.sse.sieditor.model.api.IModelObject;

+import org.eclipse.wst.sse.sieditor.model.api.IModelRoot;

+import org.eclipse.wst.sse.sieditor.model.api.INamedObject;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+import org.eclipse.wst.sse.sieditor.model.generic.IllegalInputException;

+import org.eclipse.wst.sse.sieditor.model.utils.EmfXsdUtils;

+import org.eclipse.wst.sse.sieditor.model.wsdl.impl.Description;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IElement;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IFacet;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IType;

+import org.eclipse.wst.sse.sieditor.model.xsd.impl.AbstractType;

+import org.eclipse.wst.sse.sieditor.model.xsd.impl.AbstractXSDComponent;

+

+@SuppressWarnings("nls")

+public class XSDWriteTest extends SIEditorBaseTest {

+

+    private static final String SOURCE_FOLDER = "src/wsdl";

+

+    @Override

+    protected String getProjectName() {

+        return "XSDWriteTest";

+    }

+

+    @Test

+    public void testSchema() throws Exception {

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "TestWriteSchema1.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        description = modelRoot.getDescription();

+

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://sap.com/xi/Purchasing")[0];

+        assertEquals("http://sap.com/xi/Purchasing", schema.getNamespace());

+        setNamespace(modelRoot, schema, "http://sap.com/xi/Purchasing/New");

+        assertEquals("http://sap.com/xi/Purchasing/New", schema.getNamespace());

+        assertEquals("", schema.getDocumentation());

+        setDocumentation(modelRoot, schema, "Documentation");

+        assertEquals("Documentation", schema.getDocumentation());

+        setDocumentation(modelRoot, schema, "NewDocumentation");

+        assertEquals("NewDocumentation", schema.getDocumentation());

+

+        // test creation of global type from anonymous

+        final org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType address = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema

+                .getType(false, "Address");

+        final IElement officeElement = address.getElements("Office").iterator().next();

+        createGlobalTypeFromAnonymous(modelRoot, schema, officeElement, "Office");

+        assertNotNull(schema.getType(false, "Office"));

+

+        ((Description) description).save();

+

+        modelRoot = getWSDLModelRoot("TestWriteSchema1.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://sap.com/xi/Purchasing/New")[0];

+        assertEquals("NewDocumentation", schema.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("PurchaseOrderConfirmation.wsdl", "TestWriteSchema2.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://sap.com/xi/Purchasing")[0];

+        final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType simpleType = addSimpleType(((AbstractXSDComponent) schema)

+                .getModelRoot(), schema, "NewSimpleType");

+        assertNotNull("Could not find Newly added type NewSimpleType", schema.getType(false, "NewSimpleType"));

+        assertEquals("string", simpleType.getBaseType().getName());

+        addStructureType(((AbstractXSDComponent) schema).getModelRoot(), schema, "NewStructureType", false, null);

+        assertNotNull("Could not find Newly added type NewStructureType", schema.getType(false, "NewStructureType"));

+        assertNotNull("Could not find element PurchaseOrderConfirmationRequest", schema.getType(true,

+                "PurchaseOrderConfirmationRequest"));

+        removeType(modelRoot, schema, schema.getType(true, "PurchaseOrderConfirmationRequest"));

+        assertNull("Element PurchaseOrderConfirmationRequest is not deleted", schema.getType(true,

+                "PurchaseOrderConfirmationRequest"));

+        assertNotNull("Could not find SimpleType ActionCode", schema.getType(false, "ActionCode"));

+        removeType(modelRoot, schema, schema.getType(false, "ActionCode"));

+        assertNull("SimpleType ActionCode is not deleted", schema.getType(false, "ActionCode"));

+        assertNotNull("Could not find StructureType Attachment", schema.getType(false, "Attachment"));

+        removeType(modelRoot, schema, schema.getType(false, "Attachment"));

+        assertNull("StructureType Attachment is not deleted", schema.getType(false, "Attachment"));

+        ((Description) description).save();

+

+        modelRoot = getWSDLModelRoot("TestWriteSchema2.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://sap.com/xi/Purchasing")[0];

+        assertNotNull("Could not find Newly added type NewSimpleType", schema.getType(false, "NewSimpleType"));

+        assertNotNull("Could not find Newly added type NewStructureType", schema.getType(false, "NewStructureType"));

+        assertNull("Element PurchaseOrderConfirmationRequest is not deleted", schema.getType(true,

+                "PurchaseOrderConfirmationRequest"));

+        assertNull("SimpleType ActionCode is not deleted", schema.getType(false, "ActionCode"));

+        assertNull("StructureType Attachment is not deleted", schema.getType(false, "Attachment"));

+    }

+

+    @Test

+    public void testSimpleType() throws Exception {

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("SimpleType.wsdl", "TestSimpleType.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType simpleType;

+        description = modelRoot.getDescription();

+

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/SimpleType/")[0];

+        assertNotNull("Could not find schema http://www.example.org/SimpleType/", schema);

+

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "stringType");

+        assertEquals("stringType", simpleType.getName());

+        renameSimpleType(modelRoot, simpleType, "NewType");

+        assertEquals("NewType", simpleType.getName());

+        assertNotNull("Could not find SimpleType NewType", schema.getType(false, "NewType"));

+        assertEquals("Documentation", simpleType.getDocumentation());

+        setDocumentation(modelRoot, simpleType, "Documentation");

+        assertEquals("Documentation", simpleType.getDocumentation());

+        setDocumentation(modelRoot, simpleType, "NewDocumentation");

+        assertEquals("NewDocumentation", simpleType.getDocumentation());

+        ((Description) description).save();

+

+        modelRoot = getWSDLModelRoot("TestSimpleType.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/SimpleType/")[0];

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "NewType");

+        assertEquals("NewType", simpleType.getName());

+        assertEquals("NewDocumentation", simpleType.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("SimpleType.wsdl", "TestSimpleType.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/SimpleType/")[0];

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "stringType");

+        assertEquals("1", simpleType.getMinLength());

+        setMinLength(modelRoot, simpleType, "2");

+        assertEquals("2", simpleType.getMinLength());

+        assertEquals("10", simpleType.getMaxLength());

+        setMaxLength(modelRoot, simpleType, "11");

+        assertEquals("11", simpleType.getMaxLength());

+        assertEquals(2, simpleType.getEnumerations().length);

+        assertEquals("value1", simpleType.getEnumerations()[0].getValue());

+        assertEquals("value2", simpleType.getEnumerations()[1].getValue());

+        addEnumeration(modelRoot, simpleType, "value4");

+        assertEquals(3, simpleType.getEnumerations().length);

+        assertEquals("value4", simpleType.getEnumerations()[2].getValue());

+        deleteEnumeration(modelRoot, simpleType, simpleType.getEnumerations()[0]);

+        assertEquals(2, simpleType.getEnumerations().length);

+        assertEquals(2, simpleType.getPatterns().length);

+        assertEquals("value*", simpleType.getPatterns()[0].getValue());

+        assertEquals("v*", simpleType.getPatterns()[1].getValue());

+        addPattern(modelRoot, simpleType, "va*");

+        assertEquals(3, simpleType.getPatterns().length);

+        assertEquals("va*", simpleType.getPatterns()[2].getValue());

+        deletePattern(modelRoot, simpleType, simpleType.getPatterns()[0]);

+        assertEquals(2, simpleType.getPatterns().length);

+

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "intType");

+        assertEquals("1", simpleType.getMinLength());

+        assertEquals("10", simpleType.getMaxLength());

+        setMaxLength(modelRoot, simpleType, "11");

+        assertEquals("11", simpleType.getMaxLength());

+        assertEquals("1", simpleType.getMinInclusive());

+        setMinInclusive(modelRoot, simpleType, "4");

+        assertEquals("4", simpleType.getMinInclusive());

+        assertEquals("1098098988", simpleType.getMaxInclusive());

+        setMaxInclusive(modelRoot, simpleType, "1098098989");

+        assertEquals("1098098989", simpleType.getMaxInclusive());

+        assertEquals("", simpleType.getDocumentation());

+        setDocumentation(modelRoot, simpleType, "Documentation");

+        assertEquals("Documentation", simpleType.getDocumentation());

+        setDocumentation(modelRoot, simpleType, "NewDocumentation");

+        assertEquals("NewDocumentation", simpleType.getDocumentation());

+

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "intType1");

+        assertEquals("1", simpleType.getMinLength());

+        assertEquals("10", simpleType.getMaxLength());

+        setMaxLength(modelRoot, simpleType, "11");

+        assertEquals("11", simpleType.getMaxLength());

+        assertEquals("1", simpleType.getMinExclusive());

+        setMinExclusive(modelRoot, simpleType, "4");

+        assertEquals("4", simpleType.getMinExclusive());

+        assertEquals("1098098988", simpleType.getMaxExclusive());

+        setMaxExclusive(modelRoot, simpleType, "1098098989");

+        assertEquals("1098098989", simpleType.getMaxExclusive());

+        assertEquals("", simpleType.getDocumentation());

+        setDocumentation(modelRoot, simpleType, "Documentation");

+        assertEquals("Documentation", simpleType.getDocumentation());

+        setDocumentation(modelRoot, simpleType, "NewDocumentation");

+        assertEquals("NewDocumentation", simpleType.getDocumentation());

+

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "stringType1");

+        assertEquals("10", simpleType.getLength());

+        setLength(modelRoot, simpleType, "11");

+        assertEquals("11", simpleType.getLength());

+

+        final SchemaNamespaceCondition condition = new SchemaNamespaceCondition("");

+

+        condition.setNamespace(EmfXsdUtils.getSchemaForSchemaNS());

+        final org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schemaForSchema = getSchema(

+                description.getAllVisibleSchemas(), condition);

+        assertEquals("string", simpleType.getBaseType().getName());

+        setBaseType(modelRoot, simpleType, schemaForSchema.getType(false, "int"));

+        assertEquals("int", simpleType.getBaseType().getName());

+        setBaseType(modelRoot, simpleType, schema.getType(false, "stringType"));

+        assertEquals("stringType", simpleType.getBaseType().getName());

+        setBaseType(modelRoot, simpleType, schema.getType(false, "intType"));

+        assertEquals("intType", simpleType.getBaseType().getName());

+        // cannot set complex type as base type

+        setBaseType(modelRoot, simpleType, schema.getType(false, "complexType"), IStatus.ERROR);

+        assertEquals("intType", simpleType.getBaseType().getName());

+        setBaseType(modelRoot, simpleType, schema.getType(true, "NewOperation"), IStatus.ERROR);

+        assertEquals("intType", simpleType.getBaseType().getName());

+

+        ResourceUtils.createFolderInProject(getProject(), "src");

+        IFile file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported.xsd", SOURCE_FOLDER,

+                this.getProject(), "Imported.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported.xsd", Document_FOLDER_NAME,

+                this.getProject(), "Imported.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "SupplierInvoice.wsdl", SOURCE_FOLDER,

+                this.getProject(), "SupplierInvoice.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestSingleSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestSingleSchema.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestMultipleSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestMultipleSchema.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestExternal.xsd",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestExternal.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestImportedSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestImportedSchema.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "CopyTypeTestIncludedSchema.wsdl",

+                SOURCE_FOLDER, this.getProject(), "CopyTypeTestIncludedSchema.wsdl");

+        assertTrue(file.exists());

+

+        modelRoot = copyAndGetModelRoot("SimpleTypeWriteTest.wsdl", "TestSimpleType1.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/SimpleType/")[0];

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema2 = description.getSchema("http://sap.com/xi/Purchasing")[0];

+        simpleType = (org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType) schema.getType(false, "stringType");

+        assertEquals("string", simpleType.getBaseType().getName());

+        setBaseType(modelRoot, simpleType, schema2.getType(false, "AcceptanceStatusCode"));

+        assertEquals("AcceptanceStatusCode", simpleType.getBaseType().getName());

+        setBaseType(modelRoot, simpleType, schema2.getType(false, "ActionCode"));

+        assertEquals("ActionCode", simpleType.getBaseType().getName());

+        condition.setNamespace("http://www.example.com/Imported.xsd");

+        schema2 = getSchema1(schema.getAllReferredSchemas(), condition);

+        setBaseType(modelRoot, simpleType, schema2.getType(false, "SKU"));

+        assertEquals("SKU", simpleType.getBaseType().getName());

+    }

+

+    private org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema getSchema1(

+            final Collection<org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema> collection,

+            final SchemaNamespaceCondition condition) {

+        for (final org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema : collection) {

+            if (condition.isSatisfied(schema))

+                return schema;

+        }

+        return null;

+    }

+

+    @Test

+    public void testStructureType() throws Exception {

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType structureType;

+        description = modelRoot.getDescription();

+

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        assertNotNull("Could not find schema http://www.example.org/StructureType/", schema);

+        // Test documentation and name

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        assertEquals("complexType", structureType.getName());

+        rename(modelRoot, structureType, "NewType");

+        assertEquals("NewType", structureType.getName());

+        assertNotNull("Could not find SimpleType NewType", schema.getType(false, "NewType"));

+        assertEquals("Documentation", structureType.getDocumentation());

+        setDocumentation(modelRoot, structureType, "Documentation");

+        assertEquals("Documentation", structureType.getDocumentation());

+        setDocumentation(modelRoot, structureType, "NewDocumentation");

+        assertEquals("NewDocumentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+        assertEquals("complexType", structureType.getName());

+        rename(modelRoot, structureType, "NewElement");

+        assertEquals("NewElement", structureType.getName());

+        assertNotNull("Could not find StructureType NewElement", schema.getType(true, "NewElement"));

+        assertEquals("Documentation", structureType.getDocumentation());

+        setDocumentation(modelRoot, structureType, "DocumentationOne");

+        assertEquals("DocumentationOne", structureType.getDocumentation());

+        setDocumentation(modelRoot, structureType, "NewDocumentation");

+        assertEquals("NewDocumentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctWithAttributes");

+        assertEquals("", structureType.getDocumentation());

+        setDocumentation(modelRoot, structureType, "Documentation");

+        assertEquals("Documentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+        assertEquals("", structureType.getDocumentation());

+        setDocumentation(modelRoot, structureType, "Documentation");

+        assertEquals("Documentation", structureType.getDocumentation());

+        ((Description) description).save();

+

+        modelRoot = getWSDLModelRoot("TestStructureType.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "NewType");

+        assertEquals("NewType", structureType.getName());

+        assertEquals("NewDocumentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "NewElement");

+        assertEquals("NewElement", structureType.getName());

+        assertEquals("NewDocumentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctWithAttributes");

+        assertEquals("Documentation", structureType.getDocumentation());

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+        assertEquals("Documentation", structureType.getDocumentation());

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType1.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // add an element in complexType with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        assertEquals(2, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        IElement element = addElement(modelRoot, structureType, "elementParticle2");

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle2").size());

+        deleteElement(modelRoot, structureType, structureType.getElements("elementParticle1").iterator().next());

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        // add an element in complexType with choice

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema

+                .getType(false, "groupDefinitionType");

+        assertEquals(6, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = addElement(modelRoot, structureType, "elementParticle5");

+        assertEquals(7, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        deleteElement(modelRoot, structureType, "elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        // add an element in complexType with all

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "allModelGroupType");

+        assertEquals(6, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = addElement(modelRoot, structureType, "elementParticle5");

+        assertEquals(7, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        deleteElement(modelRoot, structureType, "elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        // add an element in element declaration with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+        assertEquals(2, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        element = addElement(modelRoot, structureType, "elementParticle2");

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle2").size());

+        deleteElement(modelRoot, structureType, "elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        // add an element in element declaration with simpleType reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithSimpleTypeRef");

+        assertEquals(0, structureType.getAllElements().size());

+        XSDElementDeclaration elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        assertNull("element has anonymous type", elementDecl.getAnonymousTypeDefinition());

+        element = addElement(modelRoot, structureType, "elementParticle");

+        assertEquals(1, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertNull("referred type name is not null", elementDecl.getTypeDefinition().getName());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in element declaration with complexType reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithComplexTypeRef");

+        assertEquals(0, structureType.getAllElements().size());

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        assertNull("element has anonymous type", elementDecl.getAnonymousTypeDefinition());

+        element = addElement(modelRoot, structureType, "elementParticle");

+        assertEquals(1, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertNull("referred type name is not null", elementDecl.getTypeDefinition().getName());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        deleteElement(modelRoot, structureType, "elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in element declaration with open content

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "openContentElement");

+        assertEquals(0, structureType.getAllElements().size());

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        assertNull("element has anonymous type", elementDecl.getAnonymousTypeDefinition());

+        element = addElement(modelRoot, structureType, "elementParticle");

+        assertEquals(1, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertNull("referred type name is not null", elementDecl.getTypeDefinition().getName());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in element declaration with anonymous simpleType

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithAnonymousSimpleType");

+        assertEquals(0, structureType.getAllElements().size());

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition);

+        element = addElement(modelRoot, structureType, "elementParticle");

+        assertEquals(1, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertNotNull("element doesnt have anonymous type", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("element doesnt have anonymous type",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("", structureType.getDocumentation());

+        setDocumentation(modelRoot, structureType, "Documentation");

+        assertEquals("Documentation", structureType.getDocumentation());

+        deleteElement(modelRoot, structureType, "elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in complexType with complexType extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+        assertEquals(4, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = addElement(modelRoot, structureType, "elementParticle5");

+        assertEquals(5, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        deleteElement(modelRoot, structureType, "elementParticle3");

+        assertEquals(0, structureType.getElements("elementParticle3").size());

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        // add an element in complexType with complexType restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctRestriction");

+        assertEquals(2, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        element = addElement(modelRoot, structureType, "elementParticle2");

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle2").size());

+        deleteElement(modelRoot, structureType, "elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle2").size());

+        // add an element in element with complexType with complexType extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "elementCtExtension");

+        assertEquals(4, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = addElement(modelRoot, structureType, "elementParticle5");

+        assertEquals(5, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        deleteElement(modelRoot, structureType, "elementParticle3");

+        assertEquals(0, structureType.getElements("elementParticle3").size());

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        // add an element in complexType with simpleContent extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+        XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        assertTrue("ComplexType doesnt have simple content", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        element = addElement(modelRoot, structureType, "elementParticle");

+        assertEquals(4, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertTrue("ComplexType doesnt have simple content", complexType.getContent() instanceof XSDParticle);

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in complexType with simpleContent restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentRestriction");

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        assertTrue("ComplexType doesnt have simple content", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals(2, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        element = addElement(modelRoot, structureType, "elementParticle");

+        assertEquals(3, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        assertTrue("ComplexType doesnt have simple content", complexType.getContent() instanceof XSDParticle);

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // add an element in complexType with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "nestedElements");

+        assertEquals(8, structureType.getAllElements().size());

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+        element = addElement(modelRoot, structureType, "elementParticle5");

+        assertEquals(9, structureType.getAllElements().size());

+        assertEquals(1, structureType.getElements("elementParticle5").size());

+        deleteElement(modelRoot, structureType, "elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        deleteElement(modelRoot, structureType, element);

+        assertEquals(0, structureType.getElements("elementParticle5").size());

+

+        // Test Removal

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType1.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // Remove an element in complexType with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        assertEquals(1, structureType.getElements("elementParticle1").size());

+        deleteElement(modelRoot, structureType, "elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        // Remove an element in complexType with choice

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema

+                .getType(false, "groupDefinitionType");

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        deleteElement(modelRoot, structureType, "elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // Remove an element in complexType with all

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "allModelGroupType");

+

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        deleteElement(modelRoot, structureType, "elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // Remove an element in element declaration with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+

+        assertEquals(1, structureType.getElements("elementParticle").size());

+        deleteElement(modelRoot, structureType, "elementParticle");

+        assertEquals(0, structureType.getElements("elementParticle").size());

+        // Remove an element in complexType with complexType extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+

+        assertEquals(1, structureType.getElements("elementParticle3").size());

+        deleteElement(modelRoot, structureType, "elementParticle3");

+        assertEquals(0, structureType.getElements("elementParticle3").size());

+        // Remove an element in complexType with complexType restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctRestriction");

+

+        assertEquals(1, structureType.getElements("elementParticle1").size());

+        deleteElement(modelRoot, structureType, "elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        // Remove an element in element with complexType with complexType

+        // extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "elementCtExtension");

+

+        assertEquals(1, structureType.getElements("elementParticle3").size());

+        deleteElement(modelRoot, structureType, "elementParticle3");

+        assertEquals(0, structureType.getElements("elementParticle3").size());

+        // Remove an element in complexType with simpleContent extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+

+        assertEquals(1, structureType.getElements("attribute1").size());

+        deleteElement(modelRoot, structureType, "attribute1");

+        assertEquals(0, structureType.getElements("attribute1").size());

+        // Remove an element in complexType with simpleContent restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentRestriction");

+

+        assertEquals(1, structureType.getElements("attribute1").size());

+        deleteElement(modelRoot, structureType, "attribute1");

+        assertEquals(0, structureType.getElements("attribute1").size());

+        // Remove an element in complexType with sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "nestedElements");

+

+        assertEquals(1, structureType.getElements("attribute1").size());

+        deleteElement(modelRoot, structureType, "elementParticle1");

+        assertEquals(0, structureType.getElements("elementParticle1").size());

+        assertEquals(1, structureType.getElements("attribute1").size());

+        deleteElement(modelRoot, structureType, "attribute1");

+        assertEquals(0, structureType.getElements("attribute1").size());

+

+        // Test Set baseType

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType2.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for element with ST Reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithSimpleTypeRef");

+

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "simpleType"));

+        assertNotNull("anonymous simpleType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        // set CT as baseType for element with CT Reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithComplexTypeRef");

+

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "complexType"));

+        assertNotNull("anonymous complexType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("complexType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        assertTrue(XSDDerivationMethod.EXTENSION_LITERAL.equals(((XSDComplexTypeDefinition) elementDecl

+                .getAnonymousTypeDefinition()).getDerivationMethod()));

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureType4.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set CT as baseType for element with ST Reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithSimpleTypeRef");

+

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+

+        setBaseType(modelRoot, structureType, schema.getType(false, "complexType"));

+        assertNotNull("anonymous complexType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("complexType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        assertTrue(XSDDerivationMethod.EXTENSION_LITERAL.equals(((XSDComplexTypeDefinition) elementDecl

+                .getAnonymousTypeDefinition()).getDerivationMethod()));

+        // set ST as baseType for element with CT Reference

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true,

+                "elementWithComplexTypeRef");

+

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "simpleType"));

+        assertNotNull("anonymous simpleType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureTypeOne.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for element with Anonymous ST

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "globalElementWithSt");

+

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "simpleType"));

+        assertNotNull("anonymous simpleType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be simpleType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        // set ST as baseType for element with Anonymous CT

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "simpleType"));

+        assertNotNull("anonymous simpleType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be complexType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("simpleType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        assertTrue(XSDDerivationMethod.EXTENSION_LITERAL.equals(((XSDComplexTypeDefinition) elementDecl

+                .getAnonymousTypeDefinition()).getDerivationMethod()));

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureTypeTwo.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set CT as baseType for element with Anonymous ST

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "globalElementWithSt");

+

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "complexType"));

+        assertNotNull("anonymous complexType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be complexType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("complexType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        // set CT as baseType for element with Anonymous CT

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(true, "complexType");

+

+        elementDecl = (XSDElementDeclaration) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "complexType"));

+        assertNotNull("anonymous complexType must be created as type of this element", elementDecl.getAnonymousTypeDefinition());

+        assertTrue("Anonymous type must be complexType",

+                elementDecl.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition);

+        assertEquals("complexType", elementDecl.getAnonymousTypeDefinition().getBaseType().getName());

+        assertTrue(XSDDerivationMethod.RESTRICTION_LITERAL.equals(((XSDComplexTypeDefinition) elementDecl

+                .getAnonymousTypeDefinition()).getDerivationMethod()));

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureTypeFour.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for CT with Sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "simpleType"));

+        assertTrue("content must be complexType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with ctExtension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "simpleType"));

+        assertTrue("content must be complexType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with Restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctRestriction");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "simpleType"));

+        assertTrue("content must be complexType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+

+        modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestStructureTypeFive.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for CT with Sequence

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "complexType"));

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.RESTRICTION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with ctExtension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctExtension");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "complexType"));

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with Restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctRestriction");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "complexType"));

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.RESTRICTION_LITERAL, complexType.getDerivationMethod());

+

+        modelRoot = getWSDLModelRoot("TestStructureTypeFive.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set CT as baseType for CT with simpleContent extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "complexType"));

+        assertTrue("content must be XSDParticle", complexType.getContent() instanceof XSDParticle);

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set CT as baseType for CT with simpleContent restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentRestriction");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "complexType"));

+        assertTrue("content must be XSDParticle", complexType.getContent() instanceof XSDParticle);

+        assertEquals("complexType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.RESTRICTION_LITERAL, complexType.getDerivationMethod());

+

+        modelRoot = getWSDLModelRoot("TestStructureTypeFive.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        // set ST as baseType for CT with simpleContent extension

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "simpleType"));

+        assertTrue("content must be simpleType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        // set ST as baseType for CT with simpleContent restriction

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentRestriction");

+

+        complexType = (XSDComplexTypeDefinition) structureType.getComponent();

+        setBaseType(modelRoot, structureType, schema.getType(false, "simpleType"));

+        assertTrue("content must be simpleType", complexType.getContent() instanceof XSDSimpleTypeDefinition);

+        assertEquals("simpleType", complexType.getBaseType().getName());

+        assertEquals(XSDDerivationMethod.EXTENSION_LITERAL, complexType.getDerivationMethod());

+        assertEquals(false, structureType.isAnonymous());

+

+        // TODO Howto implement setAnonymous?

+        // wStructureType.setAnonymous(true);

+    }

+

+    @Test

+    public void testElement() throws Exception {

+        IWsdlModelRoot modelRoot = copyAndGetModelRoot("StructureType.wsdl", "TestElement.wsdl");

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType structureType;

+        description = modelRoot.getDescription();

+

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        assertNotNull("Could not find schema http://www.example.org/StructureType/", schema);

+        // Test documentation and name

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "complexType");

+        IElement element = structureType.getElements("elementParticle").iterator().next();

+        assertEquals("elementParticle", element.getName());

+        renameElement(modelRoot, element, "newName");

+        assertEquals("newName", element.getName());

+        assertEquals("Documentation", element.getDocumentation());

+        setDocumentation(modelRoot, element, "NewDocumentation");

+        assertEquals("NewDocumentation", element.getDocumentation());

+        assertEquals(1, element.getMinOccurs());

+        setMinOccurs(modelRoot, element, 2);

+        assertEquals(2, element.getMinOccurs());

+        assertEquals(1, element.getMaxOccurs());

+        setMaxOccurs(modelRoot, element, 4);

+        assertEquals(4, element.getMaxOccurs());

+        assertEquals(false, element.getNillable());

+        setNillable(modelRoot, element, true);

+        assertEquals(true, element.getNillable());

+

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctWithAttributes");

+        element = structureType.getElements("elementParticle3").iterator().next();

+        assertEquals("", element.getDocumentation());

+        setDocumentation(modelRoot, element, "NewDocumentation");

+        assertEquals("NewDocumentation", element.getDocumentation());

+        element = structureType.getElements("globalElement").iterator().next();

+        assertEquals(10, element.getMinOccurs());

+        setMinOccurs(modelRoot, element, 13);

+        assertEquals(13, element.getMinOccurs());

+        assertEquals(100, element.getMaxOccurs());

+        setMaxOccurs(modelRoot, element, 26);

+        assertEquals(26, element.getMaxOccurs());

+        assertEquals(false, element.getNillable());

+        setNillable(modelRoot, element, true);

+        assertEquals(true, element.getNillable());

+        assertEquals("", element.getDocumentation());

+        setDocumentation(modelRoot, element, "NewDocumentation");

+        assertEquals("NewDocumentation", element.getDocumentation());

+        element = structureType.getElements("attribute1").iterator().next();

+        assertEquals("", element.getDocumentation());

+        setDocumentation(modelRoot, element, "NewDocumentation");

+        assertEquals("NewDocumentation", element.getDocumentation());

+        assertEquals(0, element.getMinOccurs());

+        setMinOccurs(modelRoot, element, 2, IStatus.ERROR);

+        assertEquals(0, element.getMinOccurs());

+        assertEquals(1, element.getMaxOccurs());

+        // //fails with exception instead of fail with an error

+        // setMaxOccurs(modelRoot, element, 4, IStatus.ERROR);

+        assertEquals(1, element.getMaxOccurs());

+        assertEquals(false, element.getNillable());

+        // //fails with exception instead of fail with an error in status

+        // setNillable(modelRoot, element, true, IStatus.ERROR);

+        assertEquals(false, element.getNillable());

+

+        modelRoot = getWSDLModelRoot("TestElement.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/StructureType/")[0];

+        assertNotNull("Could not find schema http://www.example.org/StructureType/", schema);

+        // Test type assignment for element

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false, "ctWithAttributes");

+        element = structureType.getElements("elementParticle3").iterator().next();

+        assertEquals("string", element.getType().getName());

+        setType(modelRoot, element, schema.getType(false, "complexType"));

+        assertEquals("complexType", element.getType().getName());

+        assertEquals("elementParticle3", element.getName());

+        setType(modelRoot, element, schema.getType(false, "simpleType"));

+        assertEquals("simpleType", element.getType().getName());

+        assertEquals("elementParticle3", element.getName());

+        setElementAnonymousType(((AbstractXSDComponent) schema).getModelRoot(), element, true);

+        setElementAnonymousType(((AbstractXSDComponent) schema).getModelRoot(), element, false);

+

+        element = structureType.getElements("globalElement").iterator().next();

+        assertEquals("globalElement", element.getType().getName());

+        setType(modelRoot, element, schema.getType(false, "complexType"));

+        assertEquals("complexType", element.getType().getName());

+        assertEquals("globalElement", element.getName());

+        setType(modelRoot, element, schema.getType(false, "simpleType"));

+        assertEquals("simpleType", element.getType().getName());

+        assertEquals("globalElement", element.getName());

+        setElementAnonymousType(((AbstractXSDComponent) schema).getModelRoot(), element, true);

+        setElementAnonymousType(((AbstractXSDComponent) schema).getModelRoot(), element, false);

+

+        element = structureType.getElements("attribute1").iterator().next();

+        assertEquals("string", element.getType().getName());

+        setType(modelRoot, element, schema.getType(false, "complexType"));

+        assertEquals("string", element.getType().getName());

+        assertEquals("attribute1", element.getName());

+        setType(modelRoot, element, schema.getType(false, "simpleType"));

+        assertEquals("simpleType", element.getType().getName());

+        assertEquals("attribute1", element.getName());

+        setElementAnonymousType(((AbstractXSDComponent) schema).getModelRoot(), element, true);

+        // setElementAnonymousType(((AbstractXSDComponent)schema).getModelRoot(),

+        // element, false);

+

+        structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema.getType(false,

+                "ctSimpleContentExtension");

+        element = structureType.getElements("globalAttribute").iterator().next();

+        assertNull("Type must be null for attributes", element.getType());

+        setType(modelRoot, element, schema.getType(false, "complexType"));

+        assertNull("ComplexType must not be set", element.getType());

+        assertEquals("globalAttribute", element.getName());

+        setType(modelRoot, element, schema.getType(false, "simpleType"));

+        assertEquals("simpleType", element.getType().getName());

+        assertEquals("globalAttribute", element.getName());

+    }

+

+    @Test

+    public void testTypeCopyPaste() throws Exception {

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        IWsdlModelRoot modelRoot;

+

+        ResourceUtils.createFolderInProject(getProject(), "src");

+        IFile file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported_copy.xsd",

+                SOURCE_FOLDER, this.getProject(), "Imported_copy.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Imported1_copy.xsd",

+                Document_FOLDER_NAME, this.getProject(), "Imported1_copy.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Importing_copy.xsd", SOURCE_FOLDER,

+                this.getProject(), "Importing_copy.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Included_copy.xsd", SOURCE_FOLDER, this

+                .getProject(), "Included_copy.xsd");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "IncludedTypesInSchema_copy.wsdl",

+                SOURCE_FOLDER, this.getProject(), "IncludedTypesInSchema_copy.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "IncludedTypesInWSDL_copy.wsdl",

+                SOURCE_FOLDER, this.getProject(), "IncludedTypesInWSDL_copy.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "MultipleNamespacesTypes_copy.wsdl",

+                SOURCE_FOLDER, this.getProject(), "MultipleNamespacesTypes_copy.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "NullNamespaceWSDL_copy.wsdl",

+                SOURCE_FOLDER, this.getProject(), "NullNamespaceWSDL_copy.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(

+                Constants.DATA_PUBLIC_SELF_KESHAV + "TypesReferringExternalSchema_copy.wsdl", SOURCE_FOLDER, this.getProject(),

+                "TypesReferringExternalSchema_copy.wsdl");

+        assertTrue(file.exists());

+

+        modelRoot = copyAndGetModelRoot("TestSI.wsdl", "TestSI.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/")[0];

+        assertEquals(2, schema.getAllContainedTypes().size());

+

+        // Multiple Namespaces WSDL

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/SupplierInvoice.wsdl", "http://www.example.org/",

+                "http://sap.com/xi/SupplierInvoicing", "SupplierInvoiceRequest");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/SupplierInvoice.wsdl", "http://www.example.org/",

+                "http://sap.com/xi/SupplierInvoicing", "SupplierInvoiceRequestResponse");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "complexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "secondSimpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElement");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithElementRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/MultipleNamespacesTypes_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+

+        // Schema Types

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "complexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "secondSimpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElement");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithElementRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/Importing_copy.xsd", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+

+        // WSDL importing Schema Types

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "complexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "secondSimpleType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElement");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithElementRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/TypesReferringExternalSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+

+        // Including types from WSDL

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithAnonymousComplexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInWSDL_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+

+        // Including types from Schema

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithExternalTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "simpleTypeWithAnonymousRefExternalType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "globalElementWithAnonymousComplexType");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttributes");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithAttribtueGroupRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "TypeWithRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithSimpleTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexTypeWithComplexTypeRef");

+        assertCopyWithNewFile("TestSI.wsdl", "src/wsdl/IncludedTypesInSchema_copy.wsdl", "http://www.example.org/",

+                "http://www.example.org/MultipleNamespaces/", "ComplexCompositeType");

+

+        modelRoot = copyAndGetModelRoot("TestSI.wsdl", "TestSI.wsdl");

+        description = modelRoot.getDescription();

+        schema = description.getSchema("http://www.example.org/")[0];

+        final org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType structureType = (org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType) schema

+                .getType(true, "NewOperation");

+        assertEquals(1, structureType.getElements("in").size());

+

+        // test if form copy is fine

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Source.wsdl", SOURCE_FOLDER, this

+                .getProject(), "Source.wsdl");

+        assertTrue(file.exists());

+        file = ResourceUtils.copyFileIntoTestProject(Constants.DATA_PUBLIC_SELF_KESHAV + "Target.wsdl", SOURCE_FOLDER, this

+                .getProject(), "Target.wsdl");

+        assertTrue(file.exists());

+    }

+

+    public void assertCopyWithNewFile(final String targetFile, final String sourceFile, final String targetNs,

+            final String sourceNs, final String typeName) throws Exception {

+        org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription description;

+        org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema;

+        IWsdlModelRoot modelRoot;

+

+        modelRoot = getWSDLModelRoot(targetFile);

+        description = modelRoot.getDescription();

+        schema = description.getSchema(targetNs)[0];

+        assertNotNull(schema);

+    }

+

+    public void assertCopyElement(final org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType structureType,

+            final IElement element) throws IllegalInputException {

+        try {

+            final ISchema schema = structureType.getParent();

+            final IXSDModelRoot modelRoot = ((AbstractXSDComponent) schema).getModelRoot();

+            final CopyElementCommand cmd = new CopyElementCommand(modelRoot, structureType, element, schema);

+            assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        } catch (final ExecutionException e) {

+            throw new IllegalStateException("The command execution failed. See nested exception", e);

+        }

+        assertTrue(structureType.getElements(element.getName()).size() > 0);

+    }

+

+    private org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema getSchema(

+            final Collection<org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema> schemas,

+            final ICondition<org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema> condition) {

+        for (final org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema : schemas) {

+            if (condition.isSatisfied(schema))

+                return schema;

+        }

+        return null;

+    }

+

+    interface ICondition<T> {

+        boolean isSatisfied(T in);

+    }

+

+    private class SchemaNamespaceCondition implements ICondition<org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema> {

+

+        private String _namespace;

+

+        public SchemaNamespaceCondition(final String namespace) {

+            this._namespace = namespace;

+        }

+

+        public boolean isSatisfied(final org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema in) {

+            if ((null == _namespace && null == in.getNamespace()) || (null != _namespace && _namespace.equals(in.getNamespace())))

+                return true;

+            return false;

+        }

+

+        public void setNamespace(final String namespace) {

+            this._namespace = namespace;

+        }

+

+    }

+

+    private IWsdlModelRoot copyAndGetModelRoot(final String fileName, final String targetName) throws Exception {

+        return getWSDLModelRoot(Constants.DATA_PUBLIC_SELF_KESHAV + fileName, targetName);

+    }

+

+    private IWsdlModelRoot getWSDLModelRoot(final String fileName) {

+        final IFile file = (IFile) getProject().findMember(new Path(Document_FOLDER_NAME + IPath.SEPARATOR + fileName));

+        assertTrue(file.exists());

+        final IWsdlModelRoot modelRoot = ModelManager.getInstance().getWsdlModelRoot(new FileEditorInput(file));

+        setupEnvironment(modelRoot);

+        return modelRoot;

+    }

+

+    private static void setNamespace(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema, final String namespace) throws ExecutionException {

+        final SetNamespaceCommand cmd = new SetNamespaceCommand(modelRoot, schema, namespace);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void createGlobalTypeFromAnonymous(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema, final IElement element, final String name)

+            throws ExecutionException {

+        final CreateGlobalTypeFromAnonymousCommand cmd = new CreateGlobalTypeFromAnonymousCommand(modelRoot, schema, element,

+                name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType addSimpleType(final IXSDModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema, final String name) throws ExecutionException {

+        final AddSimpleTypeCommand cmd = new AddSimpleTypeCommand(modelRoot, schema, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        return cmd.getSimpleType();

+    }

+

+    private static org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType addStructureType(final IXSDModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema, final String name, final boolean element,

+            final AbstractType referencedType) throws ExecutionException {

+        final AddStructureTypeCommand cmd = new AddStructureTypeCommand(modelRoot, schema, name, element, referencedType);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        return cmd.getStructureType();

+    }

+

+    private static final void removeType(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema schema, final IType type) throws ExecutionException {

+        final RemoveTypeCommand cmd = new RemoveTypeCommand(modelRoot, schema, type);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static final void renameSimpleType(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType namedObject, final String name)

+            throws ExecutionException {

+        final RenameNamedComponent cmd = new RenameNamedComponent(modelRoot, namedObject, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static final void setMinLength(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final String length) throws ExecutionException {

+        final AddFacetCommand cmd = FacetsCommandFactory.createAddMinLengthFacetCommand(modelRoot, type, length);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static final void setMaxLength(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final String length) throws ExecutionException {

+        final AddFacetCommand cmd = FacetsCommandFactory.createAddMaxLengthFacetCommand(modelRoot, type, length);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void addEnumeration(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final String value) throws ExecutionException {

+        final AddFacetCommand cmd = FacetsCommandFactory.createAddEnumerationFacetCommand(modelRoot, type, value);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void deleteEnumeration(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final IFacet facet) throws ExecutionException {

+        final DeleteFacetCommand cmd = FacetsCommandFactory.createDeleteEnumerationFacetCommand(modelRoot, type, facet);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void addPattern(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final String value) throws ExecutionException {

+        final AddFacetCommand cmd = FacetsCommandFactory.createAddPatternFacetCommand(modelRoot, type, value);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void deletePattern(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final IFacet facet) throws ExecutionException {

+        final DeleteFacetCommand cmd = FacetsCommandFactory.createDeletePatternFacetCommand(modelRoot, type, facet);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static final void setMinInclusive(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final String length) throws ExecutionException {

+        final AddFacetCommand cmd = FacetsCommandFactory.createAddMinInclusiveFacetCommand(modelRoot, type, length);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static final void setMaxInclusive(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final String length) throws ExecutionException {

+        final AddFacetCommand cmd = FacetsCommandFactory.createAddMaxInclusiveFacetCommand(modelRoot, type, length);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static final void setMinExclusive(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final String length) throws ExecutionException {

+        final AddFacetCommand cmd = FacetsCommandFactory.createAddMinExclusiveFacetCommand(modelRoot, type, length);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static final void setMaxExclusive(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final String length) throws ExecutionException {

+        final AddFacetCommand cmd = FacetsCommandFactory.createAddMaxExclusiveFacetCommand(modelRoot, type, length);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static final void setLength(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType type, final String length) throws ExecutionException {

+        final AddFacetCommand cmd = FacetsCommandFactory.createAddLengthFacetCommand(modelRoot, type, length);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void setBaseType(final IModelRoot modelRoot, final IType type, final IType baseType) throws ExecutionException {

+        setBaseType(modelRoot, type, baseType, IStatus.OK);

+    }

+

+    private static void setBaseType(final IModelRoot modelRoot, final IType type, final IType baseType,

+            final int expectedStatusSeverity) throws ExecutionException {

+        final SetBaseTypeCommand cmd = new SetBaseTypeCommand(modelRoot, type, baseType);

+        final IStatus status = modelRoot.getEnv().execute(cmd);

+        assertEquals(status.toString(), expectedStatusSeverity, status.getSeverity());

+    }

+

+    public static void rename(final IModelRoot modelRoot, final INamedObject namedObject, final String name)

+            throws ExecutionException {

+        final RenameNamedComponent cmd = new RenameNamedComponent(modelRoot, namedObject, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    public static IElement addElement(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType type, final String name) throws ExecutionException {

+        final AddElementCommand cmd = new AddElementCommand(modelRoot, type, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+        return cmd.getElement();

+    }

+

+    public static void deleteElement(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType type, final IElement element)

+            throws ExecutionException {

+        final DeleteElementCommand cmd = new DeleteElementCommand(modelRoot, type, element);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    public static void renameElement(final IModelRoot modelRoot, final IElement element, final String name)

+            throws ExecutionException {

+        final RenameElementCommand cmd = new RenameElementCommand(modelRoot, element, name);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    public static void deleteElement(final IModelRoot modelRoot,

+            final org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType type, final String elementName)

+            throws ExecutionException {

+        final IElement element = type.getElements(elementName).iterator().next();

+        final DeleteElementCommand cmd = new DeleteElementCommand(modelRoot, type, element);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    public static void setAnonymous(final IXSDModelRoot modelRoot, final IElement element, final AbstractType type,

+            final boolean isSimple) throws ExecutionException {

+        final SetAnonymousCommand cmd = new SetAnonymousCommand(modelRoot, element, type, isSimple);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void setMinOccurs(final IModelRoot modelRoot, final IElement element, final int value,

+            final int expectedSeverity) throws ExecutionException {

+        final SetElementOccurences cmd = new SetElementOccurences(modelRoot, element, value, element.getMaxOccurs());

+        final IStatus status = modelRoot.getEnv().execute(cmd);

+        assertEquals(expectedSeverity, status.getSeverity());

+    }

+

+    private static void setMinOccurs(final IModelRoot modelRoot, final IElement element, final int value)

+            throws ExecutionException {

+        setMinOccurs(modelRoot, element, value, Status.OK);

+    }

+

+    private static void setMaxOccurs(final IModelRoot modelRoot, final IElement element, final int value,

+            final int expectedSeverity) throws ExecutionException {

+        final SetElementOccurences cmd = new SetElementOccurences(modelRoot, element, element.getMinOccurs(), value);

+        final IStatus status = modelRoot.getEnv().execute(cmd);

+        assertEquals(expectedSeverity, status.getSeverity());

+    }

+

+    private static void setMaxOccurs(final IModelRoot modelRoot, final IElement element, final int value)

+            throws ExecutionException {

+        setMaxOccurs(modelRoot, element, value, IStatus.OK);

+    }

+

+    private static void setNillable(final IModelRoot modelRoot, final IElement element, final boolean nillable,

+            final int expectedSeverity) throws ExecutionException {

+        final SetElementNillableCommand cmd = new SetElementNillableCommand(modelRoot, element, nillable);

+        final IStatus status = modelRoot.getEnv().execute(cmd);

+        assertEquals(expectedSeverity, status.getSeverity());

+    }

+

+    private static void setNillable(final IModelRoot modelRoot, final IElement element, final boolean nillable)

+            throws ExecutionException {

+        setNillable(modelRoot, element, nillable, IStatus.OK);

+    }

+

+    private static void setType(final IModelRoot modelRoot, final IElement element, final IType type) throws ExecutionException {

+        final SetElementTypeCommand cmd = new SetElementTypeCommand(modelRoot, element, type);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void setElementAnonymousType(final IXSDModelRoot modelRoot, final IElement element, final boolean anonymous)

+            throws ExecutionException {

+        final SetAnonymousCommand cmd = new SetAnonymousCommand(modelRoot, element, (AbstractType) element.getType(), anonymous);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+

+    private static void setDocumentation(final IModelRoot modelRoot, final IModelObject modelObject, final String text)

+            throws ExecutionException {

+        final SetDocumentationCommand cmd = new SetDocumentationCommand(modelRoot, modelObject, text);

+        assertEquals(Status.OK_STATUS, modelRoot.getEnv().execute(cmd));

+    }

+}
\ No newline at end of file
diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractBaseCommandTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractBaseCommandTest.java
new file mode 100644
index 0000000..c49f691
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractBaseCommandTest.java
@@ -0,0 +1,142 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands;

+

+import org.eclipse.core.commands.operations.IOperationHistory;

+import org.eclipse.core.commands.operations.IUndoContext;

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.core.runtime.NullProgressMonitor;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.emf.workspace.AbstractEMFOperation;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.After;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.core.common.Logger;

+import org.eclipse.wst.sse.sieditor.model.XMLModelNotifierWrapper;

+import org.eclipse.wst.sse.sieditor.model.api.IModelRoot;

+

+public abstract class AbstractBaseCommandTest<T extends IModelRoot> extends SIEditorBaseTest {

+

+    protected IOperationHistory operationHistory;

+    protected IUndoContext undoContext;

+    protected XMLModelNotifierWrapper xmlModelNotifierWrapper;

+

+    protected void assertPostExecuteState(final IStatus status, final T modelRoot) {

+        assertStatusOK(status);

+        assertPostRedoState(status, modelRoot);

+    }

+

+    protected abstract void assertPostUndoState(IStatus undoStatus, T modelRoot);

+

+    protected abstract void assertPostRedoState(IStatus redoStatus, T modelRoot);

+

+    protected abstract AbstractEMFOperation getOperation(T modelRoot) throws Exception;

+

+    protected abstract String getFilename();

+

+    protected abstract String getFolderName();

+

+    protected abstract String getEditorId();

+

+    @After

+    @Override

+    public void tearDown() throws Exception {

+        xmlModelNotifierWrapper = null;

+        super.tearDown();

+    }

+

+    @Test

+    public void testCommandExecution() throws Throwable {

+        try {

+            final T modelRoot = getModelRoot();

+            final AbstractEMFOperation operation = getOperation(modelRoot);

+

+            executeOperation(operation, modelRoot);

+            executeUndoOperation(operation, modelRoot);

+            executeRedoOperation(operation, modelRoot);

+            executeUndoOperation(operation, modelRoot);

+            executeRedoOperation(operation, modelRoot);

+

+        } finally {

+            disposeModel();

+        }

+    }

+

+    protected void executeOperation(final AbstractEMFOperation operation, final T modelRoot) throws Throwable {

+        assertFalse(operationHistory.canUndo(undoContext));

+        assertFalse(operationHistory.canRedo(undoContext));

+

+        final IStatus status = modelRoot.getEnv().execute(operation);

+

+        assertPostExecuteState(status, modelRoot);

+    }

+

+    protected void executeUndoOperation(final AbstractEMFOperation operation, final T modelRoot) throws Throwable {

+        assertEquals(operation.getLabel(), operationHistory.getUndoOperation(undoContext).getLabel());

+        assertTrue(operationHistory.canUndo(undoContext));

+        assertFalse(operationHistory.canRedo(undoContext));

+

+        final IStatus status = operationHistory.undo(undoContext, new NullProgressMonitor(), null);

+

+        assertStatusOK(status);

+        assertPostUndoState(status, modelRoot);

+    }

+

+    protected void executeRedoOperation(final AbstractEMFOperation operation, final T modelRoot) throws Throwable {

+        assertEquals(operation.getLabel(), operationHistory.getRedoOperation(undoContext).getLabel());

+        assertTrue(operationHistory.canRedo(undoContext));

+        assertFalse(operationHistory.canUndo(undoContext));

+

+        final IStatus status = operationHistory.redo(undoContext, new NullProgressMonitor(), null);

+

+        assertStatusOK(status);

+        assertPostRedoState(status, modelRoot);

+    }

+

+    private void assertStatusOK(final IStatus status) {

+        if (!status.isOK()) {

+            Logger.log(status);

+            if (status.getException() != null) {

+                status.getException().printStackTrace();

+            }

+        }

+        assertEquals(Status.OK_STATUS, status);

+    }

+

+    @Override

+    protected void setupEnvironment(final IModelRoot modelRoot) {

+        operationHistory = modelRoot.getEnv().getOperationHistory();

+    }

+

+    @Override

+    protected String getProjectName() {

+        return "CommandsTestingProject";

+    }

+

+    protected T getModelRoot() throws Exception {

+        final String wsdlFilename = getFilename();

+        final String fullPath = getFolderName() + wsdlFilename;

+

+        final T modelRoot = (T) getModelRoot(fullPath, wsdlFilename, getEditorId());

+

+        operationHistory = editor.getOperationHistory();

+        undoContext = editor.getUndoContext();

+        xmlModelNotifierWrapper = editor.getModelNotifier();

+

+        return modelRoot;

+    }

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractCommandChainTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractCommandChainTest.java
new file mode 100644
index 0000000..3c4779a
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractCommandChainTest.java
@@ -0,0 +1,137 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands;

+

+import java.util.ArrayList;

+import java.util.List;

+

+import org.eclipse.core.commands.operations.IUndoableOperation;

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.core.runtime.NullProgressMonitor;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.emf.workspace.AbstractEMFOperation;

+import org.junit.Before;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.common.AbstractNotificationOperation;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+

+public abstract class AbstractCommandChainTest extends AbstractCommandTest {

+

+    protected abstract AbstractNotificationOperation getNextOperation(final IWsdlModelRoot modelRoot) throws Exception;

+

+    // ******************************

+    // Override (optionally) the following methods in order to assert at finer

+    // grained execution

+

+    protected void assertPostOperationUndoState(final IUndoableOperation operation, final IWsdlModelRoot modelRoot) {

+        // EMPTY. Implementors might want to add some assertions here

+    }

+

+    protected void assertPostOperationRedoState(final IUndoableOperation operation, final IWsdlModelRoot modelRoot) {

+        // EMPTY. Implementors might want to add some assertions here

+    }

+

+    @Override

+    protected void assertPostExecuteState(final IStatus status, final IWsdlModelRoot modelRoot) {

+        assertEquals(Status.OK_STATUS, status);

+    }

+

+    // *****************************

+

+    private List<AbstractEMFOperation> operations;

+

+    @Override

+    @Before

+    public void setUp() throws Exception {

+        super.setUp();

+        operations = new ArrayList<AbstractEMFOperation>();

+    }

+

+    @Override

+    protected AbstractNotificationOperation getOperation(final IWsdlModelRoot modelRoot) throws Exception {

+        return getNextOperation(modelRoot);

+    }

+

+    @Test

+    @Override

+    public void testCommandExecution() throws Throwable {

+        try {

+            final IWsdlModelRoot modelRoot = getModelRoot();

+

+            assertEquals(0, operationHistory.getUndoHistory(undoContext).length);

+            assertEquals(0, operationHistory.getRedoHistory(undoContext).length);

+

+            AbstractNotificationOperation operation = null;

+            while ((operation = getNextOperation(modelRoot)) != null) {

+                executeOperation(operation, modelRoot);

+            }

+

+            this.executeUndoOperation(modelRoot);

+            this.executeRedoOperation(modelRoot);

+            this.executeUndoOperation(modelRoot);

+            this.executeRedoOperation(modelRoot);

+

+        } finally {

+            disposeModel();

+        }

+    }

+

+    @Override

+    protected void executeOperation(final AbstractEMFOperation operation, final IWsdlModelRoot modelRoot) throws Throwable {

+        final IStatus status = modelRoot.getEnv().execute(operation);

+        assertPostExecuteState(status, modelRoot);

+        operations.add(operation);

+    }

+

+    protected void executeUndoOperation(final IWsdlModelRoot modelRoot) throws Throwable {

+        assertTrue(operationHistory.canUndo(undoContext));

+        assertFalse(operationHistory.canRedo(undoContext));

+

+        IStatus status = null;

+        for (int i = operations.size() - 1; i >= 0; i--) {

+            final IUndoableOperation operation = operationHistory.getUndoOperation(undoContext);

+            assertEquals(operations.get(i).getLabel(), operation.getLabel());

+            assertTrue(operation.canUndo());

+            status = operationHistory.undo(undoContext, new NullProgressMonitor(), null);

+            assertEquals(Status.OK_STATUS, status);

+            assertPostOperationUndoState(operation, modelRoot);

+        }

+

+        assertEquals(0, operationHistory.getUndoHistory(undoContext).length);

+        assertEquals(operations.size(), operationHistory.getRedoHistory(undoContext).length);

+        assertPostUndoState(status, modelRoot);

+    }

+

+    protected void executeRedoOperation(final IWsdlModelRoot modelRoot) throws Throwable {

+        assertTrue(operationHistory.canRedo(undoContext));

+        assertFalse(operationHistory.canUndo(undoContext));

+

+        IStatus status = null;

+        for (int i = 0; i < operations.size(); i++) {

+            final IUndoableOperation operation = operationHistory.getRedoOperation(undoContext);

+            assertEquals(operations.get(i).getLabel(), operation.getLabel());

+            assertTrue(operation.canRedo());

+            status = operationHistory.redo(undoContext, new NullProgressMonitor(), null);

+            assertEquals(Status.OK_STATUS, status);

+            assertPostOperationRedoState(operation, modelRoot);

+        }

+

+        assertEquals(operations.size(), operationHistory.getUndoHistory(undoContext).length);

+        assertEquals(0, operationHistory.getRedoHistory(undoContext).length);

+        assertPostRedoState(status, modelRoot);

+    }

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractCommandTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractCommandTest.java
new file mode 100644
index 0000000..87604b9
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractCommandTest.java
@@ -0,0 +1,47 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands;

+

+import org.eclipse.wst.sse.sieditor.test.model.Constants;

+

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.ui.ServiceInterfaceEditor;

+

+public abstract class AbstractCommandTest extends AbstractBaseCommandTest<IWsdlModelRoot> {

+

+    @Override

+    protected String getFilename() {

+        return getWsdlFilename();

+    }

+

+    protected String getWsdlFilename() {

+        return "PurchaseOrderConfirmation.wsdl";

+    }

+

+    protected String getWsdlFoldername() {

+        return Constants.DATA_PUBLIC_SELF_MIX2;

+    }

+

+    @Override

+    protected String getFolderName() {

+        return getWsdlFoldername();

+    }

+

+    @Override

+    protected String getEditorId() {

+        return ServiceInterfaceEditor.EDITOR_ID;

+    }

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractExhaustiveValidatingCommandWSDLTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractExhaustiveValidatingCommandWSDLTest.java
new file mode 100644
index 0000000..93dea47
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractExhaustiveValidatingCommandWSDLTest.java
@@ -0,0 +1,270 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands;

+

+import java.io.File;

+import java.io.IOException;

+import java.net.URISyntaxException;

+import java.net.URL;

+import java.util.ArrayList;

+import java.util.Collection;

+import java.util.List;

+

+import org.eclipse.core.resources.IFile;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.FileLocator;

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.core.runtime.NullProgressMonitor;

+import org.eclipse.core.runtime.Path;

+import org.eclipse.emf.ecore.EObject;

+import org.eclipse.emf.workspace.AbstractEMFOperation;

+import org.eclipse.ui.IEditorInput;

+import org.eclipse.ui.IEditorPart;

+import org.eclipse.ui.IWorkbenchPage;

+import org.eclipse.ui.IWorkbenchWindow;

+import org.eclipse.ui.PartInitException;

+import org.eclipse.ui.PlatformUI;

+import org.eclipse.ui.ide.IDE;

+import org.eclipse.ui.part.FileEditorInput;

+import org.eclipse.wst.sse.sieditor.test.SIEditorTestsPlugin;

+import org.eclipse.wst.sse.sieditor.model.validation.IValidationService;

+import org.eclipse.wst.sse.sieditor.model.validation.IValidationStatusProvider;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.ThreadUtils;

+import org.junit.After;

+import org.junit.Before;

+import org.junit.runner.RunWith;

+import org.junit.runners.Parameterized;

+

+import org.eclipse.wst.sse.sieditor.model.api.IModelRoot;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.ui.AbstractEditorWithSourcePage;

+import org.eclipse.wst.sse.sieditor.ui.ServiceInterfaceEditor;

+

+/**

+ * EXTEND this class and write a static parameters method, annotated like this

+ * example

+ * 

+ * @Parameters public static Collection<Object[]> getEnterpriseWSDLFiles()

+ *             throws IOException, URISyntaxException { return

+ *             generateParameterList(ENTERPRISE_WS_RELATIVE_PATH); }

+ */

+

+@RunWith(Parameterized.class)

+public abstract class AbstractExhaustiveValidatingCommandWSDLTest extends AbstractCommandTest {

+

+    protected static final String ENTERPRISE_WS_RELATIVE_PATH = Document_FOLDER_NAME + Path.SEPARATOR + "enterprise_ws"; //$NON-NLS-1$

+    private static final String ABSTRACT_EXHAUSTIVE_VALIDATIONG_MODEL_TEST = "AbstractExhaustiveValidationgModelTest"; //$NON-NLS-1$

+

+    private File currentFile;

+    protected IFile currentIFile;

+    protected AbstractEditorWithSourcePage openedEditor;

+    protected IWsdlModelRoot modelRoot;

+    private IValidationService validationService;

+

+    /**

+     * Use this method by the yours annotated with @Parameters to generate the

+     * list of files the tests will be run with. by the given Path

+     * 

+     * @param path

+     * @return list of Files - to be parameters

+     * @throws URISyntaxException

+     * @throws IOException

+     */

+    protected static Collection<Object[]> generateParameterList(final String path) throws URISyntaxException, IOException {

+        final URL ewsDirURL = FileLocator.find(SIEditorTestsPlugin.getDefault().getBundle(), new Path(path), null);

+        assertNotNull("path to enterprise wsdls not found", ewsDirURL); //$NON-NLS-1$

+        final File ewsDir = new File(FileLocator.toFileURL(ewsDirURL).toURI());

+        assertTrue("enterprise wsdls dir not found or is not a dir", ewsDir.isDirectory()); //$NON-NLS-1$

+

+        List<File> files = getFilesFromFolderRecursively(ewsDir);

+

+        if (files.size() > getListSizeLimitation()) {

+            files = files.subList(0, getListSizeLimitation());

+        }

+

+        final List<Object[]> wrapperList = new ArrayList<Object[]>();

+        for (final File file : files) {

+            wrapperList.add(new Object[] { file });

+        }

+

+        return wrapperList;

+    }

+

+    /**

+     * Gathers all the files from a directory. Traverses each and every

+     * sub-directory and fetches its files as well. Directories are not added to

+     * the list.

+     * 

+     * @param dir

+     *            directory to descend into

+     * @return a <code>java.util.List</code> of <code>java.io.File</code>. If

+     *         the directory does not contain anything, an empty list is

+     *         returned

+     */

+    public static List<File> getFilesFromFolderRecursively(final File dir) {

+        final List<File> files = new ArrayList<File>();

+

+        gatherFolderFilesRecursively(dir, files);

+

+        return files;

+    }

+

+    private static void gatherFolderFilesRecursively(final File dir, final List<File> files) {

+        final File[] childFiles = dir.listFiles();

+        if (childFiles == null) {

+            return;

+        }

+

+        for (final File childFile : childFiles) {

+            if (childFile.isDirectory()) {

+                gatherFolderFilesRecursively(childFile, files);

+            } else {

+                files.add(childFile);

+            }

+        }

+    }

+

+    public AbstractExhaustiveValidatingCommandWSDLTest(final Object wsdlFile) throws IOException, CoreException {

+        currentFile = (File) wsdlFile;

+    }

+

+    @Override

+    @Before

+    public void setUp() throws Exception {

+        super.setUp();

+        currentIFile = ResourceUtils.copyFileIntoTestProject(currentFile, null, this.getProject(), currentFile.getName());

+        openedEditor = openEditor(currentIFile, getEditorID());

+        assertTrue(openedEditor.getModelRoot() instanceof IWsdlModelRoot);

+        modelRoot = (IWsdlModelRoot) openedEditor.getModelRoot();

+        validationService = openedEditor.getValidationService();

+        assertNotNull(validationService);

+    }

+

+    @Override

+    @After

+    public void tearDown() throws Exception {

+        if (openedEditor != null) {

+            validationService = null;

+            if (!org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false)) {

+                openedEditor.close(false);

+            }

+            // getProject().delete(true, new NullProgressMonitor());

+            openedEditor = null;

+            currentIFile = null;

+            currentFile = null;

+            ThreadUtils.waitOutOfUI(10);

+        }

+        super.tearDown();

+    }

+

+    private AbstractEditorWithSourcePage openEditor(final IFile iFile, final String editorId) throws PartInitException {

+        final IEditorInput input = new FileEditorInput(iFile);

+        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

+        if (window != null) {

+            final IWorkbenchPage page = window.getActivePage();

+            final IEditorPart editor = IDE.openEditor(page, input, editorId);

+            return (AbstractEditorWithSourcePage) editor;

+        }

+        return null;

+    }

+

+    // methods configuring the work of super classes

+    @Override

+    protected String getProjectName() {

+        return ABSTRACT_EXHAUSTIVE_VALIDATIONG_MODEL_TEST;

+    }

+

+    @Override

+    protected IWsdlModelRoot getModelRoot() throws Exception {

+        return modelRoot;

+    }

+

+    @Override

+    protected void setupEnvironment(final IModelRoot modelRoot) {

+        // Do nothing - we open the real editor - the environment should be set

+        // by itself

+    }

+

+    // methods intended to be optionally overridden to configure work of this

+    // test

+

+    /**

+     * Override to provide a different editor ID to be opened

+     * 

+     * @return

+     */

+    protected String getEditorID() {

+        return ServiceInterfaceEditor.EDITOR_ID;

+    }

+

+    /**

+     * Limit the count of parameters for which test is bein run

+     * 

+     * @return

+     */

+    protected static int getListSizeLimitation() {

+        return 150;

+    }

+

+    // -----

+

+    @Override

+    protected void executeOperation(final AbstractEMFOperation operation, final IWsdlModelRoot modelRoot)

+            throws Throwable {

+        // verify that the document is valid before and after command execution

+        verifyValid();

+        super.executeOperation(operation, modelRoot);

+        openedEditor.doSave(new NullProgressMonitor());

+        verifyValid();

+

+    }

+

+    /**

+     * Override to add more assertions to the post unDo state. Default

+     * implementations call {@link #verifyValid()} Don't forget to call it if

+     * such behaviour is expected

+     */

+    @Override

+    protected void assertPostUndoState(final IStatus undoStatus, final IWsdlModelRoot modelRoot) {

+        openedEditor.doSave(new NullProgressMonitor());

+        verifyValid();

+    }

+

+    /**

+     * Override to add more assertions to the post reDo state. Default

+     * implementations call {@link #verifyValid()} Don't forget to call it if

+     * such behaviour is expected

+     */

+    @Override

+    protected void assertPostRedoState(final IStatus redoStatus, final IWsdlModelRoot modelRoot) {

+        openedEditor.doSave(new NullProgressMonitor());

+        verifyValid();

+    }

+

+    /**

+     * Default implementation calls validate for the root model object and

+     * asserts that it's valid validation status

+     */

+    protected void verifyValid() {

+        final Collection<EObject> sources = new ArrayList<EObject>(2);

+        sources.add(modelRoot.getModelObject().getComponent());

+        validationService.validateAll(sources);

+        final IValidationStatusProvider valStatusProvider = validationService.getValidationStatusProvider();

+        assertTrue(

+                "validation errors :" + valStatusProvider.getStatus(modelRoot.getModelObject()).size() + "\n editing file:" + currentIFile.getName(),//$NON-NLS-1$ //$NON-NLS-2$

+                validationService.getValidationStatusProvider().isValid(modelRoot.getModelObject()));

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractXSDCommandTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractXSDCommandTest.java
new file mode 100644
index 0000000..3effff0
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/AbstractXSDCommandTest.java
@@ -0,0 +1,50 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands;

+

+import org.eclipse.wst.sse.sieditor.test.model.Constants;

+

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+import org.eclipse.wst.sse.sieditor.ui.DataTypesEditor;

+

+public abstract class AbstractXSDCommandTest extends AbstractBaseCommandTest<IXSDModelRoot> {

+

+    public AbstractXSDCommandTest() {

+    }

+

+    @Override

+    protected String getEditorId() {

+        return DataTypesEditor.EDITOR_ID;

+    }

+

+    @Override

+    protected String getFilename() {

+        return getXSDFilename();

+    }

+

+    protected String getXSDFilename() {

+        return "PurchaseOrderConfirmation.wsdl";

+    }

+

+    @Override

+    protected String getFolderName() {

+        return getXSDFoldername();

+    }

+

+    protected String getXSDFoldername() {

+        return Constants.DATA_PUBLIC_SELF_MIX2;

+    }

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/TestRenamePartCommandWithMultiReferredPart.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/TestRenamePartCommandWithMultiReferredPart.java
new file mode 100644
index 0000000..9637702
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/TestRenamePartCommandWithMultiReferredPart.java
@@ -0,0 +1,72 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands;

+

+import java.util.List;

+

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.junit.Before;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.emf.wsdl.RenameParameterCommand;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IOperation;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IParameter;

+import org.eclipse.wst.sse.sieditor.ui.ServiceInterfaceEditor;

+

+public class TestRenamePartCommandWithMultiReferredPart extends SIEditorBaseTest {

+    private IDescription modelDescription;

+    private IParameter multiReferredParameter;

+    private IOperation theSecondOperation;

+    private String oldNameOfThePartInTheSecondOperation;

+    private IWsdlModelRoot modelRoot;

+

+    @Override

+    @Before

+    public void setUp() throws Exception {

+        super.setUp();

+        modelRoot = (IWsdlModelRoot) getModelRoot("pub/csns/renameMultiReferredPart.wsdl", //$NON-NLS-1$

+                "renameMultiReferredPart.wsdl", ServiceInterfaceEditor.EDITOR_ID); //$NON-NLS-1$

+

+        modelDescription = modelRoot.getDescription();

+

+        final IOperation newOperation = modelDescription.getInterface("NewWSDLFile").get(0) //$NON-NLS-1$

+                .getOperation("NewOperation").get(0); //$NON-NLS-1$

+

+        theSecondOperation = modelDescription.getInterface("NewWSDLFile").get(0) //$NON-NLS-1$

+                .getOperation("NewOperation1").get(0); //$NON-NLS-1$

+

+        oldNameOfThePartInTheSecondOperation = ((List<IParameter>) theSecondOperation.getAllInputParameters()).get(1).getName();

+

+        multiReferredParameter = ((List<IParameter>) newOperation.getAllInputParameters()).get(1);

+

+        assertEquals(multiReferredParameter.getName(), oldNameOfThePartInTheSecondOperation);

+        modelRoot.getEnv().execute(new RenameParameterCommand(modelRoot, multiReferredParameter, "newNameOfTheParameter")); //$NON-NLS-1$

+

+    }

+

+    @Test

+    public void testThatNamesOfTheParametersInTheUITreeAreTheSameWhenReferToSameMessagePart() throws Exception {

+        String theNewNameOfMultiReferredPart = multiReferredParameter.getName();

+

+        assertNotSame(theNewNameOfMultiReferredPart, oldNameOfThePartInTheSecondOperation);

+

+        IParameter parameterInTheSecondOperationWhichReferToTheSamePart = ((List<IParameter>) theSecondOperation

+                .getAllInputParameters()).get(1);

+

+        assertEquals(parameterInTheSecondOperationWhichReferToTheSamePart.getName(), theNewNameOfMultiReferredPart);

+    }

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/TestUndoRedoInSourceAndEMF.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/TestUndoRedoInSourceAndEMF.java
new file mode 100644
index 0000000..784d7b5
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/TestUndoRedoInSourceAndEMF.java
@@ -0,0 +1,163 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands;

+

+import org.eclipse.core.commands.operations.IOperationHistoryListener;

+import org.eclipse.core.commands.operations.OperationHistoryEvent;

+import org.eclipse.core.resources.IFile;

+import org.eclipse.emf.common.command.AbstractCommand;

+import org.eclipse.emf.common.command.Command;

+import org.eclipse.emf.common.command.CommandStack;

+import org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl;

+import org.eclipse.ui.IWorkbenchPage;

+import org.eclipse.ui.IWorkbenchWindow;

+import org.eclipse.ui.PlatformUI;

+import org.eclipse.ui.part.FileEditorInput;

+import org.eclipse.wst.sse.core.internal.undo.StructuredTextCommandImpl;

+import org.eclipse.wst.sse.sieditor.test.util.ResourceUtils;

+import org.eclipse.wst.sse.sieditor.test.util.SIEditorBaseTest;

+import org.eclipse.wst.sse.sieditor.test.util.ThreadUtils;

+import org.junit.After;

+import org.junit.AfterClass;

+import org.junit.Before;

+import org.junit.BeforeClass;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.common.CompositeTextOperationWrapper;

+import org.eclipse.wst.sse.sieditor.core.common.ICommandStackListener;

+import org.eclipse.wst.sse.sieditor.core.common.IEnvironment;

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+import org.eclipse.wst.sse.sieditor.model.utils.StatusUtils;

+import org.eclipse.wst.sse.sieditor.ui.AbstractEditorWithSourcePage;

+import org.eclipse.wst.sse.sieditor.ui.DataTypesEditor;

+

+public class TestUndoRedoInSourceAndEMF extends SIEditorBaseTest {

+

+    AbstractEditorWithSourcePage editor = null;

+

+    @BeforeClass

+    public static void setUpBefore() {

+        StatusUtils.isUnderJunitExecution = true;

+    }

+

+    @AfterClass

+    public static void tearDownAfter() {

+        StatusUtils.isUnderJunitExecution = false;

+    }

+

+    @Override

+    @Before

+    public void setUp() throws Exception {

+        super.setUp();

+     // Flush threads that wait UI thread for execution

+        ThreadUtils.waitOutOfUI(100);

+    }

+

+    @Override

+    @After

+    public void tearDown() throws Exception {

+        if (editor != null) {

+            editor.close(false);

+        }

+        super.tearDown();

+        // Flush threads that wait UI thread for execution

+        ThreadUtils.waitOutOfUI(100);

+

+    }

+

+    @Test

+    public void testDTESourceTextCommandsAreWrappedInSIECommands() throws Exception {

+        final IFile file = ResourceUtils.copyFileIntoTestProject("pub/self/mix/po.xsd", Document_FOLDER_NAME, this.getProject(),

+                "po.xsd");

+        refreshProjectNFile(file);

+

+        final FileEditorInput eInput = new FileEditorInput(file);

+        

+        final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

+        final IWorkbenchPage workbenchActivePage = window.getActivePage();

+

+        editor = (DataTypesEditor) workbenchActivePage.openEditor(eInput, DataTypesEditor.EDITOR_ID);

+

+        final IXSDModelRoot modelRoot = (IXSDModelRoot) editor.getModelRoot();

+

+        final IEnvironment env = modelRoot.getEnv();

+        final CommandStack commandStack = env.getEditingDomain().getCommandStack();

+        

+        assertTrue(commandStack instanceof WorkspaceCommandStackImpl);

+        assertEquals(((WorkspaceCommandStackImpl)commandStack).getDefaultUndoContext(), env.getUndoContext());

+

+        testExecuteOnCommandStack(env, (WorkspaceCommandStackImpl)commandStack);

+        

+        

+    }

+

+    private void testExecuteOnCommandStack(final IEnvironment env, final WorkspaceCommandStackImpl commandStack) {

+        final boolean listenerCalled[] = {false};

+        final ICommandStackListener testListener = new ICommandStackListener() {

+

+            public void commandToBeExecuted(final Command command) {

+                listenerCalled[0] = true;

+            }

+        };

+        env.addCommandStackListener(testListener);

+

+        final boolean operationHistoryListener_called[] = {false};

+        final IOperationHistoryListener operationHistoryListener = new IOperationHistoryListener() {

+            @Override

+            public void historyNotification(final OperationHistoryEvent event) {

+                operationHistoryListener_called[0] = true;

+                assertTrue(event.getOperation() instanceof CompositeTextOperationWrapper); 

+            }

+        };

+        commandStack.getOperationHistory().addOperationHistoryListener(operationHistoryListener);

+        

+        // Assert that command stack intercept StructuredTextCommandImpl commands

+        final StructuredTextCommandImpl commandToIntercept = new StructuredTextCommandImpl() {};

+        commandStack.execute(commandToIntercept);

+        

+        assertTrue(listenerCalled[0]);

+        assertTrue(operationHistoryListener_called[0]);

+        

+        // Assert that command stack does NOT intercept other commands

+        listenerCalled[0] = false;

+        commandStack.getOperationHistory().removeOperationHistoryListener(operationHistoryListener);

+        

+        final boolean commandNotToIntercept_called[] = {false};

+        final AbstractCommand commandNotToIntercept = new AbstractCommand() {

+            

+            @Override

+            public void redo() {

+            }

+            

+            @Override

+            public void execute() {

+                commandNotToIntercept_called[0] = true;                

+            }

+

+            @Override

+            public boolean canExecute() {

+                return true;

+            }

+        };

+

+        commandStack.execute(commandNotToIntercept);

+        

+        assertFalse(listenerCalled[0]);

+        assertTrue(commandNotToIntercept_called[0]);

+    }

+

+

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/common/AbstractNewTypeCompositeCommandTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/common/AbstractNewTypeCompositeCommandTest.java
new file mode 100644
index 0000000..136627f
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/common/AbstractNewTypeCompositeCommandTest.java
@@ -0,0 +1,112 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands.common;

+

+import static org.easymock.EasyMock.createMock;

+import static org.easymock.EasyMock.expect;

+import static org.easymock.EasyMock.isA;

+import static org.easymock.EasyMock.replay;

+import static org.easymock.EasyMock.verify;

+import static org.junit.Assert.assertNull;

+import static org.junit.Assert.assertSame;

+

+import java.util.LinkedList;

+

+import org.eclipse.emf.transaction.impl.InternalTransactionalEditingDomain;

+import org.junit.Before;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.common.AbstractNotificationOperation;

+import org.eclipse.wst.sse.sieditor.command.emf.common.AbstractNewTypeCompositeCommand;

+import org.eclipse.wst.sse.sieditor.command.emf.common.setcommandbuilder.ISetTypeCommandBuilder;

+import org.eclipse.wst.sse.sieditor.core.common.IEnvironment;

+import org.eclipse.wst.sse.sieditor.model.api.IModelObject;

+import org.eclipse.wst.sse.sieditor.model.api.IXSDModelRoot;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IElement;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISchema;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.ISimpleType;

+import org.eclipse.wst.sse.sieditor.model.xsd.api.IStructureType;

+

+public abstract class AbstractNewTypeCompositeCommandTest {

+

+    protected ISetTypeCommandBuilder commandBuilder;

+    protected IXSDModelRoot modelRoot;

+    protected ISchema schema;

+    protected IModelObject modelObject;

+    protected IStructureType typeMock;

+    protected ISimpleType baseTypeMock;

+

+    private IEnvironment environment;

+    private InternalTransactionalEditingDomain editingDomain;

+

+    private AbstractNewTypeCompositeCommand command;

+    private AbstractNotificationOperation setTypeCommand;

+

+    protected static final String TYPE_NAME = "ala-bala" + System.currentTimeMillis(); //$NON-NLS-1$

+    protected static final String OPERATION_LABEL = "operation_label_" + System.currentTimeMillis(); //$NON-NLS-1$

+

+    protected AbstractNotificationOperation addOperationResult;

+

+    @Before

+    public void setUp() {

+        schema = createMock(ISchema.class);

+        modelRoot = createMock(IXSDModelRoot.class);

+        modelObject = createMock(IModelObject.class);

+        typeMock = createMock(IStructureType.class);

+        baseTypeMock = createMock(ISimpleType.class);

+

+        environment = createMock(IEnvironment.class);

+        editingDomain = createMock(InternalTransactionalEditingDomain.class);

+

+        commandBuilder = createMock(ISetTypeCommandBuilder.class);

+    }

+

+    @Test

+    public void getNextOperation() {

+        expect(schema.getModelRoot()).andReturn(modelRoot).anyTimes();

+        expect(modelRoot.getEnv()).andReturn(environment).anyTimes();

+        expect(environment.getEditingDomain()).andReturn(editingDomain).anyTimes();

+        expect(typeMock.getElements(isA(String.class))).andReturn(new LinkedList<IElement>());

+        expect(typeMock.getBaseType()).andReturn(baseTypeMock);

+        replay(schema, modelRoot, environment, typeMock);

+

+        setTypeCommand = createSetTypeCommand();

+        expect(commandBuilder.createSetTypeCommand(typeMock)).andReturn(setTypeCommand);

+

+        replay(commandBuilder);

+

+        command = createCompositeCommand();

+

+        final AbstractNotificationOperation addOperation = command.getNextOperation(null);

+

+        intermediateAsserts(command);

+

+        final AbstractNotificationOperation setOperation = command.getNextOperation(null);

+        assertSame(addOperationResult, addOperation); // test the add operation

+                                                      // here

+        assertSame(setTypeCommand, setOperation);

+

+        assertNull(command.getNextOperation(null));

+

+        verify(commandBuilder);

+    }

+

+    protected abstract AbstractNotificationOperation createSetTypeCommand();

+

+    protected abstract AbstractNewTypeCompositeCommand createCompositeCommand();

+

+    protected abstract void intermediateAsserts(AbstractNewTypeCompositeCommand command);

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/common/CompositeTextOperationWrapperNotifiesTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/common/CompositeTextOperationWrapperNotifiesTest.java
new file mode 100644
index 0000000..8a8d8ff
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/common/CompositeTextOperationWrapperNotifiesTest.java
@@ -0,0 +1,84 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands.common;

+

+import java.io.IOException;

+

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.runtime.CoreException;

+import org.eclipse.core.runtime.IAdaptable;

+import org.eclipse.core.runtime.IProgressMonitor;

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.emf.workspace.AbstractEMFOperation;

+import org.eclipse.wst.sse.sieditor.test.model.commands.AbstractCommandTest;

+

+import org.eclipse.wst.sse.sieditor.command.common.AbstractNotificationOperation;

+import org.eclipse.wst.sse.sieditor.command.common.CompositeTextOperationWrapper;

+import org.eclipse.wst.sse.sieditor.model.api.IChangeListener;

+import org.eclipse.wst.sse.sieditor.model.api.IModelChangeEvent;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+

+public class CompositeTextOperationWrapperNotifiesTest extends AbstractCommandTest {

+

+    private int changeListenerCalls = 0;

+

+    private int lastChangeListenerCalls = 0;

+

+    @Override

+    protected void assertPostRedoState(final IStatus redoStatus, final IWsdlModelRoot modelRoot) {

+        assertEquals("notifyListeners() must be called", lastChangeListenerCalls + 1, changeListenerCalls);

+        lastChangeListenerCalls = changeListenerCalls;

+    }

+

+    @Override

+    protected void assertPostUndoState(final IStatus undoStatus, final IWsdlModelRoot modelRoot) {

+

+        assertEquals("notifyListeners() must be called 2 time", lastChangeListenerCalls + 1, changeListenerCalls);

+        lastChangeListenerCalls = changeListenerCalls;

+    }

+

+    @SuppressWarnings("restriction")

+    @Override

+    protected AbstractEMFOperation getOperation(final IWsdlModelRoot modelRoot) throws Exception {

+

+        final AbstractNotificationOperation wrappedCommand = new AbstractNotificationOperation(modelRoot, modelRoot

+                .getModelObject(), "Empty Test Operation") {

+

+            @Override

+            public IStatus run(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {

+                return Status.OK_STATUS;

+            }

+

+        };

+

+        CompositeTextOperationWrapper operation = new CompositeTextOperationWrapper(wrappedCommand);

+        modelRoot.addChangeListener(new IChangeListener() {

+            @Override

+            public void componentChanged(final IModelChangeEvent event) {

+                changeListenerCalls++;

+            }

+        });

+

+        return operation;

+    }

+

+    @Override

+    protected IWsdlModelRoot getWSDLModelRoot(final String fileName, final String targetFileName) throws IOException,

+            CoreException {

+        return super.getWsdlModelRootViaDocumentProvider(fileName, targetFileName);

+    }

+

+}

diff --git a/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/common/CompositeTextOperationWrapperTest.java b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/common/CompositeTextOperationWrapperTest.java
new file mode 100644
index 0000000..eefff5d
--- /dev/null
+++ b/plugins/org.eclipse.wst.sse.sieditor.test/api/org/eclipse/wst/sse/sieditor/test/model/commands/common/CompositeTextOperationWrapperTest.java
@@ -0,0 +1,339 @@
+/*******************************************************************************

+ * Copyright (c) 2010 SAP AG.

+ * 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:

+ *    Emil Simeonov - initial API and implementation.

+ *    Dimitar Donchev - initial API and implementation.

+ *    Dimitar Tenev - initial API and implementation.

+ *    Nevena Manova - initial API and implementation.

+ *    Georgi Konstantinov - initial API and implementation.

+ *******************************************************************************/

+package org.eclipse.wst.sse.sieditor.test.model.commands.common;

+

+import static org.easymock.EasyMock.createMock;

+import static org.easymock.EasyMock.createNiceMock;

+import static org.easymock.EasyMock.expect;

+import static org.easymock.EasyMock.replay;

+import static org.easymock.EasyMock.verify;

+import static org.junit.Assert.assertEquals;

+import static org.junit.Assert.assertFalse;

+import static org.junit.Assert.assertSame;

+import static org.junit.Assert.assertTrue;

+

+import org.eclipse.core.commands.ExecutionException;

+import org.eclipse.core.runtime.IAdaptable;

+import org.eclipse.core.runtime.IProgressMonitor;

+import org.eclipse.core.runtime.IStatus;

+import org.eclipse.emf.transaction.Transaction;

+import org.eclipse.wst.xml.core.internal.document.XMLModelNotifier;

+import org.junit.Test;

+

+import org.eclipse.wst.sse.sieditor.command.common.AbstractNotificationOperation;

+import org.eclipse.wst.sse.sieditor.command.common.CompositeTextOperationWrapper;

+import org.eclipse.wst.sse.sieditor.core.common.IEnvironment;

+import org.eclipse.wst.sse.sieditor.core.common.IModelReconcileRegistry;

+import org.eclipse.wst.sse.sieditor.model.api.IModelRoot;

+import org.eclipse.wst.sse.sieditor.model.api.IWsdlModelRoot;

+import org.eclipse.wst.sse.sieditor.model.reconcile.IModelReconciler;

+import org.eclipse.wst.sse.sieditor.model.wsdl.api.IDescription;

+

+public class CompositeTextOperationWrapperTest {

+

+    private CompositeTextOperationWrapperExpose compositeOperationWrapper;

+    private IModelReconciler modelReconciler;

+

+    @Test

+    public void reconcileOnUndo() throws Exception {

+        final IModelRoot modelRoot = setUpModelRoot();

+        final AbstractNotificationOperation operationMock = createWrapperOperation(modelRoot);

+

+        // calledInPostUndoRedo[0] - basicPatchEmfModel

+        // calledInPostUndoRedo[1] - fullPatchEmfModel

+        // calledInPostUndoRedo[2] - doReconcile

+        final boolean calledInPostUndoRedo[] = { false, false, false };

+        // calledPreAndPostOfUndoRedo[0] - preUndoRedoOfCompositeCommand

+        // calledPreAndPostOfUndoRedo[1] - postUndoRedoOfCompositeCommand

+        final boolean calledPreAndPostOfUndoRedoCompositeCommand[] = { false, false };

+        compositeOperationWrapper = new CompositeTextOperationWrapperExpose(operationMock) {

+            @Override

+            public void preUndoRedoOfCompositeCommand() {

+                assertFalse("postUndoRedoOfCompositeCommand was called before preUndoRedoOfCompositeCommand",

+                        calledPreAndPostOfUndoRedoCompositeCommand[1]);

+                calledPreAndPostOfUndoRedoCompositeCommand[0] = true;

+            }

+

+            @Override

+            protected void postUndoRedoOfCompositeCommand() {

+                assertTrue("postUndoRedoOfCompositeCommand was called after preUndoRedoOfCompositeCommand",

+                        calledPreAndPostOfUndoRedoCompositeCommand[0]);

+                calledPreAndPostOfUndoRedoCompositeCommand[1] = true;

+                super.postUndoRedoOfCompositeCommand();

+            }

+

+            @Override

+            protected void fullPatchEmfModel(final IModelRoot modelRoot) {

+                assertTrue("preUndoRedoOfCompositeCommand was not called before fullPatchEmfModel",

+                        calledPreAndPostOfUndoRedoCompositeCommand[0]);

+                calledInPostUndoRedo[1] = true;

+                assertFalse("doReconcile was not called before fullPatchEmfModel", calledInPostUndoRedo[2]);

+                assertSame("operation model root should be passed for patching", modelRoot, operationMock.getModelRoot());

+            }

+

+            @Override

+            public void doReconcile() {

+                assertTrue("preUndoRedoOfCompositeCommand was not called before doReconcile",

+                        calledPreAndPostOfUndoRedoCompositeCommand[0]);

+                assertTrue("fullPatchEmfModel was not called before doReconcile", calledInPostUndoRedo[1]);

+                calledInPostUndoRedo[2] = true;

+            }

+        };

+        assertEquals(Boolean.TRUE, compositeOperationWrapper.getOptions().get(Transaction.OPTION_NO_VALIDATION));

+        compositeOperationWrapper.doUndo(null, null);

+

+        assertTrue("preUndoRedoOfCompositeCommand was not called", calledPreAndPostOfUndoRedoCompositeCommand[0]);

+        assertTrue("fullPatchEmfModel was not called", calledInPostUndoRedo[1]);

+        assertTrue("postUndoRedoOfCompositeCommand was not called", calledPreAndPostOfUndoRedoCompositeCommand[1]);

+    }

+

+    @Test

+    public void reconcileOnRedo() throws Exception {

+        final IModelRoot modelRoot = setUpModelRoot();

+        final AbstractNotificationOperation operationMock = createWrapperOperation(modelRoot);

+

+        // calledInPostUndoRedo[0] - basicPatchEmfModel

+        // calledInPostUndoRedo[1] - fullPatchEmfModel

+        // calledInPostUndoRedo[2] - doReconcile

+        final boolean calledInPostUndoRedo[] = { false, false, false };

+        // calledPreAndPostOfUndoRedo[0] - preUndoRedoOfCompositeCommand

+        // calledPreAndPostOfUndoRedo[1] - postUndoRedoOfCompositeCommand

+        final boolean calledPreAndPostOfUndoRedoCompositeCommand[] = { false, false };

+        compositeOperationWrapper = new CompositeTextOperationWrapperExpose(operationMock) {

+            @Override

+            public void preUndoRedoOfCompositeCommand() {

+                assertFalse("postUndoRedoOfCompositeCommand was called before preUndoRedoOfCompositeCommand",

+                        calledPreAndPostOfUndoRedoCompositeCommand[1]);

+                calledPreAndPostOfUndoRedoCompositeCommand[0] = true;

+            }

+

+            @Override

+            protected void postUndoRedoOfCompositeCommand() {

+                assertTrue("postUndoRedoOfCompositeCommand was called after preUndoRedoOfCompositeCommand",

+                        calledPreAndPostOfUndoRedoCompositeCommand[0]);

+                calledPreAndPostOfUndoRedoCompositeCommand[1] = true;

+                super.postUndoRedoOfCompositeCommand();

+            }

+

+            @Override

+            protected void fullPatchEmfModel(final IModelRoot modelRoot) {

+                assertTrue("preUndoRedoOfCompositeCommand was not called before fullPatchEmfModel",

+                        calledPreAndPostOfUndoRedoCompositeCommand[0]);

+                calledInPostUndoRedo[1] = true;

+                assertFalse("doReconcile was not called before fullPatchEmfModel", calledInPostUndoRedo[2]);

+                assertSame("operation model root should be passed for patching", modelRoot, operationMock.getModelRoot());

+            }

+

+            @Override

+            public void doReconcile() {

+                assertTrue("preUndoRedoOfCompositeCommand was not called before doReconcile",

+                        calledPreAndPostOfUndoRedoCompositeCommand[0]);

+                assertTrue("fullPatchEmfModel was not called before doReconcile", calledInPostUndoRedo[1]);

+                calledInPostUndoRedo[2] = true;

+            }

+

+        };

+        assertEquals(Boolean.TRUE, compositeOperationWrapper.getOptions().get(Transaction.OPTION_NO_VALIDATION));

+        compositeOperationWrapper.doRedo(null, null);

+

+        assertTrue("preUndoRedoOfCompositeCommand was not called", calledPreAndPostOfUndoRedoCompositeCommand[0]);

+        assertTrue("fullPatchEmfModel was not called", calledInPostUndoRedo[1]);

+        assertTrue("postUndoRedoOfCompositeCommand was not called", calledPreAndPostOfUndoRedoCompositeCommand[1]);

+    }

+

+    @Test

+    public void reconcileOnExecute() throws Exception {

+        final IModelRoot modelRoot = createMock(IModelRoot.class);

+        final IEnvironment environment = createMock(IEnvironment.class);

+

+        expect(modelRoot.getEnv()).andReturn(environment).anyTimes();

+        expect(environment.getEditingDomain()).andReturn(null).anyTimes();

+        environment.finalizeWrapperCommandExecution();

+        expect(environment.getCompositeTextOperationWrapper()).andReturn(null);

+        expect(modelRoot.getModelObject()).andReturn(null).anyTimes();

+        replay(modelRoot, environment);

+

+        final AbstractNotificationOperation operationMock = createWrapperOperation(modelRoot);

+

+        final boolean called[] = { false, false, false };

+        compositeOperationWrapper = new CompositeTextOperationWrapperExpose(operationMock) {

+            @Override

+            public void preUndoRedoOfCompositeCommand() {

+                assertFalse("basicPatchModel was called before preUndoRedoOfCompositeCommand", called[1]);

+                assertFalse("postUndoRedoOfCompositeCommand was called before preUndoRedoOfCompositeCommand", called[2]);

+                called[0] = true;

+            }

+

+            @Override

+            protected void basicPatchEmfModel(final IModelRoot modelRoot) {

+                assertTrue("preUndoRedoOfCompositeCommand was called before basicPatchModel", called[0]);

+                assertFalse("postUndoRedoOfCompositeCommand was called before basicPatchModel", called[2]);

+                called[1] = true;

+            }

+

+            @Override

+            public void doReconcile() {

+                assertTrue("postUndoRedoOfCompositeCommand was called before preUndoRedoOfCompositeCommand", called[0]);

+                assertTrue("postUndoRedoOfCompositeCommand was called before basicPatchModel", called[1]);

+                called[2] = true;

+            }

+        };

+

+        compositeOperationWrapper.doExecute(null, null);

+        assertEquals(Boolean.TRUE, compositeOperationWrapper.getOptions().get(Transaction.OPTION_NO_VALIDATION));

+

+        assertTrue("preUndoRedoOfCompositeCommand was not called", called[0]);

+        assertTrue("basicPatchModel was not called", called[1]);

+        assertTrue("postUndoRedoOfCompositeCommand was not called", called[2]);

+

+        verify(environment);

+    }

+

+    @Test

+    public void postUndoRedoOfCompositeCommand() {

+        final IModelReconcileRegistry modelReconcileRegistry = createNiceMock(IModelReconcileRegistry.class);