[285346] [model] WSDL editor does not remove removed annotations from Properties/Extensions tab
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingFaultImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingFaultImpl.java
index 5a15ee4..04e892c 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingFaultImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingFaultImpl.java
@@ -299,14 +299,6 @@
super.handleUnreconciledElement(child, remainingModelObjects);
}
- protected void handleReconciliation(Collection remainingModelObjects)
- {
- for (Iterator i = remainingModelObjects.iterator(); i.hasNext();)
- {
- getEExtensibilityElements().remove(i.next());
- }
- }
-
public Collection getModelObjects(Object component)
{
BindingFault bindingFault = (BindingFault)component;
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingInputImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingInputImpl.java
index 4398d1a..6c1d59b 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingInputImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingInputImpl.java
@@ -302,14 +302,6 @@
super.handleUnreconciledElement(child, remainingModelObjects);
}
- protected void handleReconciliation(Collection remainingModelObjects)
- {
- for (Iterator i = remainingModelObjects.iterator(); i.hasNext();)
- {
- getEExtensibilityElements().remove(i.next());
- }
- }
-
public Collection getModelObjects(Object component)
{
BindingInput bindingInput = (BindingInput)component;
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingOutputImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingOutputImpl.java
index 92d37b2..6f16bcb 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingOutputImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/BindingOutputImpl.java
@@ -302,14 +302,6 @@
super.handleUnreconciledElement(child, remainingModelObjects);
}
- protected void handleReconciliation(Collection remainingModelObjects)
- {
- for (Iterator i = remainingModelObjects.iterator(); i.hasNext();)
- {
- getEExtensibilityElements().remove(i.next());
- }
- }
-
public Collection getModelObjects(Object component)
{
BindingOutput bindingOutput = (BindingOutput)component;
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/ExtensibleElementImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/ExtensibleElementImpl.java
index bbf9bba..c3c05c7 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/ExtensibleElementImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/ExtensibleElementImpl.java
@@ -12,6 +12,7 @@
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -262,4 +263,22 @@
return getEnclosingDefinition() == null ? true : ((DefinitionImpl)getEnclosingDefinition()).getUseExtensionFactories();
}
+ /**
+ * Override this method if the remainingModelObjects contain elements that are not only ExtensibilityElement
+ */
+ protected void handleReconciliation(Collection remainingModelObjects)
+ {
+ super.handleReconciliation(remainingModelObjects);
+ Iterator iterator = remainingModelObjects.iterator();
+ List extensibilityElements = getExtensibilityElements();
+ while (iterator.hasNext())
+ {
+ Object modelObject = iterator.next();
+ if (modelObject instanceof ExtensibilityElement)
+ {
+ extensibilityElements.remove(modelObject);
+ }
+ }
+ }
+
} //ExtensibleElementImpl
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageImpl.java
index fa61571..f02876e 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageImpl.java
@@ -31,6 +31,7 @@
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.ExtensibilityElement;
import org.eclipse.wst.wsdl.Message;
import org.eclipse.wst.wsdl.Part;
import org.eclipse.wst.wsdl.WSDLPackage;
@@ -431,13 +432,28 @@
protected void remove(Object component, Object modelObject)
{
+ List list = getList(component, modelObject);
+ if (list != null)
+ {
+ list.remove(modelObject);
+ }
+ }
+
+ private List getList(Object component, Object modelObject)
+ {
+ List result = null;
Message message = (Message)component;
if (modelObject instanceof Part)
{
- message.getEParts().remove(modelObject);
- // message.getEParts().clear();
+ result = message.getEParts();
}
- }
+ else if (modelObject instanceof ExtensibilityElement)
+ {
+ result = getExtensibilityElements();
+ }
+
+ return result;
+ }
//
// For reconciliation: Model -> DOM
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageReferenceImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageReferenceImpl.java
index 069b0ef..1d400bb 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageReferenceImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/MessageReferenceImpl.java
@@ -267,10 +267,6 @@
super.handleUnreconciledElement(child, remainingModelObjects);
}
- protected void handleReconciliation(Collection remainingModelObjects)
- {
- }
-
//
// For reconciliation: Model -> DOM
//
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/OperationImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/OperationImpl.java
index 08afb2a..9ba8b32 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/OperationImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/OperationImpl.java
@@ -33,6 +33,7 @@
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.ExtensibilityElement;
import org.eclipse.wst.wsdl.Fault;
import org.eclipse.wst.wsdl.Input;
import org.eclipse.wst.wsdl.Operation;
@@ -913,6 +914,10 @@
{
operation.getEFaults().remove(modelObject);
}
+ else if (modelObject instanceof ExtensibilityElement)
+ {
+ getExtensibilityElements().remove(modelObject);
+ }
}
public Collection getModelObjects(Object component)
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortImpl.java
index e9be965..015eb62 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortImpl.java
@@ -298,14 +298,6 @@
super.handleUnreconciledElement(child, remainingModelObjects);
}
- protected void handleReconciliation(Collection remainingModelObjects)
- {
- for (Iterator i = remainingModelObjects.iterator(); i.hasNext();)
- {
- getEExtensibilityElements().remove(i.next());
- }
- }
-
public Collection getModelObjects(Object component)
{
Port port = (Port)component;
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortTypeImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortTypeImpl.java
index f9484dd..6805bac 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortTypeImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/PortTypeImpl.java
@@ -28,6 +28,7 @@
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;
import org.eclipse.wst.wsdl.Definition;
+import org.eclipse.wst.wsdl.ExtensibilityElement;
import org.eclipse.wst.wsdl.Operation;
import org.eclipse.wst.wsdl.PortType;
import org.eclipse.wst.wsdl.WSDLFactory;
@@ -458,6 +459,11 @@
{
result = portType.getEOperations();
}
+ else if (modelObject instanceof ExtensibilityElement)
+ {
+ result = getExtensibilityElements();
+ }
+
return result;
}
diff --git a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/TypesImpl.java b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/TypesImpl.java
index 150fa3f..feead2b 100644
--- a/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/TypesImpl.java
+++ b/bundles/org.eclipse.wst.wsdl/src-wsdl/org/eclipse/wst/wsdl/internal/impl/TypesImpl.java
@@ -170,20 +170,10 @@
protected void handleReconciliation(Collection remainingModelObjects)
{
- for (Iterator i = remainingModelObjects.iterator(); i.hasNext();)
- {
- remove(this, i.next());
- }
+ super.handleReconciliation(remainingModelObjects);
((DefinitionImpl)getEnclosingDefinition()).reconcileReferences(true);
}
- protected void remove(Object component, Object modelObject)
- {
- Types types = (Types)component;
- List list = types.getEExtensibilityElements();
- list.remove(modelObject);
- }
-
public Collection getModelObjects(Object component)
{
Types types = (Types)component;
diff --git a/tests/org.eclipse.wst.wsdl.tests/samples/BugFixes/ReconcilesExtensibleElements/ExtensibleElementSample.wsdl b/tests/org.eclipse.wst.wsdl.tests/samples/BugFixes/ReconcilesExtensibleElements/ExtensibleElementSample.wsdl
new file mode 100644
index 0000000..c936109
--- /dev/null
+++ b/tests/org.eclipse.wst.wsdl.tests/samples/BugFixes/ReconcilesExtensibleElements/ExtensibleElementSample.wsdl
@@ -0,0 +1,222 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.example.org/BindingFaultSample/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="BindingFaultSample"
+ targetNamespace="http://www.example.org/BindingFaultSample/">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ <wsdl:import namespace="" location="">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ </wsdl:import>
+ <wsdl:types>
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <xsd:schema targetNamespace="http://www.example.org/BindingFaultSample/"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="Operation1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="in" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="Operation1Response">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="out" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="Operation1Fault">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="fault" type="xsd:string" />
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="Operation2">
+ <xsd:complexType>
+ <xsd:sequence>
+
+ <xsd:element name="in" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="Operation2Response">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="out" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="Operation2Fault1">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="Operation2Fault1" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="Operation2Fault2">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="Operation2Fault2" type="xsd:string"></xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="Operation1Fault1">
+ <xsd:complexType>
+ <xsd:sequence>
+
+ <xsd:element name="Operation1Fault" type="xsd:string">
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="Operation1Request">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ <wsdl:part element="tns:Operation1" name="parameters">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ </wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="Operation1Response">
+ <wsdl:part element="tns:Operation1Response" name="parameters" />
+ </wsdl:message>
+ <wsdl:message name="Operation1Fault">
+ <wsdl:part name="Fault" element="tns:Operation1Fault" />
+ </wsdl:message>
+ <wsdl:message name="Operation2Request">
+ <wsdl:part name="parameters" element="tns:Operation2"></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="Operation2Response">
+ <wsdl:part name="parameters" element="tns:Operation2Response"></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="Operation2Fault1">
+ <wsdl:part name="parameters" element="tns:Operation2Fault1"></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="Operation2Fault2">
+ <wsdl:part name="parameters" element="tns:Operation2Fault2"></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name="Operation1Fault1">
+ <wsdl:part name="parameters" element="tns:Operation1Fault1"></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name="SamplePort">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <wsdl:operation name="Operation1">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ <wsdl:input message="tns:Operation1Request">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ </wsdl:input>
+ <wsdl:output message="tns:Operation1Response">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ </wsdl:output>
+ <wsdl:fault name="fault" message="tns:Operation1Fault1">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ </wsdl:fault>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="SamplePortSOAPBinding" type="tns:SamplePort">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http" />
+ <wsdl:operation name="Operation1">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <soap:operation
+ soapAction="http://www.example.org/BindingFaultSample/Operation1" />
+ <wsdl:input>
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <soap:body use="literal" />
+ </wsdl:input>
+ <wsdl:output>
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ <soap:body use="literal" />
+ </wsdl:output>
+ <wsdl:fault name="Operation1Fault">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <soap:fault name="Operation1Fault" />
+ </wsdl:fault>
+ </wsdl:operation>
+
+ </wsdl:binding>
+ <wsdl:service name="SampleService">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+
+ <wsdl:port binding="tns:SamplePortSOAPBinding" name="SamplePort">
+ <xsd:annotation>
+ <xsd:documentation>
+ Annotation
+ </xsd:documentation>
+ </xsd:annotation>
+ <soap:address location="http://www.example.org/" />
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java
index b1fedba..d289bf0 100644
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java
+++ b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java
@@ -37,6 +37,7 @@
import org.eclipse.wst.wsdl.BindingFault;
import org.eclipse.wst.wsdl.BindingInput;
import org.eclipse.wst.wsdl.BindingOperation;
+import org.eclipse.wst.wsdl.BindingOutput;
import org.eclipse.wst.wsdl.Definition;
import org.eclipse.wst.wsdl.ExtensibleElement;
import org.eclipse.wst.wsdl.Fault;
@@ -49,6 +50,7 @@
import org.eclipse.wst.wsdl.PortType;
import org.eclipse.wst.wsdl.Service;
import org.eclipse.wst.wsdl.Types;
+import org.eclipse.wst.wsdl.UnknownExtensibilityElement;
import org.eclipse.wst.wsdl.WSDLFactory;
import org.eclipse.wst.wsdl.WSDLPackage;
import org.eclipse.wst.wsdl.WSDLPlugin;
@@ -314,7 +316,15 @@
{
testReconcilesImportsWithNoLocation();
}
- });
+ });
+
+ suite.addTest(new BugFixesTest("ReconcilesExtensibleElements") //$NON-NLS-1$
+ {
+ protected void runTest()
+ {
+ testReconcilesExtensibleElements();
+ }
+ });
return suite;
}
@@ -1764,4 +1774,127 @@
fail();
}
}
+
+ /**
+ * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=236404
+ */
+ public void testReconcilesExtensibleElements()
+ {
+ Definition definition = null;
+
+ // The sample WSDL already has an <annotation> extensibility element for each extensible element
+ // We will loop through every extensible element and remove the annotation extensibility element
+ // and force the model to update, thus calling the reconciliation code. The expected result is that
+ // the annotation extensibility element will be removed in the model.
+ try
+ {
+ definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/ReconcilesExtensibleElements/ExtensibleElementSample.wsdl"); //$NON-NLS-1$
+ }
+ catch (IOException e)
+ {
+ fail(e.getMessage());
+ }
+
+ // Definition
+ ensureExtensibilityElementRemoved(definition, 1);
+
+ // Import
+ EList imports = definition.getEImports();
+ Import myImport = (Import) imports.get(0);
+ ensureExtensibilityElementRemoved(myImport, 1);
+
+ // Type: original is two because it has <annotation> and <schema>
+ Types types = definition.getETypes();
+ ensureExtensibilityElementRemoved(types, 2);
+
+ // Service
+ Service service = (Service)definition.getEServices().get(0);
+ ensureExtensibilityElementRemoved(service, 1);
+
+ // Port
+ org.eclipse.wst.wsdl.Port port = (org.eclipse.wst.wsdl.Port)service.getEPorts().get(0);
+ ensureExtensibilityElementRemoved(port, 2);
+
+ // Binding: original is 2 because it has <annotation> and <soap:binding>
+ Binding binding = port.getEBinding();
+ ensureExtensibilityElementRemoved(binding, 2);
+
+ // Binding Operation: original is 2 because it has <annotation> and <soap:operation>
+ List bindingOperations = binding.getBindingOperations();
+ BindingOperation bindingOperation = (BindingOperation)bindingOperations.get(0);
+ ensureExtensibilityElementRemoved(bindingOperation, 2);
+
+ // Binding Input: original is 2 because it has <annotation> and <soap:body>
+ BindingInput bindingInput = bindingOperation.getEBindingInput();
+ ensureExtensibilityElementRemoved(bindingInput, 2);
+
+ // Binding Output: original is 2 because it has <annotation> and <soap:body>
+ BindingOutput bindingOutput = bindingOperation.getEBindingOutput();
+ ensureExtensibilityElementRemoved(bindingOutput, 2);
+
+ // Binding Fault: original is 2 because it has <annotation> and <soap:fault>
+ EList bindingFaults = bindingOperation.getEBindingFaults();
+ BindingFault bindingFault = (BindingFault)bindingFaults.get(0);
+ ensureExtensibilityElementRemoved(bindingFault, 2);
+
+ // Port Type
+ PortType portType = binding.getEPortType();
+ ensureExtensibilityElementRemoved(portType, 1);
+
+ // Operation
+ EList operations = portType.getEOperations();
+ Operation operation = (Operation) operations.get(0);
+ ensureExtensibilityElementRemoved(operation, 1);
+
+ // Output
+ Output output = operation.getEOutput();
+ ensureExtensibilityElementRemoved(output, 1);
+
+ // Input
+ Input input = operation.getEInput();
+ ensureExtensibilityElementRemoved(input, 1);
+
+ // fault
+ EList faults = operation.getEFaults();
+ Fault fault = (Fault) faults.get(0);
+ ensureExtensibilityElementRemoved(fault, 1);
+
+ // Message
+ Message message = input.getEMessage();
+ ensureExtensibilityElementRemoved(message, 1);
+
+ // Part
+ EList parts = message.getEParts();
+ Part part = (Part) parts.get(0);
+ ensureExtensibilityElementRemoved(part, 1);
+ }
+
+ /**
+ * Remove the first UnknownExtensibilityElement. The expected result is original size will decrement by 1
+ */
+ private void ensureExtensibilityElementRemoved(ExtensibleElement extensibleElement, int originalSize)
+ {
+ List extensibilityElements = extensibleElement.getExtensibilityElements();
+ assertEquals(originalSize, extensibilityElements.size());
+ UnknownExtensibilityElement unknownExtensibilityElement = null;
+ Iterator extensibilityElementsIterator = extensibilityElements.iterator();
+ while (extensibilityElementsIterator.hasNext())
+ {
+ Object object = extensibilityElementsIterator.next();
+ if (object instanceof UnknownExtensibilityElement)
+ {
+ unknownExtensibilityElement = (UnknownExtensibilityElement) object;
+ break;
+ }
+ }
+
+ if (unknownExtensibilityElement == null)
+ {
+ fail("Cannot find the UnknownExtensibilityElement.");
+ }
+ Element element = unknownExtensibilityElement.getElement();
+ extensibleElement.getElement().removeChild(element);
+ extensibleElement.elementChanged(extensibleElement.getElement());
+ assertEquals(originalSize - 1, extensibilityElements.size());
+ }
}