Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.wst.wsdl.tests/src/org')
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/AllTestCases.java57
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java1971
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/InlineSchemaTest.java188
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LoadAndSerializationTest.java222
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LocationTrackingTest.java108
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/MyResolver.java35
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/ParserTest.java73
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/RefactoringTest.java206
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/SemanticTest.java486
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/UtilTest.java251
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDL4JAPITest.java387
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLEMFAPITest.java552
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLGenerationTest.java238
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLTestsPlugin.java127
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/HTTPExtensionsTest.java314
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/MIMEExtensionsTest.java208
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/SOAPExtensionsTest.java512
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/WSDLExtensionsTest.java74
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionLoader.java90
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionVisitor.java204
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDL4JDefinitionVisitor.java218
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLConverter.java598
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLModelLocatorAdapterFactory.java48
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XMLDiff.java181
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverAdapterFactory.java33
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverImpl.java33
26 files changed, 0 insertions, 7414 deletions
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/AllTestCases.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/AllTestCases.java
deleted file mode 100644
index a8dcc4c6d..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/AllTestCases.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import org.eclipse.wst.wsdl.tests.extensions.HTTPExtensionsTest;
-import org.eclipse.wst.wsdl.tests.extensions.MIMEExtensionsTest;
-import org.eclipse.wst.wsdl.tests.extensions.SOAPExtensionsTest;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-
-/**
- * @author Kihup Boo
- */
-public class AllTestCases extends TestCase
-{
-
- public AllTestCases()
- {
- }
-
- public static void main(String[] args)
- {
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(InlineSchemaTest.suite());
- suite.addTest(LoadAndSerializationTest.suite());
- suite.addTest(SemanticTest.suite());
- suite.addTest(WSDLGenerationTest.suite());
- suite.addTest(WSDL4JAPITest.suite());
- suite.addTest(WSDLEMFAPITest.suite());
- suite.addTest(UtilTest.suite());
- suite.addTest(BugFixesTest.suite());
- suite.addTest(LocationTrackingTest.suite());
- suite.addTest(RefactoringTest.suite());
- suite.addTest(SOAPExtensionsTest.suite());
- suite.addTest(HTTPExtensionsTest.suite());
- suite.addTest(MIMEExtensionsTest.suite());
-
- return suite;
- }
-}
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
deleted file mode 100644
index 715f7d86e..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java
+++ /dev/null
@@ -1,1971 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.wsdl.tests;
-
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.wsdl.OperationType;
-import javax.wsdl.Port;
-import javax.wsdl.WSDLException;
-import javax.wsdl.extensions.ExtensibilityElement;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.XMLConstants;
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.wst.wsdl.Binding;
-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;
-import org.eclipse.wst.wsdl.Import;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-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;
-import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement;
-import org.eclipse.wst.wsdl.binding.mime.MIMEContent;
-import org.eclipse.wst.wsdl.binding.mime.MIMEFactory;
-import org.eclipse.wst.wsdl.binding.mime.MIMEMimeXml;
-import org.eclipse.wst.wsdl.binding.mime.MIMEMultipartRelated;
-import org.eclipse.wst.wsdl.binding.mime.MIMEPackage;
-import org.eclipse.wst.wsdl.binding.mime.MIMEPart;
-import org.eclipse.wst.wsdl.binding.mime.internal.util.MIMEConstants;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBody;
-import org.eclipse.wst.wsdl.binding.soap.SOAPFactory;
-import org.eclipse.wst.wsdl.binding.soap.SOAPPackage;
-import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants;
-import org.eclipse.wst.wsdl.internal.util.WSDLUtil;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-/**
- * Contains unit tests for reported bugs.
- */
-public class BugFixesTest extends TestCase
-{
- private String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- public BugFixesTest(String name)
- {
- super(name);
- }
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new BugFixesTest("TypeAndElementResolution") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testTypeAndElementResolution();
- }
- });
-
- suite.addTest(new BugFixesTest("MIMEGetTypeName") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testReturnsProperQNameForMIMEExtensibilityElements();
- }
- });
-
- suite.addTest(new BugFixesTest("ImportsElementOrder") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testPlacesImportsAfterTheDefinitionElement();
- }
- });
-
- suite.addTest(new BugFixesTest("ResolveWSDLElement") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testResolvesElementInImports();
- }
- });
-
- suite.addTest(new BugFixesTest("PartsSerialization") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testSerializesPartsInSOAPBody();
- }
- });
-
- suite.addTest(new BugFixesTest("ImportsSerialization") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testSerializesImportsBeforeTypes();
- }
- });
-
- suite.addTest(new BugFixesTest("LocalNamespacePrefixes") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testSupportsLocalNamespacePrefixes();
- }
- });
-
- suite.addTest(new BugFixesTest("OperationExtensionElements") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testTolleratesExtensionElementsForOperation();
- }
- });
-
- suite.addTest(new BugFixesTest("ReconcilesBindingFaults") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testReconcilesBindingFaults();
- }
- });
-
- suite.addTest(new BugFixesTest("DuplicateSAXErrorDiagnostics") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testAvoidDuplicateSAXExceptionDiagnostics();
- }
- });
-
- suite.addTest(new BugFixesTest("BindingOperationReconciliation") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testBindingOperationReconciliation();
- }
- });
-
- suite.addTest(new BugFixesTest("FullElementExtensibility") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testFullElementExtensibility();
- }
- });
-
- suite.addTest(new BugFixesTest("TypesExtensibility") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testTypesExtensibility();
- }
- });
-
- suite.addTest(new BugFixesTest("AllowNullNamespaceURI") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testAllowNullNamespaceURI();
- }
- });
-
- suite.addTest(new BugFixesTest("LoadsNamelessDefinition") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testLoadsNamelessDefinition();
- }
- });
-
- suite.addTest(new BugFixesTest("HandlesDocumentationElements") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testHandlesDocumentationElements();
- }
- });
-
- suite.addTest(new BugFixesTest("SupportsLocalNSForExtensibilityElements") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testSupportsLocalNSForExtensibilityElements();
- }
- });
-
- suite.addTest(new BugFixesTest("InlineTypesFromImportsAreVisible") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testInlineTypesFromImportsAreVisible();
- }
- });
-
- suite.addTest(new BugFixesTest("PropagatesTargetNamespaceChange") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testPropagatesTargetNamespaceChange();
- }
- });
-
- suite.addTest(new BugFixesTest("RemoveBinding") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testRemoveBinding();
- }
- });
-
- suite.addTest(new BugFixesTest("RemoveMessage") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testRemoveMessage();
- }
- });
-
- suite.addTest(new BugFixesTest("RemovePortType") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testRemovePortType();
- }
- });
-
- suite.addTest(new BugFixesTest("RemoveService") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testRemoveService();
- }
- });
-
- suite.addTest(new BugFixesTest("GetWSDLType") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testGetWSDLType();
- }
- });
-
- suite.addTest(new BugFixesTest("InvalidXSDImports") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testInvalidXSDImports();
- }
- });
-
- suite.addTest(new BugFixesTest("ReconcileNonWSDLElements") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testReconcileNonWSDLElements();
- }
- });
-
- suite.addTest(new BugFixesTest("ReconcilesImportsWithNoLocation") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testReconcilesImportsWithNoLocation();
- }
- });
-
- suite.addTest(new BugFixesTest("ReconcilesExtensibleElements") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testReconcilesExtensibleElements();
- }
- });
-
- suite.addTest(new BugFixesTest("ImportsWithNonStandardFileExtension") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testImportsWithNonStandardFileExtension();
- }
- });
-
- return suite;
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=133310
- */
- public void testTypeAndElementResolution()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/TypeAndElementResolution/Test.wsdl"); //$NON-NLS-1$
-
- // There are two inline schemas, each importing an external schema.
- // The first schema is empty and used just to show the type resolution
- // mechanism's fault.
- // The schema containing the type and element declaration we're interested
- // in is the second schema in the collection.
-
- XSDSchema inlineSchema = (XSDSchema)definition.getETypes().getSchemas().get(1);
-
- // The first and only component in this schema is an import.
-
- XSDImport xsdImport = (XSDImport)inlineSchema.getContents().get(0);
-
- // The imported schema was resolved when the resource was loaded.
- // This is the schema containing our type/element.
-
- XSDSchema schema = xsdImport.getResolvedSchema();
-
- // Now check to make sure the resolved type/element for the messages in
- // the WSDL document
- // are the ones in the schema and not some bogus ones.
-
- Iterator messagesIterator = definition.getEMessages().iterator();
-
- while (messagesIterator.hasNext())
- {
- Message message = (Message)messagesIterator.next();
- String name = message.getQName().getLocalPart();
- if (name.equals("testRequest")) //$NON-NLS-1$
- {
- // We know there is only one part in the message and it refers to a
- // type. Make sure the type can be resolved.
-
- Part part = (Part)message.getEParts().get(0);
- XSDTypeDefinition myType = part.getTypeDefinition();
- assertEquals(schema, myType.getContainer());
- }
- else if (name.equals("testResponse")) //$NON-NLS-1$
- {
- // We know there is only one part in the message and it refers to an
- // element.
-
- Part part = (Part)message.getEParts().get(0);
- XSDElementDeclaration myElement = part.getElementDeclaration();
- assertEquals(schema, myElement.getContainer());
- }
- }
-
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=133953
- */
- public void testReturnsProperQNameForMIMEExtensibilityElements()
- {
- MIMEFactory factory = MIMEPackage.eINSTANCE.getMIMEFactory();
-
- MIMEContent content = factory.createMIMEContent();
- QName contentElementType = content.getElementType();
- assertEquals(MIMEConstants.MIME_NAMESPACE_URI, contentElementType.getNamespaceURI());
- assertEquals(MIMEConstants.CONTENT_ELEMENT_TAG, contentElementType.getLocalPart());
-
- MIMEMimeXml mimeXml = factory.createMIMEMimeXml();
- QName mimeXmlElementType = mimeXml.getElementType();
- assertEquals(MIMEConstants.MIME_NAMESPACE_URI, mimeXmlElementType.getNamespaceURI());
- assertEquals(MIMEConstants.MIME_XML_ELEMENT_TAG, mimeXmlElementType.getLocalPart());
-
- MIMEMultipartRelated multipartRelated = factory.createMIMEMultipartRelated();
- QName multipartRelatedElementType = multipartRelated.getElementType();
- assertEquals(MIMEConstants.MIME_NAMESPACE_URI, multipartRelatedElementType.getNamespaceURI());
- assertEquals(MIMEConstants.MULTIPART_RELATED_ELEMENT_TAG, multipartRelatedElementType.getLocalPart());
-
- MIMEPart part = factory.createMIMEPart();
- QName partElementType = part.getElementType();
- assertEquals(MIMEConstants.MIME_NAMESPACE_URI, partElementType.getNamespaceURI());
- assertEquals(MIMEConstants.PART_ELEMENT_TAG, partElementType.getLocalPart());
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=137040
- */
- public void testPlacesImportsAfterTheDefinitionElement()
- {
- WSDLFactory factory = WSDLPackage.eINSTANCE.getWSDLFactory();
-
- String namespace = "testNamespace"; //$NON-NLS-1$
-
- Definition definition = factory.createDefinition();
- definition.setQName(new QName(namespace, "testDefinition")); //$NON-NLS-1$
- definition.updateElement();
-
- Service service = factory.createService();
- service.setQName(new QName(namespace, "testService")); //$NON-NLS-1$
- definition.addService(service);
-
- Import wsdlImport = factory.createImport();
- definition.addImport(wsdlImport);
-
- Element definitionElement = definition.getElement();
- Element serviceElement = service.getElement();
- Element importElement = wsdlImport.getElement();
-
- NodeList definitionElementChildren = definitionElement.getChildNodes();
-
- Node firstChild = definitionElementChildren.item(0);
-
- assertSame(importElement, firstChild);
-
- Node secondChild = definitionElementChildren.item(1);
-
- assertSame(serviceElement, secondChild);
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=137866
- */
- public void testResolvesElementInImports()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/WSDLElementResolution/main.wsdl"); //$NON-NLS-1$
-
- String targetNamespace = "http://www.example.com"; //$NON-NLS-1$
-
- // This test attempts to locate a message located in the first level
- // import.
-
- QName firstLevelMessageQName = new QName(targetNamespace, "testINPUTmessage"); //$NON-NLS-1$
- javax.wsdl.Message firstLevelMessage = definition.getMessage(firstLevelMessageQName);
-
- assertNotNull(firstLevelMessage);
-
- // This test attempts to locate a message located in the second level
- // import.
-
- QName secondLevelMessageQName = new QName(targetNamespace, "testOUTPUTmessage"); //$NON-NLS-1$
- javax.wsdl.Message secondLevelMessage = definition.getMessage(secondLevelMessageQName);
-
- assertNotNull(secondLevelMessage);
-
- // This test ensures that we do a breadth first traversal to keep things
- // working approximatively as the old implementation which used to check
- // only the definition and its first level imports. The first message is
- // defined in firstlevel.wsdl as well as secondlevel.wsdl but the
- // algorithm should find the one in firstlevel.wsdl.
-
- Import firstLevelImport = (Import)definition.getImports(targetNamespace).get(0);
- Definition firstLevelDefinition = firstLevelImport.getEDefinition();
-
- assertEquals(firstLevelDefinition, ((Message)firstLevelMessage).getEnclosingDefinition());
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=137990
- */
- public void testSerializesPartsInSOAPBody()
- {
- // Build an in-memory WSDL definition.
-
- WSDLFactory factory = WSDLPackage.eINSTANCE.getWSDLFactory();
-
- String targetNamespace = "testNamespace"; //$NON-NLS-1$
-
- Definition definition = factory.createDefinition();
- definition.setTargetNamespace(targetNamespace);
- definition.setQName(new QName(targetNamespace, "testDefinition")); //$NON-NLS-1$
- definition.addNamespace("tns", targetNamespace); //$NON-NLS-1$
- definition.addNamespace("xsd", XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); //$NON-NLS-1$
- definition.addNamespace("soap", SOAPConstants.SOAP_NAMESPACE_URI); //$NON-NLS-1$
-
- Message message = factory.createMessage();
- QName messageQName = new QName(targetNamespace, "testMessage");
- message.setQName(messageQName);
- definition.addMessage(message);
-
- Part part1 = factory.createPart();
- String part1Name = "part1"; //$NON-NLS-1$
- part1.setName(part1Name);
- part1.setTypeName(new QName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string")); //$NON-NLS-1$
- message.addPart(part1);
-
- Part part2 = factory.createPart();
- String part2Name = "part2"; //$NON-NLS-1$
- part2.setName(part2Name);
- part2.setTypeName(new QName(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string")); //$NON-NLS-1$
- message.addPart(part2);
-
- PortType portType = factory.createPortType();
- QName portQName = new QName(targetNamespace, "testPort"); //$NON-NLS-1$
- portType.setQName(portQName);
- definition.addPortType(portType);
-
- Operation operation = factory.createOperation();
- String operationName = "testOperation"; //$NON-NLS-1$
- operation.setName(operationName);
- portType.addOperation(operation);
-
- Input input = factory.createInput();
- input.setMessage(message);
- operation.setInput(input);
-
- Binding binding = factory.createBinding();
- QName bindingQName = new QName(targetNamespace, "testBinding"); //$NON-NLS-1$
- binding.setQName(bindingQName);
- binding.setPortType(portType);
- definition.addBinding(binding);
-
- BindingOperation bindingOperation = factory.createBindingOperation();
- bindingOperation.setOperation(operation);
- binding.addBindingOperation(bindingOperation);
-
- BindingInput bindingInput = factory.createBindingInput();
- bindingOperation.setBindingInput(bindingInput);
-
- SOAPFactory soapFactory = SOAPPackage.eINSTANCE.getSOAPFactory();
- SOAPBody soapBody = soapFactory.createSOAPBody();
- bindingInput.addExtensibilityElement(soapBody);
-
- definition.updateElement();
-
- // Test the "no parts" scenario. In this case the parts attribute should not
- // be present.
-
- Element soapBodyElement = soapBody.getElement();
- Attr partsAttributeNode = soapBodyElement.getAttributeNode(SOAPConstants.PARTS_ATTRIBUTE);
- assertNull(partsAttributeNode);
-
- // Test the scenario when the body specifies one part. In this case the
- // parts attribute
- // should be present and look like this parts="part1"
-
- List parts = new ArrayList();
- parts.add(part1);
- soapBody.setParts(parts);
-
- soapBody.updateElement();
-
- soapBodyElement = soapBody.getElement();
- String partsAttributeValue = soapBodyElement.getAttribute(SOAPConstants.PARTS_ATTRIBUTE);
- assertEquals(part1Name, partsAttributeValue);
-
- // Test the scenario when the body specifies two parts. In this case the
- // parts attribute
- // should be present and look like this parts="part1 part2"
-
- parts.add(part2);
- soapBody.setParts(parts);
-
- soapBody.updateElement();
-
- soapBodyElement = soapBody.getElement();
- partsAttributeValue = soapBodyElement.getAttribute(SOAPConstants.PARTS_ATTRIBUTE);
- assertEquals(part1Name + " " + part2Name, partsAttributeValue); //$NON-NLS-1$
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=138033
- */
- public void testSerializesImportsBeforeTypes()
- {
- WSDLFactory factory = WSDLPackage.eINSTANCE.getWSDLFactory();
-
- String namespace = "testNamespace"; //$NON-NLS-1$
-
- Definition definition = factory.createDefinition();
- definition.setQName(new QName(namespace, "testDefinition")); //$NON-NLS-1$
- definition.updateElement();
-
- Types types = factory.createTypes();
- definition.setTypes(types);
-
- Import wsdlImport = factory.createImport();
- definition.addImport(wsdlImport);
-
- Element definitionElement = definition.getElement();
- Element typesElement = types.getElement();
- Element importElement = wsdlImport.getElement();
-
- NodeList definitionElementChildren = definitionElement.getChildNodes();
-
- Node firstChild = definitionElementChildren.item(0);
-
- assertSame(importElement, firstChild);
-
- Node secondChild = definitionElementChildren.item(1);
-
- assertSame(typesElement, secondChild);
-
- // Blow away the backing DOM.
-
- definition.setElement(null);
- definition.updateElement();
-
- definitionElement = definition.getElement();
- typesElement = types.getElement();
- importElement = wsdlImport.getElement();
-
- definitionElementChildren = definitionElement.getChildNodes();
-
- firstChild = definitionElementChildren.item(0);
-
- assertSame(importElement, firstChild);
-
- secondChild = definitionElementChildren.item(1);
-
- assertSame(typesElement, secondChild);
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=245263
- */
- public void testRemoveMessage()
- {
- try
- {
- // load a wsdl that imports another wsdl
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/WSDL4JRemove/RemoveViaWSDL4J.wsdl", true); //$NON-NLS-1$
- String targetNamespace = definition.getTargetNamespace();
- String importedTargetNamespace = "http://www.example.org/ImportMe/"; //$NON-NLS-1$
- int totalMessages = 5;
- definition.updateElement();
-
- // make sure wsdl was loaded properly
- assertEquals("Initial messages were not properly loaded (checked via definition.getMessages())", totalMessages, definition.getMessages().size()); //$NON-NLS-1$
- assertEquals("Initial messages were not properly loaded (checked via definition.getEMessages())", totalMessages, definition.getEMessages().size()); //$NON-NLS-1$
- Element definitionElement = definition.getElement();
- NodeList messageElements = definitionElement.getElementsByTagNameNS(WSDLConstants.WSDL_NAMESPACE_URI, WSDLConstants.MESSAGE_ELEMENT_TAG);
- assertEquals("Initial messages were not properly loaded (checked via DOM)", totalMessages, messageElements.getLength()); //$NON-NLS-1$
-
- // make sure message we're going to remove currently exists
- QName messageQName = new QName(targetNamespace, "RemoveViaWSDL4JMessageExtra"); //$NON-NLS-1$
- javax.wsdl.Message message = definition.getMessage(messageQName);
- assertNotNull("Unable to find RemoveViaWSDL4JMessageExtra", message); //$NON-NLS-1$
-
- // remove the message
- javax.wsdl.Message removedMessage = definition.removeMessage(messageQName);
- assertEquals("Incorrect message removed", message, removedMessage); //$NON-NLS-1$
-
- // make sure message is gone
- javax.wsdl.Message nonexistMessage = definition.getMessage(messageQName);
- assertNull("RemoveViaWSDL4JMessageExtra still exists in model", nonexistMessage); //$NON-NLS-1$
-
- // make sure there is now 1 less message
- assertEquals("Message was not removed (checked via definition.getMessages())", totalMessages-1, definition.getMessages().size()); //$NON-NLS-1$
- assertEquals("Message was not removed (checked via definition.getEMessages())", totalMessages-1, definition.getEMessages().size()); //$NON-NLS-1$
- definitionElement = definition.getElement();
- messageElements = definitionElement.getElementsByTagNameNS(WSDLConstants.WSDL_NAMESPACE_URI, WSDLConstants.MESSAGE_ELEMENT_TAG);
- assertEquals("Message was not removed (checked via DOM)", totalMessages-1, messageElements.getLength()); //$NON-NLS-1$
-
- // make sure imported message we're going to remove currently exists
- messageQName = new QName(importedTargetNamespace, "ImportMeMessageExtra"); //$NON-NLS-1$
- message = definition.getMessage(messageQName);
- assertNotNull("Unable to find ImportMeMessageExtra", message); //$NON-NLS-1$
-
- // attempt to remove the imported message
- removedMessage = definition.removeMessage(messageQName);
- assertNull("ImportMeMessageExtra was incorrectly removed", removedMessage); //$NON-NLS-1$
-
- // make sure imported message still exists
- message = definition.getMessage(messageQName);
- assertNotNull("ImportMeMessageExtra no longer exists", message); //$NON-NLS-1$
-
- nonexistMessage = definition.removeMessage(new QName(targetNamespace, "doesntexist")); //$NON-NLS-1$
- assertNull("A non-existing message was removed", nonexistMessage); //$NON-NLS-1$
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=245263
- */
- public void testRemoveService()
- {
- try
- {
- // load a wsdl that imports another wsdl
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/WSDL4JRemove/RemoveViaWSDL4J.wsdl", true); //$NON-NLS-1$
- String targetNamespace = definition.getTargetNamespace();
- String importedTargetNamespace = "http://www.example.org/ImportMe/"; //$NON-NLS-1$
- int totalServices = 2;
- definition.updateElement();
-
- // make sure wsdl was loaded properly
- assertEquals("Initial services were not properly loaded (checked via definition.getServices())", totalServices, definition.getServices().size()); //$NON-NLS-1$
- assertEquals("Initial services were not properly loaded (checked via definition.getEServices())", totalServices, definition.getEServices().size()); //$NON-NLS-1$
- Element definitionElement = definition.getElement();
- NodeList serviceElements = definitionElement.getElementsByTagNameNS(WSDLConstants.WSDL_NAMESPACE_URI, WSDLConstants.SERVICE_ELEMENT_TAG);
- assertEquals("Initial services were not properly loaded (checked via DOM)", totalServices, serviceElements.getLength()); //$NON-NLS-1$
-
- // make sure service we're going to remove currently exists
- QName serviceQName = new QName(targetNamespace, "MainServiceExtra"); //$NON-NLS-1$
- javax.wsdl.Service service = definition.getService(serviceQName);
- assertNotNull("Unable to find MainServiceExtra", service); //$NON-NLS-1$
-
- // remove the service
- javax.wsdl.Service removedService = definition.removeService(serviceQName);
- assertEquals("Incorrect service removed", service, removedService); //$NON-NLS-1$
-
- // make sure service is gone
- javax.wsdl.Service nonexistService = definition.getService(serviceQName);
- assertNull("MainServiceExtra still exists in model", nonexistService); //$NON-NLS-1$
-
- // make sure there is now 1 less service
- assertEquals("Service was not removed (checked via definition.getServices())", totalServices-1, definition.getServices().size()); //$NON-NLS-1$
- assertEquals("Service was not removed (checked via definition.getEServices())", totalServices-1, definition.getEServices().size()); //$NON-NLS-1$
- definitionElement = definition.getElement();
- serviceElements = definitionElement.getElementsByTagNameNS(WSDLConstants.WSDL_NAMESPACE_URI, WSDLConstants.SERVICE_ELEMENT_TAG);
- assertEquals("Service was not removed (checked via DOM)", totalServices-1, serviceElements.getLength()); //$NON-NLS-1$
-
- // make sure imported service we're going to remove currently exists
- serviceQName = new QName(importedTargetNamespace, "ImportServiceExtra"); //$NON-NLS-1$
- service = definition.getService(serviceQName);
- assertNotNull("Unable to find ImportServiceExtra", service); //$NON-NLS-1$
-
- // attempt to remove the imported service
- removedService = definition.removeService(serviceQName);
- assertNull("ImportServiceExtra was incorrectly removed", removedService); //$NON-NLS-1$
-
- // make sure imported service still exists
- service = definition.getService(serviceQName);
- assertNotNull("ImportServiceExtra no longer exists", service); //$NON-NLS-1$
-
- nonexistService = definition.removeService(new QName(targetNamespace, "doesntexist")); //$NON-NLS-1$
- assertNull("A non-existing service was removed", nonexistService); //$NON-NLS-1$
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=245263
- */
- public void testRemoveBinding()
- {
- try
- {
- // load a wsdl that imports another wsdl
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/WSDL4JRemove/RemoveViaWSDL4J.wsdl", true); //$NON-NLS-1$
- String targetNamespace = definition.getTargetNamespace();
- String importedTargetNamespace = "http://www.example.org/ImportMe/"; //$NON-NLS-1$
- int totalBindings = 2;
- definition.updateElement();
-
- // make sure wsdl was loaded properly
- assertEquals("Initial bindings were not properly loaded (checked via definition.getBindings())", totalBindings, definition.getBindings().size()); //$NON-NLS-1$
- assertEquals("Initial bindings were not properly loaded (checked via definition.getEBindings())", totalBindings, definition.getEBindings().size()); //$NON-NLS-1$
- Element definitionElement = definition.getElement();
- NodeList bindingElements = definitionElement.getElementsByTagNameNS(WSDLConstants.WSDL_NAMESPACE_URI, WSDLConstants.BINDING_ELEMENT_TAG);
- assertEquals("Initial bindings were not properly loaded (checked via DOM)", totalBindings, bindingElements.getLength()); //$NON-NLS-1$
-
- // make sure binding we're going to remove currently exists
- QName bindingQName = new QName(targetNamespace, "MainBindingExtra"); //$NON-NLS-1$
- javax.wsdl.Binding binding = definition.getBinding(bindingQName);
- assertNotNull("Unable to find MainBindingExtra", binding); //$NON-NLS-1$
-
- // remove the binding
- javax.wsdl.Binding removedBinding = definition.removeBinding(bindingQName);
- assertEquals("Incorrect binding removed", binding, removedBinding); //$NON-NLS-1$
-
- // make sure binding is gone
- javax.wsdl.Binding nonexistBinding = definition.getBinding(bindingQName);
- assertNull("MainBindingExtra still exists in model", nonexistBinding); //$NON-NLS-1$
-
- // make sure there is now 1 less binding
- assertEquals("Binding was not removed (checked via definition.getBindings())", totalBindings-1, definition.getBindings().size()); //$NON-NLS-1$
- assertEquals("Binding was not removed (checked via definition.getEBindings())", totalBindings-1, definition.getEBindings().size()); //$NON-NLS-1$
- definitionElement = definition.getElement();
- bindingElements = definitionElement.getElementsByTagNameNS(WSDLConstants.WSDL_NAMESPACE_URI, WSDLConstants.BINDING_ELEMENT_TAG);
- assertEquals("Binding was not removed (checked via DOM)", totalBindings-1, bindingElements.getLength()); //$NON-NLS-1$
-
- // make sure imported binding we're going to remove currently exists
- bindingQName = new QName(importedTargetNamespace, "ImportBindingExtra"); //$NON-NLS-1$
- binding = definition.getBinding(bindingQName);
- assertNotNull("Unable to find ImportBindingExtra", binding); //$NON-NLS-1$
-
- // attempt to remove the imported binding
- removedBinding = definition.removeBinding(bindingQName);
- assertNull("ImportBindingExtra was incorrectly removed", removedBinding); //$NON-NLS-1$
-
- // make sure imported binding still exists
- binding = definition.getBinding(bindingQName);
- assertNotNull("ImportBindingExtra no longer exists", binding); //$NON-NLS-1$
-
- nonexistBinding = definition.removeBinding(new QName(targetNamespace, "doesntexist")); //$NON-NLS-1$
- assertNull("A non-existing binding was removed", nonexistBinding); //$NON-NLS-1$
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=245263
- */
- public void testRemovePortType()
- {
- try
- {
- // load a wsdl that imports another wsdl
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/WSDL4JRemove/RemoveViaWSDL4J.wsdl", true); //$NON-NLS-1$
- String targetNamespace = definition.getTargetNamespace();
- String importedTargetNamespace = "http://www.example.org/ImportMe/"; //$NON-NLS-1$
- int totalPortTypes = 2;
- definition.updateElement();
-
- // make sure wsdl was loaded properly
- assertEquals("Initial port types were not properly loaded (checked via definition.getPortTypes())", totalPortTypes, definition.getPortTypes().size()); //$NON-NLS-1$
- assertEquals("Initial port types were not properly loaded (checked via definition.getEPortTypes())", totalPortTypes, definition.getEPortTypes().size()); //$NON-NLS-1$
- Element definitionElement = definition.getElement();
- NodeList portTypeElements = definitionElement.getElementsByTagNameNS(WSDLConstants.WSDL_NAMESPACE_URI, WSDLConstants.PORT_TYPE_ELEMENT_TAG);
- assertEquals("Initial port types were not properly loaded (checked via DOM)", totalPortTypes, portTypeElements.getLength()); //$NON-NLS-1$
-
- // make sure port type we're going to remove currently exists
- QName portTypeQName = new QName(targetNamespace, "MainPortTypeExtra"); //$NON-NLS-1$
- javax.wsdl.PortType portType = definition.getPortType(portTypeQName);
- assertNotNull("Unable to find MainPortTypeExtra", portType); //$NON-NLS-1$
-
- // remove the portType
- javax.wsdl.PortType removedPortType = definition.removePortType(portTypeQName);
- assertEquals("Incorrect portType removed", portType, removedPortType); //$NON-NLS-1$
-
- // make sure portType is gone
- javax.wsdl.PortType nonexistPortType = definition.getPortType(portTypeQName);
- assertNull("MainPortTypeExtra still exists in model", nonexistPortType); //$NON-NLS-1$
-
- // make sure there is now 1 less portType
- assertEquals("PortType was not removed (checked via definition.getPortTypes())", totalPortTypes-1, definition.getPortTypes().size()); //$NON-NLS-1$
- assertEquals("PortType was not removed (checked via definition.getEPortTypes())", totalPortTypes-1, definition.getEPortTypes().size()); //$NON-NLS-1$
- definitionElement = definition.getElement();
- portTypeElements = definitionElement.getElementsByTagNameNS(WSDLConstants.WSDL_NAMESPACE_URI, WSDLConstants.PORT_TYPE_ELEMENT_TAG);
- assertEquals("PortType was not removed (checked via DOM)", totalPortTypes-1, portTypeElements.getLength()); //$NON-NLS-1$
-
- // make sure imported portType we're going to remove currently exists
- portTypeQName = new QName(importedTargetNamespace, "ImportPortTypeExtra"); //$NON-NLS-1$
- portType = definition.getPortType(portTypeQName);
- assertNotNull("Unable to find ImportPortTypeExtra", portType); //$NON-NLS-1$
-
- // attempt to remove the imported portType
- removedPortType = definition.removePortType(portTypeQName);
- assertNull("ImportPortTypeExtra was incorrectly removed", removedPortType); //$NON-NLS-1$
-
- // make sure imported portType still exists
- portType = definition.getPortType(portTypeQName);
- assertNotNull("ImportPortTypeExtra no longer exists", portType); //$NON-NLS-1$
-
- nonexistPortType = definition.removePortType(new QName(targetNamespace, "doesntexist")); //$NON-NLS-1$
- assertNull("A non-existing portType was removed", nonexistPortType); //$NON-NLS-1$
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=150553
- */
- public void testSupportsLocalNamespacePrefixes()
- {
- Definition definition = null;
-
- try
- {
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/LocalNamespace/LocalNamespace.wsdl"); //$NON-NLS-1$
- }
- catch (IOException e)
- {
- fail(e.getMessage());
- }
-
- String targetNamespace = "http://tempuri.org/Simple/"; //$NON-NLS-1$
-
- // Check that the response message's part element is resolved OK.
-
- QName responseMessageQName = new QName(targetNamespace, "myOperationResponse"); ////$NON-NLS-1$
- javax.wsdl.Message responseMessage = definition.getMessage(responseMessageQName);
-
- Part responsePart = (Part)responseMessage.getPart("myOperationResponse"); ////$NON-NLS-1$
-
- XSDElementDeclaration responseElementDeclaration = responsePart.getElementDeclaration();
-
- assertNotNull(responseElementDeclaration);
- assertNotNull(responseElementDeclaration.getContainer());
-
- // Check that the request message's part element is resolved OK.
- // This part defines a local namespace prefix
-
- QName requestMessageQName = new QName(targetNamespace, "myOperationRequest"); ////$NON-NLS-1$
- javax.wsdl.Message requestMessage = definition.getMessage(requestMessageQName);
-
- Part requestPart = (Part)requestMessage.getPart("myOperationRequest"); ////$NON-NLS-1$
-
- XSDElementDeclaration requestElementDeclaration = requestPart.getElementDeclaration();
-
- assertNotNull(requestElementDeclaration);
-
- // Now to make sure the DOM is reconciled properly and uses the local namespace prefix,
- // let's try to change the part's element declaration. We'll use the response part element
- // just because it is convenient.
-
- requestPart.setElementDeclaration(responseElementDeclaration);
-
- Element partElement = requestPart.getElement();
- String elementAttributeValue = partElement.getAttribute(WSDLConstants.ELEMENT_ATTRIBUTE);
-
- assertEquals(elementAttributeValue, "parttns:" + responseElementDeclaration.getName());
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=157107
- */
- public void testTolleratesExtensionElementsForOperation()
- {
- Definition definition = null;
-
- try
- {
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/OperationStyle/OperationStyleTest.wsdl"); //$NON-NLS-1$
- }
- catch (IOException e)
- {
- fail(e.getMessage());
- }
-
- PortType portType = (PortType)definition.getEPortTypes().get(0);
- EList operations = portType.getEOperations();
-
- Operation operation = (Operation)operations.get(0);
- OperationType operationType = operation.getStyle();
-
- assertEquals(OperationType.REQUEST_RESPONSE, operationType);
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=164565
- */
- public void testReconcilesBindingFaults()
- {
- Definition definition = null;
-
- try
- {
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/BindingFaultReconciliation/BindingFaultSample.wsdl"); //$NON-NLS-1$
- }
- catch (IOException e)
- {
- fail(e.getMessage());
- }
-
- // Test the abnormal case when the binding operation tries to bind a fault
- // but the fault is missing in the corresponding operation. In this case the
- // fault obtained from the binding operation's fault should be null.
-
- List bindings = definition.getEBindings();
- Binding binding = (Binding)bindings.get(0);
- List bindingOperations = binding.getBindingOperations();
- BindingOperation bindingOperation = (BindingOperation)bindingOperations.get(0);
- BindingFault bindingFault = (BindingFault)bindingOperation.getBindingFault("Operation1Fault"); //$NON-NLS-1$
- Fault fault = bindingFault.getEFault();
- assertNull(fault);
-
- // Test the normal case when the operation and binding operation are in
- // synch. In this case the fault defined in the operation should match
- // the one obtained from the binding operation's fault.
-
- List portTypes = definition.getEPortTypes();
- PortType portType = (PortType)portTypes.get(0);
- EList operations = portType.getEOperations();
-
- Operation operation = (Operation)operations.get(1);
- javax.wsdl.Fault expectedFault1 = operation.getFault("Operation2Fault1"); //$NON-NLS-1$
- javax.wsdl.Fault expectedFault2 = operation.getFault("Operation2Fault2"); //$NON-NLS-1$
-
- BindingOperation bindingOperation2 = (BindingOperation)bindingOperations.get(1);
-
- // Make sure the fault obtained from the binding fault is not null and
- // matches the one in the corresponding operation.
-
- BindingFault bindingFault1 = (BindingFault)bindingOperation2.getBindingFault("Operation2Fault1"); //$NON-NLS-1$
- javax.wsdl.Fault actualFault1 = bindingFault1.getEFault();
- assertNotNull(actualFault1);
- assertEquals(expectedFault1, actualFault1);
-
- // Make sure the fault obtained from the binding fault is not null and
- // matches the one in the corresponding operation.
-
- BindingFault bindingFault2 = (BindingFault)bindingOperation2.getBindingFault("Operation2Fault2"); //$NON-NLS-1$
- javax.wsdl.Fault actualFault2 = bindingFault2.getEFault();
- assertNotNull(actualFault2);
- assertEquals(expectedFault2, actualFault2);
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=161059
- */
- public void testAvoidDuplicateSAXExceptionDiagnostics()
- {
- Definition definition = null;
-
- try
- {
- // Make sure we track location to allow the WSDLParser to kick in.
-
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/DuplicateSAXException/SAXException.wsdl", true, true); //$NON-NLS-1$
- }
- catch (IOException e)
- {
- fail(e.getMessage());
- }
-
- Resource resource = definition.eResource();
- EList errors = resource.getErrors();
- int expectedSize = 1;
- int actualSize = errors.size();
- assertEquals(expectedSize, actualSize);
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=172576
- */
- public void testBindingOperationReconciliation()
- {
- Definition definition = null;
-
- try
- {
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH
- + "samples/BugFixes/BindingOperationReconciliation/BindingOperationReconciliation.wsdl", true); //$NON-NLS-1$
- }
- catch (IOException e)
- {
- fail(e.getMessage());
- }
-
- String targetNamespace = "http://www.example.org/BindingOperationReconciliation/"; //$NON-NLS-1$
- QName portTypeQName = new QName(targetNamespace, "BindingOperationReconciliation"); //$NON-NLS-1$
- javax.wsdl.PortType portType = definition.getPortType(portTypeQName);
-
- String input3Name = "Input3"; //$NON-NLS-1$
- String output3Name = "Output3"; //$NON-NLS-1$
-
- // Check that the first operation - which has no named input/output is being
- // found.
-
- String operationName = "NewOperation"; //$NON-NLS-1$
- javax.wsdl.Operation operation1 = portType.getOperation(operationName, null, null);
-
- QName bindingQName = new QName(targetNamespace, "BindingOperationReconciliationSOAP"); //$NON-NLS-1$
- javax.wsdl.Binding binding = definition.getBinding(bindingQName);
-
- javax.wsdl.BindingOperation bindingOperation1 = binding.getBindingOperation(operationName, null, null);
- javax.wsdl.Operation actualOperation1 = bindingOperation1.getOperation();
-
- assertEquals(operation1, actualOperation1);
-
- // The second operation - which has no named input/output is being found
- // should not be reconciled because the binding specifies the input and
- // output.
-
- String input2Name = "Input2"; //$NON-NLS-1$
- String output2Name = "Output2"; //$NON-NLS-1$
-
- String operation2Name = "NewOperation2"; //$NON-NLS-1$
-
- javax.wsdl.BindingOperation bindingOperation2 = binding.getBindingOperation(operation2Name, input2Name, output2Name);
- javax.wsdl.Operation actualOperation2 = bindingOperation2.getOperation();
-
- assertEquals(null, actualOperation2);
-
- // The third operation specifies an input and output name, and the binding
- // operation will reconcile fine because the it also specifies the proper
- // input and output name.
-
- String operation3Name = "NewOperation3"; //$NON-NLS-1$
- javax.wsdl.Operation operation3 = portType.getOperation(operation3Name, input3Name, output3Name);
-
- javax.wsdl.BindingOperation bindingOperation3 = binding.getBindingOperation(operation3Name, input3Name, output3Name);
- javax.wsdl.Operation actualOperation3 = bindingOperation3.getOperation();
-
- assertEquals(operation3, actualOperation3);
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=177852
- */
- public void testFullElementExtensibility()
- {
-
- Definition definition = null;
-
- try
- {
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/FullElementExtensibility/ExtendedWSDL.wsdl", true); //$NON-NLS-1$
- }
- catch (IOException e)
- {
- fail(e.getMessage());
- }
-
- String extensionsNamespaceURI = "http://www.example.org/Extensions/"; //$NON-NLS-1$
- EList imports = definition.getEImports();
- assertFalse(imports.isEmpty());
- Import theImport = (Import)imports.get(0);
- checkExtension(theImport, extensionsNamespaceURI, "import"); //$NON-NLS-1$
-
- EList messages = definition.getEMessages();
- assertFalse(messages.isEmpty());
- Message message = (Message)messages.get(0);
- checkExtension(message, extensionsNamespaceURI, "message"); //$NON-NLS-1$
-
- Part part = (Part)message.getPart("extendedPart"); //$NON-NLS-1$
- assertNotNull(part);
- checkExtension(part, extensionsNamespaceURI, "part"); //$NON-NLS-1$
-
- EList portTypes = definition.getEPortTypes();
- assertFalse(portTypes.isEmpty());
- PortType portType = (PortType)portTypes.get(0);
- checkExtension(portType, extensionsNamespaceURI, "portType"); //$NON-NLS-1$
-
- Operation operation = (Operation)portType.getOperation("extendedOperation", null, null); //$NON-NLS-1$
- assertNotNull(operation);
- checkExtension(operation, extensionsNamespaceURI, "operation"); //$NON-NLS-1$
-
- Input input = operation.getEInput();
- assertNotNull(input);
- checkExtension(input, extensionsNamespaceURI, "input"); //$NON-NLS-1$
-
- Output output = operation.getEOutput();
- assertNotNull(output);
- checkExtension(output, extensionsNamespaceURI, "output"); //$NON-NLS-1$
-
- Fault fault = (Fault)operation.getFault("extendedFault"); //$NON-NLS-1$
- assertNotNull(fault);
- checkExtension(fault, extensionsNamespaceURI, "fault"); //$NON-NLS-1$
- }
-
- /**
- * Checks the given extensible element to make sure that its assumed one and only extensibility element matches the given namespace and local name.
- * @param extensibleElement the extensible element to test.
- * @param extensionsNamespaceURI the expected namespace URI.
- * @param elementName the expected element name.
- */
- private void checkExtension(ExtensibleElement extensibleElement, String extensionsNamespaceURI, String elementName)
- {
- List extensibilityElements = extensibleElement.getExtensibilityElements();
- assertFalse(extensibilityElements.isEmpty());
- ExtensibilityElement extensibilityElement = (ExtensibilityElement)extensibilityElements.get(0);
- QName elementType = extensibilityElement.getElementType();
- String nsURI = elementType.getNamespaceURI();
- String localPart = elementType.getLocalPart();
- assertEquals(extensionsNamespaceURI, nsURI);
- assertEquals(localPart, elementName);
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=174361
- */
- public void testTypesExtensibility()
- {
-
- Definition definition = null;
-
- try
- {
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/TypesExtensibility/TypesExtensibility.wsdl", true); //$NON-NLS-1$
- }
- catch (IOException e)
- {
- fail(e.getMessage());
- }
-
- Types types = definition.getETypes();
- List extensibilityElements = types.getExtensibilityElements();
- assertEquals(3, extensibilityElements.size());
-
- String otherTypesNamespace = "http://www.example.org/OtherTypes/"; //$NON-NLS-1$
-
- ExtensibilityElement extensibilityElement = (ExtensibilityElement)extensibilityElements.get(0);
- QName elementType = extensibilityElement.getElementType();
- assertEquals(otherTypesNamespace, elementType.getNamespaceURI());
- assertEquals("typeDef", elementType.getLocalPart()); //$NON-NLS-1$
-
- List schemas = types.getSchemas();
- assertEquals(1, schemas.size());
-
- XSDSchemaExtensibilityElement schemaExtensibilityElement = (XSDSchemaExtensibilityElement)extensibilityElements.get(1);
- XSDSchema schema = schemaExtensibilityElement.getSchema();
- assertNotNull(schema);
- XSDElementDeclaration elementDeclaration = schema.resolveElementDeclaration("test"); //$NON-NLS-1$
- assertNotNull(elementDeclaration);
- assertNotNull(elementDeclaration.getContainer());
-
- extensibilityElement = (ExtensibilityElement)extensibilityElements.get(2);
- elementType = extensibilityElement.getElementType();
- assertEquals(otherTypesNamespace, elementType.getNamespaceURI());
- assertEquals("typeDef", elementType.getLocalPart()); //$NON-NLS-1$
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=178555
- */
- public void testAllowNullNamespaceURI()
- {
- Definition definition = null;
-
- try
- {
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/NullNamespaceURI/ContactInfoService.wsdl", true); //$NON-NLS-1$
- }
- catch (IOException e)
- {
- fail(e.getMessage());
- }
-
- String targetNamespace = "http://www.example.org/ContactInfoService"; //$NON-NLS-1$
-
- // The element declaration for the output message part is specified in a
- // schema with no target namespace. It should resolve fine and have a null
- // namespace URI.
-
- QName output1QName = new QName(targetNamespace, "updatePhoneNumberResponseMsg"); //$NON-NLS-1$
- Message output1Message = (Message)definition.getMessage(output1QName);
- assertNotNull(output1Message);
-
- Part part1 = (Part)output1Message.getPart("output1"); //$NON-NLS-1$
- assertNotNull(part1);
-
- QName output2ElementName = part1.getElementName();
- assertNotNull(output2ElementName);
- assertEquals(XMLConstants.NULL_NS_URI, output2ElementName.getNamespaceURI());
-
- XSDElementDeclaration output2ElementDeclaration = part1.getElementDeclaration();
- assertNotNull(output2ElementDeclaration);
- assertNotNull(output2ElementDeclaration.getContainer());
- assertNull(output2ElementDeclaration.getTargetNamespace());
-
- // The type definition for the output message part is specified in a
- // schema with no target namespace. It should resolve fine and have a null
- // namespace URI.
-
- QName output2QName = new QName(targetNamespace, "updateAddressResponseMsg"); //$NON-NLS-1$
- Message output2Message = (Message)definition.getMessage(output2QName);
- assertNotNull(output2Message);
-
- Part part2 = (Part)output2Message.getPart("output2"); //$NON-NLS-1$
- assertNotNull(part1);
-
- QName output2TypeName = part2.getTypeName();
- assertNotNull(output2TypeName);
- assertEquals(XMLConstants.NULL_NS_URI, output2TypeName.getNamespaceURI());
-
- XSDTypeDefinition output2TypeDefinition = part2.getTypeDefinition();
- assertNotNull(output2TypeDefinition);
- assertNotNull(output2TypeDefinition.getContainer());
- assertNull(output2TypeDefinition.getTargetNamespace());
- }
-
- /**
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=104453
- */
- public void testLoadsNamelessDefinition()
- {
- try
- {
- //Test with nameless definition
-
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/LoadsNamelessDefinition/MissingName.wsdl");
- assertNull(definition.getQName());
-
- //Test with named definition
-
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/LoadsNamelessDefinition/WithName.wsdl");
- assertNotNull(definition);
- QName name = definition.getQName();
- assertNotNull(name);
- assertEquals("WSDLFile", name.getLocalPart());
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=151674
- * @throws Exception
- */
- public void testHandlesDocumentationElements()
- {
- try
- {
- // Load a sample WSDL document that has documentation elements in all allowed places.
-
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/HandlesDocumentationElements/Documented.wsdl");
-
- // Make sure imports are added after the documentation element.
-
- WSDLFactory factory = WSDLFactory.eINSTANCE;
- Import anImport = factory.createImport();
- anImport.setNamespaceURI("http://www.test.com");
- definition.addImport(anImport);
-
- Element definitionDocumentationElement = definition.getDocumentationElement();
- assertNotNull(definitionDocumentationElement);
- Element expectedImportElement = getNextElement(definitionDocumentationElement);
- Element importElement = anImport.getElement();
- assertEquals(importElement, expectedImportElement);
-
- // This is a bit overkill since the documentation elements are handled in the base class WSDLElementImpl but...
-
- // Make sure new message parts are added after the documentation element and as the last element.
-
- Message aMessage = (Message)definition.getEMessages().get(0);
- Part newPart = factory.createPart();
- aMessage.addPart(newPart);
-
- Element messageElement = aMessage.getElement();
-
- Element messageDocumentationElement = aMessage.getDocumentationElement();
- assertNotNull(messageDocumentationElement);
- Element firstChildElement = getFirstChildElement(messageElement);
- assertEquals(messageDocumentationElement, firstChildElement);
-
- Element partElement = newPart.getElement();
- Element lastChildElement = getLastChildElement(messageElement);
- assertEquals(partElement, lastChildElement);
-
- // Make sure new operations are added after the documentation element and as the last element.
-
- PortType portType = (PortType)definition.getEPortTypes().get(0);
- Operation newOperation = factory.createOperation();
- portType.addOperation(newOperation);
-
- Element portTypeElement = portType.getElement();
-
- Element portTypeDocumentationElement = portType.getDocumentationElement();
- assertNotNull(portTypeDocumentationElement);
- firstChildElement = getFirstChildElement(portTypeElement);
- assertEquals(portTypeDocumentationElement, firstChildElement);
-
- Element newOperationElement = newOperation.getElement();
- lastChildElement = getLastChildElement(portTypeElement);
- assertEquals(newOperationElement, lastChildElement);
-
- // Make sure the output element is added after the documentation element and as the last element.
-
- Operation operation = (Operation)portType.getEOperations().get(0);
- Output output = factory.createOutput();
- operation.setOutput(output);
-
- Element operationElement = operation.getElement();
-
- Element operationDocumentationElement = operation.getDocumentationElement();
- assertNotNull(operationDocumentationElement);
- firstChildElement = getFirstChildElement(operationElement);
- assertEquals(operationDocumentationElement, firstChildElement);
-
- Element outputElement = output.getElement();
- lastChildElement = getLastChildElement(operationElement);
- assertEquals(outputElement, lastChildElement);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=198390
- */
- public void testSupportsLocalNSForExtensibilityElements()
- {
- try
- {
- String uri = PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/LocalNamespace/LocalNamespace2.wsdl"; //$NON-NLS-1$
- javax.wsdl.factory.WSDLFactory factory = WSDLPlugin.INSTANCE.createWSDL4JFactory();
- WSDLReader wsdlReader = factory.newWSDLReader();
- javax.wsdl.Definition definition = wsdlReader.readWSDL(uri);
-
- String targetNamespace = "http://www.example.org/example/"; //$NON-NLS-1$
-
- // Test a local SOAP namespace prefix declaration.
-
- QName bindingQName = new QName(targetNamespace, "exampleSOAP"); //$NON-NLS-1$
- javax.wsdl.Binding binding = definition.getBinding(bindingQName);
- assertNotNull(binding);
- List extensibilityElements = binding.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- ExtensibilityElement soapBinding = (ExtensibilityElement)extensibilityElements.get(0);
- assertNotNull(soapBinding);
- QName bindingElementType = soapBinding.getElementType();
- assertNotNull(bindingElementType);
- String localPart = bindingElementType.getLocalPart();
- assertEquals(SOAPConstants.BINDING_ELEMENT_TAG, localPart);
- String namespaceURI = bindingElementType.getNamespaceURI();
- assertEquals(SOAPConstants.SOAP_NAMESPACE_URI, namespaceURI);
- assertTrue(soapBinding instanceof javax.wsdl.extensions.soap.SOAPBinding);
-
- // Test a default SOAP namespace declaration at the port level.
-
- QName serviceQName = new QName(targetNamespace, "example"); //$NON-NLS-1$
- javax.wsdl.Service service = definition.getService(serviceQName);
- Port port = service.getPort("exampleSOAP");
- extensibilityElements = port.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- ExtensibilityElement soapAddress = (ExtensibilityElement)extensibilityElements.get(0);
- assertNotNull(soapAddress);
- QName portElementType = soapAddress.getElementType();
- assertNotNull(portElementType);
- localPart = portElementType.getLocalPart();
- assertEquals(SOAPConstants.ADDRESS_ELEMENT_TAG, localPart);
- namespaceURI = portElementType.getNamespaceURI();
- assertEquals(SOAPConstants.SOAP_NAMESPACE_URI, namespaceURI);
- assertTrue(soapAddress instanceof javax.wsdl.extensions.soap.SOAPAddress);
- }
- catch (WSDLException e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- private Element getNextElement(Element anElement)
- {
- Node node = anElement.getNextSibling();
- while (node != null && node.getNodeType() != Node.ELEMENT_NODE)
- {
- node = node.getNextSibling();
- }
- return (Element)node;
- }
-
- private Element getFirstChildElement(Element anElement)
- {
- Node node = anElement.getFirstChild();
- while (node != null && node.getNodeType() != Node.ELEMENT_NODE)
- {
- node = node.getNextSibling();
- }
- return (Element)node;
- }
-
- private Element getLastChildElement(Element anElement)
- {
- Node node = anElement.getLastChild();
- while (node != null && node.getNodeType() != Node.ELEMENT_NODE)
- {
- node = node.getPreviousSibling();
- }
- return (Element)node;
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=208485
- */
- public void testInlineTypesFromImportsAreVisible()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/InlineTypesFromImportsAreVisible/A.wsdl"); //$NON-NLS-1$
- String targetNamespace = "http://A"; //$NON-NLS-1$
- QName messageQName = new QName(targetNamespace, "message" ); //$NON-NLS-1$
- javax.wsdl.Message message = definition.getMessage(messageQName);
- assertNotNull(message);
- Part part = (Part)message.getPart("parameters"); //$NON-NLS-1$
- assertNotNull(part);
- XSDTypeDefinition typeDefinition = part.getTypeDefinition();
- assertNotNull(typeDefinition);
- String namespace = typeDefinition.getTargetNamespace();
- assertEquals("http://B", namespace);
- assertEquals("BType", typeDefinition.getName());
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=194096
- */
- public void testPropagatesTargetNamespaceChange()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/TargetNamespace/TargetNamespace.wsdl", true); //$NON-NLS-1$
-
- String oldTargetNamespace = definition.getTargetNamespace();
-
- QName messageQName = new QName(oldTargetNamespace, "NewOperationRequest");
- javax.wsdl.Message message = definition.getMessage(messageQName);
- assertNotNull(message);
-
- QName portTypeQName = new QName(oldTargetNamespace, "TargetNamespace");
- javax.wsdl.PortType portType = definition.getPortType(portTypeQName);
- assertNotNull(portType);
-
- QName bindingQName = new QName(oldTargetNamespace, "TargetNamespaceSOAP");
- javax.wsdl.Binding binding = definition.getBinding(bindingQName);
- assertNotNull(binding);
-
- QName serviceQName = new QName(oldTargetNamespace, "TargetNamespace");
- javax.wsdl.Service service = definition.getService(serviceQName);
- assertNotNull(service);
-
- String newTargetNamespace = "http://www.example.org/NewTargetNamespace/";
- definition.setTargetNamespace(newTargetNamespace);
- Element definitionElement = definition.getElement();
- Attr targetNamespaceNode = definitionElement.getAttributeNode(WSDLConstants.TARGETNAMESPACE_ATTRIBUTE);
- assertNotNull(targetNamespaceNode);
- assertEquals(newTargetNamespace, targetNamespaceNode.getValue());
-
- messageQName = new QName(newTargetNamespace, messageQName.getLocalPart());
- message = definition.getMessage(messageQName);
- assertNotNull(message);
-
- portTypeQName = new QName(newTargetNamespace, portTypeQName.getLocalPart());
- portType = definition.getPortType(portTypeQName);
- assertNotNull(portType);
-
- bindingQName = new QName(newTargetNamespace, bindingQName.getLocalPart());
- binding = definition.getBinding(bindingQName);
- assertNotNull(binding);
-
- serviceQName = new QName(newTargetNamespace, serviceQName.getLocalPart());
- service = definition.getService(serviceQName);
- assertNotNull(service);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=247296
- */
- public void testGetWSDLType()
- {
- try
- {
- // load a wsdl
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/GetWSDLType/BadImport.wsdl", true); //$NON-NLS-1$
- definition.updateElement();
-
- // test all direct child elements of definition to make sure they are expected type
- Element definitionElement = definition.getElement();
- int type = WSDLUtil.getInstance().getWSDLType(definitionElement);
- assertEquals("Definition type incorrectly identified", WSDLConstants.DEFINITION, type); //$NON-NLS-1$
-
- NodeList childNodes = definitionElement.getChildNodes();
- Node n = childNodes.item(0);
- // skip over text node
- if (n.getNodeType() != Node.ELEMENT_NODE)
- n = n.getNextSibling();
- type = WSDLUtil.getInstance().getWSDLType((Element)n);
- assertEquals("Import type incorrectly identified", WSDLConstants.IMPORT, type); //$NON-NLS-1$
-
- n = n.getNextSibling();
- // skip over text node
- if (n.getNodeType() != Node.ELEMENT_NODE)
- n = n.getNextSibling();
- type = WSDLUtil.getInstance().getWSDLType((Element)n);
- assertEquals("xsd:import type incorrectly identified", -1, type); //$NON-NLS-1$
-
- n = n.getNextSibling();
- // skip over text node
- if (n.getNodeType() != Node.ELEMENT_NODE)
- n = n.getNextSibling();
- type = WSDLUtil.getInstance().getWSDLType((Element)n);
- assertEquals("Types type incorrectly identified", WSDLConstants.TYPES, type); //$NON-NLS-1$
-
- n = n.getNextSibling();
- // skip over text node
- if (n.getNodeType() != Node.ELEMENT_NODE)
- n = n.getNextSibling();
- type = WSDLUtil.getInstance().getWSDLType((Element)n);
- assertEquals("Message type incorrectly identified", WSDLConstants.MESSAGE, type); //$NON-NLS-1$
- n = n.getNextSibling();
-
- n = n.getNextSibling();
- // skip over text node
- if (n.getNodeType() != Node.ELEMENT_NODE)
- n = n.getNextSibling();
- type = WSDLUtil.getInstance().getWSDLType((Element)n);
- assertEquals("Message type incorrectly identified", WSDLConstants.MESSAGE, type); //$NON-NLS-1$
-
- n = n.getNextSibling();
- // skip over text node
- if (n.getNodeType() != Node.ELEMENT_NODE)
- n = n.getNextSibling();
- type = WSDLUtil.getInstance().getWSDLType((Element)n);
- assertEquals("Port type type incorrectly identified", WSDLConstants.PORT_TYPE, type); //$NON-NLS-1$
-
- n = n.getNextSibling();
- // skip over text node
- if (n.getNodeType() != Node.ELEMENT_NODE)
- n = n.getNextSibling();
- type = WSDLUtil.getInstance().getWSDLType((Element)n);
- assertEquals("Binding type incorrectly identified", WSDLConstants.BINDING, type); //$NON-NLS-1$
-
- n = n.getNextSibling();
- // skip over text node
- if (n.getNodeType() != Node.ELEMENT_NODE)
- n = n.getNextSibling();
- type = WSDLUtil.getInstance().getWSDLType((Element)n);
- assertEquals("Service type incorrectly identified", WSDLConstants.SERVICE, type); //$NON-NLS-1$
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/show_bug.cgi?id=247296
- */
- public void testInvalidXSDImports()
- {
- try
- {
- // load a wsdl that contains an xsd:import outside of wsdl:types
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/GetWSDLType/BadImport.wsdl", true); //$NON-NLS-1$
-
- // there should only be one valid wsdl:import
- Map imports = definition.getImports();
- assertEquals("Incorrect number of imports", 1, imports.size()); //$NON-NLS-1$
-
- // the bad xsd:import should be considered an extensibility element
- List extElements = definition.getExtensibilityElements();
- assertEquals("Incorrect number of extensibility elements", 1, extElements.size()); //$NON-NLS-1$
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/attachment.cgi?bugid=257279
- */
- public void testReconcileNonWSDLElements()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH +
- "samples/BugFixes/ReconcileNonWSDLElements/ReconcileNonWSDLElements.wsdl", true); //$NON-NLS-1$
-
- Definition newDefinition = WSDLFactory.eINSTANCE.createDefinition();
- assertNotNull("The new definition cannot be null",newDefinition);
-
- // The namespace in the WSDL definition is not instances of WSDLElement, it is an
- // instances of NamespaceImpl
- newDefinition.addNamespace("wsdl", "http://example.org"); //$NON-NLS-1$ //$NON-NLS-2$
- newDefinition.updateElement();
-
- Document newDocument = newDefinition.getDocument();
- assertNotNull("The new definition's document cannot be null",newDocument); //$NON-NLS-1$
- Types types = (Types)definition.getTypes();
- assertNotNull("The definition must have Types",types); //$NON-NLS-1$
- Node typesNode = (types.getElement());
- assertNotNull("The Types element cannot be null",typesNode); //$NON-NLS-1$
- Node toImport = newDocument.importNode(typesNode, true);
-
- // Append child will call org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl.elementContentsChanged(Element)
- // which changes isReconciling to true and calls
- // org.eclipse.wst.wsdl.internal.impl.WSDLElementImpl.reconcileContents(Element) and changes isReconciling to
- // false after. However, due to a ClassCast exception in reconcileContents, isReconciling is never changed to
- // false. The result is newly added WSDL elements not showing up in the EMF model.
- newDefinition.getElement().appendChild(toImport);
-
- // The bug would have set isReconciling to true and so messages will not be reconciled
- assertNotNull("The definition must have messages",definition.getMessages()); //$NON-NLS-1$
-
- Message messageToAdd = ((Message)definition.getMessage(
- new QName("http://www.example.com/ReconcileNonWSDLElements/","NewOperationRequest"))); //$NON-NLS-1$ //$NON-NLS-2$
- Node messageNode = messageToAdd.getElement();
- assertNotNull("The message to add to the new definition cannot be null",messageNode); //$NON-NLS-1$
- Node toImport2 = newDefinition.getDocument().importNode(messageNode,false);
-
- assertTrue("No messages should exist",newDefinition.getEMessages().size() == 0); //$NON-NLS-1$
- newDefinition.getElement().appendChild(toImport2);
- // The bug causes the message to be added
- assertTrue("A message should have been added", newDefinition.getEMessages().size() == 1); //$NON-NLS-1$
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-
- /**
- * See https://bugs.eclipse.org/bugs/attachment.cgi?bugid=257279
- */
- public void testReconcilesImportsWithNoLocation()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH +
- "samples/BugFixes/ReconcilesImportsWithNoLocation/Main.wsdl", true); //$NON-NLS-1$
- assertNotNull(definition);
- String targetNamespace = "http://www.example.org/B/";
- QName serviceQName = new QName(targetNamespace, "B");
- javax.wsdl.Service service = definition.getService(serviceQName);
- assertNotNull(service);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- 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());
- }
-
- public void testImportsWithNonStandardFileExtension()
- {
- String WSDL_NS = "http://www.example.org/ImportWithNonStandardWSDLFileExtension/wsdl0/"; //$NON-NLS-1$
- String XSD_NS = "http://www.example.org/NonStandardSchemaFileExtension/xsd0"; //$NON-NLS-1$
-
- try
- {
- // load a wsdl that imports another WSDL with non-standard file extension (.wsdl0) which in turn
- // imports a XSD with non-standard file extension (.xsd0)
- // ImportWithNonStandardFileExtension.wsdl also imports a XSD (NonStandardSchemaFileExtension.xsd1) using <wsdl:import>
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/BugFixes/ImportsWithNonStandardFileExtension/ImportWithNonStandardFileExtension.wsdl", true); //$NON-NLS-1$
-
- // there should only be two valid <wsdl:import>s - NonStandardWSDLFileExtension.wsdl0 and NonStandardSchemaFileExtension.xsd1
- EList imports = definition.getEImports();
- assertEquals("Incorrect number of imports", 2, imports.size()); //$NON-NLS-1$
-
-
- for (int i = 0; i < imports.size(); i++) {
- Import myImport = (Import) imports.get(i);
- assertTrue("Incorrect imported namespace", WSDL_NS.equals(myImport.getNamespaceURI()) || XSD_NS.equals(myImport.getNamespaceURI())); //$NON-NLS-1$
- if (WSDL_NS.equals(myImport.getNamespaceURI())) {
- // WSDL import: make sure the binding in the imported NonStandardWSDLFileExtension.wsdl0 is resolved
- Definition importedDefinition = myImport.getEDefinition();
- assertNotNull(importedDefinition);
- Map bindings = importedDefinition.getBindings();
- assertEquals("Incorrect number of binding elements in imported WSDL", 1, bindings.size()); //$NON-NLS-1$
-
- // Go to the resolved "NewType" complex type element and reads its testXSD0 attribute, and verify it's accessible.
- List schemas = importedDefinition.getETypes().getSchemas();
- assertEquals(1, schemas.size());
- XSDSchema schema = (XSDSchema)schemas.get(0);
- EList types = schema.getTypeDefinitions();
- assertEquals("Incorrect number of types definitions in the inline schema of the imported WSDL", 1, types.size()); //$NON-NLS-1$
- Object type = types.get(0);
- assertTrue("Not complex type", type instanceof XSDComplexTypeDefinition);
- XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) type;
- assertEquals("Incorrect name for the ComplexType imported from NonStandardSchemaFileExtension.xsd0", "NewType", complexTypeDefinition.getName()); //$NON-NLS-1$ $NON-NLS-2$
- String testAttribute = complexTypeDefinition.getElement().getAttribute("testXSD0");
- assertEquals("Incorrect test attribute for the ComplexType imported from NonStandardSchemaFileExtension.xsd0", "passed", testAttribute); //$NON-NLS-1$ $NON-NLS-2$
- } else {
- // schema import: make sure the complex type in the imported NonStandardSchemaFileExtension.xsd1 is resolved
- // Go to the resolved "ImportedTypeViaWSDLImport" complex type element and reads its testXSD1 attribute, and verify it's accessible.
- XSDSchema schema = myImport.getESchema();
- EList types = schema.getTypeDefinitions();
- assertEquals("Incorrect number of types definitions in imported XSD", 1, types.size()); //$NON-NLS-1$
-
- Object type = types.get(0);
- assertTrue("Not complex type", type instanceof XSDComplexTypeDefinition);
- XSDComplexTypeDefinition complexTypeDefinition = (XSDComplexTypeDefinition) type;
- assertEquals("Incorrect name for the ComplexType imported from NonStandardSchemaFileExtension.xsd1", "ImportedTypeViaWSDLImport", complexTypeDefinition.getName()); //$NON-NLS-1$ $NON-NLS-2$
- String testAttribute = complexTypeDefinition.getElement().getAttribute("testXSD1"); //$NON-NLS-1$
- assertEquals("Incorrect test attribute for the ComplexType imported from NonStandardSchemaFileExtension.xsd1", "passed", testAttribute); //$NON-NLS-1$ $NON-NLS-2$
- }
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- fail();
- }
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/InlineSchemaTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/InlineSchemaTest.java
deleted file mode 100644
index 157f41bda..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/InlineSchemaTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.wsdl.tests;
-
-
-import java.io.FileInputStream;
-import java.util.Iterator;
-
-import javax.wsdl.xml.WSDLReader;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Import;
-import org.eclipse.wst.wsdl.Types;
-import org.eclipse.wst.wsdl.internal.impl.wsdl4j.WSDLFactoryImpl;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDParticle;
-import org.eclipse.xsd.XSDParticleContent;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDSimpleTypeDefinition;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.xml.sax.InputSource;
-
-
-/**
- * @author Kihup Boo
- */
-public class InlineSchemaTest extends TestCase
-{
- private String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- public InlineSchemaTest(String name)
- {
- super(name);
- }
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new InlineSchemaTest("InlineSchema")
- {
- protected void runTest()
- {
- testInlineSchema();
- }
- });
-
- suite.addTest(new InlineSchemaTest("InlineSchemaWithWSDL4J")
- {
- protected void runTest()
- {
- testInlineSchemaWithWSDL4J();
- }
- });
-
- return suite;
- }
-
- public void testInlineSchema()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/LoadStoreCompare/LoadAndPrintTest.wsdl");
- traverseDefinition(definition);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- public void testInlineSchemaWithWSDL4J()
- {
- try
- {
- Definition definition = loadDefinitionForWSDL4J("samples/LoadStoreCompare/LoadAndPrintTest.wsdl");
- traverseDefinition(definition);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- public void traverseDefinition(Definition definition) throws Exception
- {
- Assert.assertNotNull(definition);
-
- Iterator iter = definition.getEImports().iterator();
- while (iter.hasNext())
- {
- Import myImport = (Import)iter.next();
- traverseImport(myImport);
- }
-
- // Get Inline Schema
- Types types = (org.eclipse.wst.wsdl.Types)definition.getTypes();
- Assert.assertNotNull("<types> is null", types);
- if (types != null)
- {
- Iterator iterator = types.getSchemas().iterator();
- Assert.assertTrue("<types> does not have inline <schema>s", iterator.hasNext());
- while (iterator.hasNext())
- {
- XSDSchema schema = (XSDSchema)iterator.next();
- traverseSchema(schema);
- }
- }
- }
-
- private void traverseImport(Import myImport) throws Exception
- {
- // Definition definition = myImport.getEDefinition();
- // traverseDefinition(definition);
- }
-
- private void traverseSchema(XSDSchema schema)
- {
- Iterator iterator = schema.getElementDeclarations().iterator();
- XSDElementDeclaration elementDecl = null;
- Assert.assertTrue("No <element>s are found", iterator.hasNext());
- while (iterator.hasNext())
- {
- elementDecl = (XSDElementDeclaration)iterator.next();
-
- if (elementDecl.getName().equals("NewOperationResponse"))
- traverseElementDecl(elementDecl);
- else if (elementDecl.getName().equals("NewOperationRequest"))
- traverseElementDecl(elementDecl);
- }
- }
-
- private void traverseElementDecl(XSDElementDeclaration elementDecl)
- {
- XSDTypeDefinition type = elementDecl.getTypeDefinition();
- Assert.assertTrue("<element> does not have <simpleType>", type instanceof XSDSimpleTypeDefinition);
- if (type.getComplexType() == null) // simple type
- return; // TBD - Currently this always returns at this point.
- XSDParticleContent content = type.getComplexType().getContent();
- traverseModelGroup((XSDModelGroup)content);
- }
-
- private void traverseModelGroup(XSDModelGroup modelGroup)
- {
- Iterator iterator = modelGroup.getContents().iterator();
- XSDParticleContent particleContent = null;
- while (iterator.hasNext())
- {
- particleContent = ((XSDParticle)iterator.next()).getContent();
- if (particleContent instanceof XSDElementDeclaration)
- {
- if (((XSDElementDeclaration)particleContent).isElementDeclarationReference())
- traverseElementDecl(((XSDElementDeclaration)particleContent).getResolvedElementDeclaration());
- else
- traverseElementDecl((XSDElementDeclaration)particleContent);
- }
- }
- }
-
- private Definition loadDefinitionForWSDL4J(String wsdlFile) throws Exception
- {
- WSDLReader reader = (new WSDLFactoryImpl()).newWSDLReader();
- String s = PLUGIN_ABSOLUTE_PATH + wsdlFile;
- Definition definition = (org.eclipse.wst.wsdl.Definition)reader.readWSDL(s, new InputSource(new FileInputStream(s)));
- return definition;
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LoadAndSerializationTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LoadAndSerializationTest.java
deleted file mode 100644
index b127ded3d..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LoadAndSerializationTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import java.io.File;
-import java.io.FileFilter;
-import java.util.Vector;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.internal.impl.DefinitionImpl;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.wst.wsdl.tests.util.XMLDiff;
-import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Kihup Boo
- */
-public class LoadAndSerializationTest extends TestCase
-{
- private String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- private Vector wsdlFiles = new Vector();
-
- static private Definition definition = null;
-
- /**
- * Executes a stand-alone test.
- * @param objects an array of Strings from the command line.
- * @see #run
- */
- public static void main(String args[])
- {
- junit.textui.TestRunner.run(suite());
- }
-
- public LoadAndSerializationTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
- suite.addTest(new LoadAndSerializationTest("LoadAndStore")
- {
- protected void runTest()
- {
- testLoadAndStore();
- }
- });
- suite.addTest // wtp bug 79326
- (new LoadAndSerializationTest("Compare")
- {
- protected void runTest()
- {
- testCompare();
- }
- });
- return suite;
- }
-
- /**
- * Load from the WSDL definitions file and store back to a different file.
- */
- public void testLoadAndStore()
- {
- String TEST_DATA_DIR = System.getProperty("testDataDir");
- //Assert.assertNotNull(testDataDir);
- File dir = null;
- if (TEST_DATA_DIR != null)
- dir = new File(TEST_DATA_DIR);
- else
- // KB: if you are here, fix text.xml
- dir = new File(PLUGIN_ABSOLUTE_PATH + "samples/LoadStoreCompare"); // fallback
-
- if (dir.exists() && dir.isDirectory())
- {
- listDataFiles(dir);
-
- try
- {
- File myFile = null;
- for (int i = 0; i < wsdlFiles.size(); i++)
- {
- myFile = (File)wsdlFiles.elementAt(i);
- System.out.println(myFile.toURL().toString());
- load(myFile.toString());
- print(myFile.toString() + ".out");
- }
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
- else
- fail(dir.toString());
-
- }
-
- private void listDataFiles(File src)
- {
- if (!src.isDirectory())
- return; // Assertion failed
-
- filterWSDLFiles(src); // Add WSDL files in the src directory
-
- File[] children = src.listFiles();
- File myFile;
- for (int i = 0; i < children.length; i++)
- {
- myFile = children[i];
- if (myFile.isDirectory())
- {
- if ("CVS".equals(myFile.getName()))
- continue;
-
- listDataFiles(myFile); // Visit sub-directories recursively
- }
- }
- }
-
- private void filterWSDLFiles(File dir)
- {
- File[] wsdls = dir.listFiles(new FileFilter()
- {
- public boolean accept(File pathname)
- {
- return pathname.getName().endsWith(".wsdl");
- }
- });
-
- for (int j = 0; j < wsdls.length; j++)
- {
- wsdlFiles.add(wsdls[j]);
- }
- }
-
- /*
- * Load from the WSDL definitions file.
- */
- private void load(String filename)
- {
- try
- {
- definition = DefinitionLoader.load(filename);
- Assert.assertNotNull(definition);
- Assert.assertTrue(definition.eResource() instanceof WSDLResourceImpl);
-
- WSDLResourceImpl wsdlResource = (WSDLResourceImpl)definition.eResource();
- Assert.assertNotNull(wsdlResource);
-
- Element element = definition.getElement();
- Assert.assertNotNull(definition.getElement());
-
- WSDLResourceImpl.serialize(System.out, element);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- /*
- * Store the WSDL definitions to a file.
- */
- private void print(String filename)
- {
- try
- {
- // This removes the associated DOM element, creates a new associated DOM element, and then prints it.
- // This is a good test for how well serialization works for a model created "bottom up".
- //
- definition.setDocument(null);
- definition.setElement(null);
- ((DefinitionImpl)definition).updateElement();
-
- DefinitionLoader.store(definition, filename);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- /**
- * Compare the output WSDL file to the original.
- */
- public void testCompare()
- {
- XMLDiff xmldiff = new XMLDiff();
- try
- {
- File myFile = null;
- for (int i = 0; i < wsdlFiles.size(); i++)
- {
- myFile = (File)wsdlFiles.elementAt(i);
- Assert.assertTrue(xmldiff.diff(myFile.toString(), myFile.toString() + ".out"));
- }
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LocationTrackingTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LocationTrackingTest.java
deleted file mode 100644
index 7e240bcba..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LocationTrackingTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.wsdl.tests;
-
-
-import java.util.List;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.Types;
-import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.wst.wsdl.util.WSDLParser;
-import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDParser;
-import org.w3c.dom.Element;
-
-
-/**
- * Test class used to validate the WSDL model source location tracking
- * mechanism.
- */
-public class LocationTrackingTest extends TestCase
-{
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
- suite.addTest(new LocationTrackingTest()
- {
- protected void runTest()
- {
- testTracksLocation();
- }
- });
- return suite;
- }
-
- /**
- * Tests the location tracking mechanism provided by the WSDL model resource
- * loader.
- *
- * @see WSDLResourceImpl
- * @see WSDLParser
- */
- public void testTracksLocation()
- {
- try
- {
- String fileName = WSDLTestsPlugin.getInstallURL() + "/samples/LoadStoreCompare/LoadAndPrintTest.wsdl"; //$NON-NLS-1$
- Definition definition = DefinitionLoader.load(fileName, true, true);
- Assert.assertNotNull(definition);
- Assert.assertTrue(definition.eResource() instanceof WSDLResourceImpl);
-
- Element definitionElement = definition.getElement();
- assertEquals(1, WSDLParser.getStartLine(definitionElement));
-
- Types types = definition.getETypes();
- Element typesElement = types.getElement();
- assertEquals(4, WSDLParser.getStartLine(typesElement));
-
- List typesExtensibilityElements = types.getEExtensibilityElements();
-
- assertEquals(1, typesExtensibilityElements.size());
-
- XSDSchemaExtensibilityElement schemaExtension = (XSDSchemaExtensibilityElement)typesExtensibilityElements.get(0);
-
- XSDSchema schema = schemaExtension.getSchema();
-
- Element schemaElement = schema.getElement();
-
- assertEquals(5, XSDParser.getStartLine(schemaElement));
-
- XSDElementDeclaration requestElementDeclaration = schema.resolveElementDeclaration("NewOperationRequest"); //$NON-NLS-1$
-
- Element requestElement = requestElementDeclaration.getElement();
-
- assertEquals(7, XSDParser.getStartLine(requestElement));
-
- List services = definition.getEServices();
- assertEquals(1, services.size());
- Service service = (Service)services.get(0);
-
- Element serviceElement = service.getElement();
- assertEquals(42, WSDLParser.getStartLine(serviceElement));
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/MyResolver.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/MyResolver.java
deleted file mode 100644
index f9974d29a..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/MyResolver.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-
-
-public class MyResolver implements EntityResolver
-{
- public InputSource resolveEntity(String publicId, String systemId)
- {
- if (systemId.equals("http://www.myhost.com/today"))
- {
- // return a special input source
- //MyReader reader = new MyReader();
- //return new InputSource(reader);
- return new InputSource(systemId); // TBD
- }
- else
- {
- // use the default behaviour
- return null;
- }
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/ParserTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/ParserTest.java
deleted file mode 100644
index 267f84a1b..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/ParserTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import java.io.FileInputStream;
-import java.io.InputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.w3c.dom.Document;
-import org.xml.sax.EntityResolver;
-
-
-public class ParserTest extends TestCase
-{
-
- public ParserTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new ParserTest("Parser")
- {
- protected void runTest()
- {
- testParser();
- }
- });
-
- return suite;
- }
-
- public void testParser()
- {
- EntityResolver myResolver = new MyResolver();
- try
- {
- InputStream is = new FileInputStream("./samples/LoadAndPrintTest.wsdl");
- DocumentBuilder myBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- myBuilder.setEntityResolver(myResolver);
- Document doc = myBuilder.parse(is);
- Assert.assertNotNull("Document is null", doc);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- public static void main(String[] args)
- {
- }
-
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/RefactoringTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/RefactoringTest.java
deleted file mode 100644
index 257941d10..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/RefactoringTest.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.WSDLFactory;
-import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-
-
-public class RefactoringTest extends TestCase
-{
- public RefactoringTest()
- {
- }
-
- public RefactoringTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new RefactoringTest("Refactoring")
- {
- protected void runTest()
- {
- testRefactoring();
- }
- });
-
- return suite;
- }
-
- public void testRefactoring()
- {
- try
- {
- // Before running this test, modify the location of the generated WSDL file
- generateWSDL(WSDLTestsPlugin.getInstallURL() +"samples/generated/RefactoringTest.wsdl");
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- // defect 6594
- public void renameOperation(Operation op)
- {
- Input input = op.getEInput();
- Assert.assertNotNull(input);
- Message message = input.getEMessage();
- Assert.assertNotNull(message);
-
- op.setName("Renamed" + op.getName());
- QName newQName = new QName(message.getQName().getNamespaceURI(), "Renamed" + message.getQName().getLocalPart());
- message.setQName(newQName);
- }
-
- public void generateWSDL(String outputFile) throws Exception
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.createResource(URI.createFileURI(outputFile));
- resourceSet.getResources().add(resource);
-
- // Create a Definition - Temperature
- Definition definition = WSDLFactory.eINSTANCE.createDefinition();
- definition.setQName(new QName(WSDLConstants.WSDL_NAMESPACE_URI, "Temperature"));
- resource.getContents().add(definition);
-
- // Target namespace - http://www.temperature.com
- definition.setTargetNamespace("http://www.temperature.com");
- definition.addNamespace("tns", "http://www.temperature.com");
-
- // Other namespaces - wsdl, soap, xsd
- definition.addNamespace("wsdl", WSDLConstants.WSDL_NAMESPACE_URI);
- definition.addNamespace("xsd", WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001);
- definition.addNamespace("soap", SOAPConstants.SOAP_NAMESPACE_URI);
-
- //
- // Let's start building two messages
- //
-
- // Create a Part - ZipCode
- Part part = WSDLFactory.eINSTANCE.createPart();
- part.setName("ZipCode");
- part.setTypeName(new QName(WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string"));
-
- // Create a Message - GetTemperatureInput
- Message inputMessage = WSDLFactory.eINSTANCE.createMessage();
- inputMessage.setQName(new QName(definition.getTargetNamespace(), "GetTemperatureInput"));
- inputMessage.addPart(part);
- definition.addMessage(inputMessage);
-
- // Create a Part - Temperature
- part = WSDLFactory.eINSTANCE.createPart();
- part.setName("Temperature");
- part.setTypeName(new QName(WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "float"));
-
- // Create a Message - GetTemperatureOutput
- Message outputMessage = WSDLFactory.eINSTANCE.createMessage();
- outputMessage.setQName(new QName(definition.getTargetNamespace(), "GetTemperatureOutput"));
- outputMessage.addPart(part);
- definition.addMessage(outputMessage);
-
- //
- // Next, build a PortType
- //
-
- // Create an Input - GetTemperatureInput
- Input input = WSDLFactory.eINSTANCE.createInput();
- input.setMessage(inputMessage);
-
- // Create an Output - GetTemperatureOutput
- Output output = WSDLFactory.eINSTANCE.createOutput();
- output.setMessage(outputMessage);
-
- // Create an Operation - GetTemperatureForZipCode
- Operation operation = WSDLFactory.eINSTANCE.createOperation();
- operation.setName("GetTemperatureForZipCode");
- operation.setInput(input);
- operation.setOutput(output);
-
- // Create a PortType
- PortType portType = WSDLFactory.eINSTANCE.createPortType();
- portType.setQName(new QName(definition.getTargetNamespace(), "GetTemperatureInfoSOAP"));
- portType.addOperation(operation);
- definition.addPortType(portType);
-
- //
- // Create the second set op Operations
- //
-
- // Create a Part
- part = WSDLFactory.eINSTANCE.createPart();
- part.setName("Part2");
- part.setTypeName(new QName(WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string"));
-
- // Create a Message
- Message inputMessage2 = WSDLFactory.eINSTANCE.createMessage();
- inputMessage2.setQName(new QName(definition.getTargetNamespace(), "InputMessage2"));
- inputMessage2.addPart(part);
- definition.addMessage(inputMessage2);
-
- // Create a Part
- part = WSDLFactory.eINSTANCE.createPart();
- part.setName("Part3");
- part.setTypeName(new QName(WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "float"));
-
- // Create a Message - GetTemperatureOutput
- Message outputMessage2 = WSDLFactory.eINSTANCE.createMessage();
- outputMessage2.setQName(new QName(definition.getTargetNamespace(), "OutputMessage2"));
- outputMessage2.addPart(part);
- definition.addMessage(outputMessage2);
-
- // Create an Input
- Input input2 = WSDLFactory.eINSTANCE.createInput();
- input2.setMessage(inputMessage2);
-
- // Create an Output - GetTemperatureOutput
- Output output2 = WSDLFactory.eINSTANCE.createOutput();
- output2.setMessage(outputMessage2);
-
- // Create an Operation - GetTemperatureForZipCode
- Operation operation2 = WSDLFactory.eINSTANCE.createOperation();
- operation2.setName("Operation2");
- operation2.setInput(input2);
- operation2.setOutput(output2);
-
- portType.addOperation(operation2);
-
- renameOperation(operation);
- renameOperation(operation2);
-
- resource.save(null);
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/SemanticTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/SemanticTest.java
deleted file mode 100644
index bf35c7b4b..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/SemanticTest.java
+++ /dev/null
@@ -1,486 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import java.util.Iterator;
-
-import javax.wsdl.OperationType;
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.wst.wsdl.Binding;
-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.ExtensibilityElement;
-import org.eclipse.wst.wsdl.ExtensibleElement;
-import org.eclipse.wst.wsdl.Fault;
-import org.eclipse.wst.wsdl.Import;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.Types;
-import org.eclipse.wst.wsdl.binding.soap.SOAPAddress;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBinding;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBody;
-import org.eclipse.wst.wsdl.binding.soap.SOAPOperation;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.wst.wsdl.tests.util.DefinitionVisitor;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Kihup Boo
- */
-public class SemanticTest extends DefinitionVisitor
-{
- private String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- // Added for JUnit
- public SemanticTest(String name)
- {
- super(name);
- }
-
- /**
- * @param definition
- */
- public SemanticTest(Definition definition)
- {
- super(definition);
- }
-
- /*
- private void serialize(String filename) throws Exception
- {
- Source domSource = new DOMSource(doc);
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT,"yes");
- transformer.setOutputProperty(OutputKeys.ENCODING,"UTF-8");
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount","4");
- transformer.transform(domSource,new StreamResult(new FileOutputStream(filename)));
- }
-
- private void createDocument() throws ParserConfigurationException
- {
- doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- }
-
- private Element createWSDLElement(String name)
- {
- Element element = doc.createElementNS("http://www.w3.org/2004/08/wsdl",name);
- if (wsdlNamespacePrefix != null)
- element.setPrefix(wsdlNamespacePrefix);
-
- return element;
- }
- */
- private void visitDocumentation(Element docElement)
- {
- if (docElement == null)
- return;
- println("documentation: " + docElement); // TBD - serialize docElement
- }
-
- private void println(String s)
- {
- System.out.println(s);
- }
-
- protected void visitDefinition(Definition def)
- {
- println("Visiting definitions...");
- visitDocumentation(def.getDocumentationElement());
-
- QName qname = def.getQName();
- if (qname != null)
- println("name: " + qname.getLocalPart());
-
- String targetNamespace = def.getTargetNamespace();
- if (targetNamespace != null)
- println("targetNamespace: " + targetNamespace);
-
- Iterator iterator = def.getNamespaces().keySet().iterator();
- String prefix = null;
- String namespace = null;
-
- while (iterator.hasNext())
- {
- prefix = (String)iterator.next();
- namespace = def.getNamespace(prefix);
- println("namespace prefix: " + prefix + ", namespace URI: " + namespace);
- }
- super.visitDefinition(def);
- println("Leaving definitions...");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitImport(org.eclipse.wst.wsdl.Import)
- */
- protected void visitImport(Import wsdlImport)
- {
- println("Visiting import...");
- // Determine if we <import> a schema.
- if (importingSchema(wsdlImport))
- {
- println("<import>ing XML Schema");
-
- // <xs:import namespace="http://foo.com" schemaLocation= "bar.xsd"/>
- println("namespace: " + wsdlImport.getNamespaceURI());
- println("schemaLocation: " + wsdlImport.getLocationURI());
- visitDocumentation(wsdlImport.getDocumentationElement());
- }
- else
- {
- println("<import>ing WSDL");
- visitDocumentation(wsdlImport.getDocumentationElement());
- }
- println("Leaving import...");
- }
-
- private boolean importingSchema(Import myImport)
- {
- if (myImport.getDefinition() != null) // it is WSDL import
- return false;
- else
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitTypes(org.eclipse.wst.wsdl.Types)
- */
- protected void visitTypes(Types types)
- {
- println("Visiting types...");
-
- Iterator iterator = types.getSchemas().iterator();
- XSDSchema schema = null;
- while (iterator.hasNext())
- {
- schema = (XSDSchema)iterator.next();
- println("in-line schema: " + schema);
- }
- println("Leaving types...");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitPart(org.eclipse.wst.wsdl.Part)
- */
- protected void visitPart(Part part)
- {
- println("Visiting part...");
- }
-
- protected void visitPortType(PortType portType)
- {
- println("Visiting portType...");
- visitDocumentation(portType.getDocumentationElement());
-
- QName qname = portType.getQName();
- if (qname != null)
- println("name: " + qname.getLocalPart());
-
- super.visitPortType(portType);
- println("Leaving portType...");
- }
-
- protected void visitOperation(Operation operation)
- {
- println("Visiting operation...");
- visitDocumentation(operation.getDocumentationElement());
-
- String name = operation.getName();
- if (name != null)
- println("name: " + name);
-
- OperationType opType = operation.getStyle();
- Assert.assertNotNull("Failed determining Operation Type", opType);
-
- if (OperationType.REQUEST_RESPONSE == opType)
- println("op type: " + "in-out");
- else if (OperationType.SOLICIT_RESPONSE == opType)
- println("op type" + "out-in");
- else if (OperationType.NOTIFICATION == opType)
- println("op type" + "out-only");
- else if (OperationType.ONE_WAY == opType)
- println("op type" + "in-only");
-
- super.visitOperation(operation);
- println("Leaving operation...");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitInput(org.eclipse.wst.wsdl.Input)
- */
- protected void visitInput(Input input)
- {
- println("Visiting input...");
- visitDocumentation(input.getDocumentationElement());
-
- String name = input.getName();
- if (name != null)
- println("name: " + name);
-
- Message message = input.getEMessage();
- Assert.assertNotNull("Failed to resolve the message", message);
-
- println("Leaving input...");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitOutput(org.eclipse.wst.wsdl.Output)
- */
- protected void visitOutput(Output output)
- {
- println("Visiting output...");
- visitDocumentation(output.getDocumentationElement());
-
- String name = output.getName();
- if (name != null)
- println("name: " + name);
-
- Message message = output.getEMessage();
- Assert.assertNotNull("Failed to resolve the message", message);
-
- println("Leaving output...");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitFault(org.eclipse.wst.wsdl.Fault)
- */
- protected void visitFault(Fault fault)
- {
- println("Visiting fault...");
- println("Leaving fault...");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitBinding(org.eclipse.wst.wsdl.Binding)
- */
- protected void visitBinding(Binding binding)
- {
- println("Visiting binding...");
- visitDocumentation(binding.getDocumentationElement());
-
- QName qname = binding.getQName();
- if (qname != null)
- println("name: " + qname.getLocalPart());
-
- PortType portType = binding.getEPortType();
- Assert.assertNotNull("Failed to resolve the portType", portType);
-
- super.visitBinding(binding);
- Assert.assertTrue("<soapBody> is missing", soapBodyVisited);
- Assert.assertTrue("<soapBinding> is missing", soapBindingVisited);
- Assert.assertTrue("<soapOperation> is missing", soapOperationVisited);
- println("Leaving binding...");
- }
-
- protected void visitBindingOperation(BindingOperation bindingOperation)
- {
- println("Visiting binding operation...");
- visitDocumentation(bindingOperation.getDocumentationElement());
-
- Operation operation = bindingOperation.getEOperation();
- Assert.assertNotNull("Failed to resolve the operation", operation);
-
- if (operation != null)
- {
- String operationName = operation.getName();
- println("name: " + operationName);
- }
-
- super.visitBindingOperation(bindingOperation);
- println("Leaving binding operation...");
- }
-
- protected void visitBindingInput(BindingInput input)
- {
- println("Visiting binding input...");
- visitDocumentation(input.getDocumentationElement());
-
- String inputName = input.getName();
- if (inputName != null)
- println("name: " + inputName);
-
- super.visitBindingInput(input);
- println("Leaving binding input...");
- }
-
- protected void visitBindingOutput(BindingOutput output)
- {
- println("Visiting binding output...");
- visitDocumentation(output.getDocumentationElement());
-
- String outputName = output.getName();
- if (outputName != null)
- println("name: " + outputName);
-
- super.visitBindingOutput(output);
- println("Leaving binding output...");
- }
-
- protected void visitBindingFault(BindingFault fault)
- {
- println("Visiting binding fault...");
- visitDocumentation(fault.getDocumentationElement());
-
- Element faultElement = fault.getElement();
- String faultName = fault.getName();
- if (faultName != null)
- faultElement.setAttribute("name", faultName);
-
- super.visitBindingFault(fault);
- println("Leaving binding fault...");
- }
-
- protected void visitService(Service service)
- {
- println("Visiting service...");
- visitDocumentation(service.getDocumentationElement());
-
- QName qname = service.getQName();
- Assert.assertNotNull("Validation Error: service is missing the name attribute", qname);
- if (qname != null)
- println("name: " + qname.getLocalPart());
-
- super.visitService(service);
- println("Leaving service...");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitPort(org.eclipse.wst.wsdl.Port)
- */
- protected void visitPort(Port port)
- {
- println("Visiting port...");
- visitDocumentation(port.getDocumentationElement());
-
- String name = port.getName();
- Assert.assertNotNull("Validation Error: port is missing the name attribute", port);
- if (name != null)
- println("name: " + port.getName());
-
- Binding binding = port.getEBinding();
- Assert.assertNotNull("Failed to resolve the binding", binding);
-
- super.visitPort(port);
- Assert.assertTrue("<soapAddress> is missing", soapAddressVisited);
- println("Leaving port...");
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitExtensibilityElement(org.eclipse.wst.wsdl.ExtensibleElement, org.eclipse.wst.wsdl.ExtensibilityElement)
- */
- protected void visitExtensibilityElement(ExtensibleElement owner, ExtensibilityElement extensibilityElement)
- {
- println("Visiting extensibility element...");
- if (extensibilityElement instanceof SOAPBody)
- visitSOAPBody((SOAPBody)extensibilityElement);
- else if (extensibilityElement instanceof SOAPBinding)
- visitSOAPBinding((SOAPBinding)extensibilityElement);
- else if (extensibilityElement instanceof SOAPAddress)
- visitSOAPAddress((SOAPAddress)extensibilityElement);
- else if (extensibilityElement instanceof SOAPOperation)
- visitSOAPOperation((SOAPOperation)extensibilityElement);
- println("Leaving extensibility element...");
- }
-
- //Needs to improve this part
- private boolean soapOperationVisited = false;
-
- private void visitSOAPOperation(SOAPOperation soapOperation)
- {
- soapOperationVisited = true;
- println("Visiting SOAPOperation...");
- println("soapAction: " + soapOperation.getSoapActionURI());
- println("Leaving SOAPOperation...");
- }
-
- //Needs to improve this part
- private boolean soapBodyVisited = false;
-
- private void visitSOAPBody(SOAPBody soapBody)
- {
- soapBodyVisited = true;
- println("Visiting SOAPBody...");
- println("use: " + soapBody.getUse());
- println("Leaving SOAPBody...");
- }
-
- //Needs to improve this part
- private boolean soapBindingVisited = false;
-
- private void visitSOAPBinding(SOAPBinding soapBinding)
- {
- soapBindingVisited = true;
- println("Visiting SOAPBinding...");
- println("style: " + soapBinding.getStyle());
- println("transport: " + soapBinding.getTransportURI());
- println("Leaving SOAPBinding...");
- }
-
- // Needs to improve this part
- private boolean soapAddressVisited = false;
-
- private void visitSOAPAddress(SOAPAddress soapAddress)
- {
- soapAddressVisited = true;
- println("Visiting SOAPAddress...");
- println("location: " + soapAddress.getLocationURI());
- println("Leaving SOAPAddress...");
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new SemanticTest("ModelSemanticTest")
- {
- protected void runTest()
- {
- testModelSemantic();
- }
- });
- return suite;
- }
-
- public void testModelSemantic()
- {
- try
- {
- Definition def = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/LoadStoreCompare/LoadAndPrintTest.wsdl", true);
- SemanticTest test = new SemanticTest(def);
- test.visit();
- }
- catch (Exception e)
- {
- Assert.fail(e.toString());
- }
- }
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(suite());
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/UtilTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/UtilTest.java
deleted file mode 100644
index 87784552a..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/UtilTest.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.ExtensibilityElement;
-import org.eclipse.wst.wsdl.WSDLPlugin;
-import org.eclipse.wst.wsdl.binding.soap.SOAPHeader;
-import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants;
-import org.eclipse.wst.wsdl.internal.impl.ExtensibilityElementImpl;
-import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.wst.wsdl.util.ExtensibilityElementFactory;
-import org.eclipse.wst.wsdl.util.ExtensibilityElementFactoryRegistry;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-public class UtilTest extends TestCase
-{
- private String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- public UtilTest(String name)
- {
- super(name);
- }
-
- public static void main(String args[])
- {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new UtilTest("WSDLConstants")
- {
- protected void runTest()
- {
- testConstants();
- }
- });
-
- suite.addTest(new UtilTest("WSDLResourceFactoryImpl")
- {
- protected void runTest()
- {
- testWSDLResourceFactoryImpl();
- }
- });
-
- suite.addTest(new UtilTest("WSDLResourceImpl")
- {
- protected void runTest()
- {
- testWSDLResourceImpl();
- }
- });
- suite.addTest(new UtilTest("ExtensibilityElementFactory")
- {
- protected void runTest()
- {
- testExtensibilityElementFactory();
- }
- });
- suite.addTest(new UtilTest("ExtensibilityElementFactoryRegistry")
- {
- protected void runTest()
- {
- testExtensibilityElementFactoryRegistry();
- }
- });
-
- return suite;
- }
-
- static private Definition definition = null;
-
- public void testConstants()
- {
- try
- {
- int type = WSDLConstants.nodeType(WSDLConstants.PORT_ELEMENT_TAG);
- Assert.assertTrue("Node type is not that of port", type == 10);
-
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/LoadStoreCompare/LoadAndPrintTest.wsdl");
- Assert.assertTrue(definition.eResource() instanceof WSDLResourceImpl);
-
- int definitionNodeType = WSDLConstants.nodeType(definition.getElement());
- Assert.assertTrue("Node type is not that of definition", definitionNodeType == 1);
-
- boolean isWSDLNamespace = WSDLConstants.isWSDLNamespace(definition.getTargetNamespace());
- Assert.assertFalse("This should not be the WSDL Namespace", isWSDLNamespace);
-
- boolean isMatching = WSDLConstants.isMatchingNamespace("http://www.example.org", "http://www.example.org");
- Assert.assertTrue("isMatchingNamespace is incorrect", isMatching);
-
- String attr = WSDLConstants.getAttribute(definition.getElement(), "name");
- Assert.assertTrue("getAttribute is incorrect", attr.equals("LoadAndPrintTest"));
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- public void testWSDLResourceFactoryImpl()
- {
- try
- {
- WSDLResourceFactoryImpl factoryImpl = new WSDLResourceFactoryImpl();
- Resource resource = factoryImpl.createResource(URI.createFileURI("./samples/createResourceTest.wsdl"));
- Assert.assertTrue("Resource is not of type WSDLResourceImpl", resource instanceof WSDLResourceImpl);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- public void testWSDLResourceImpl()
- {
- try
- {
- WSDLResourceImpl resourceImpl = new WSDLResourceImpl(URI.createFileURI("./samples/createResourceTest.wsdl"));
- Assert.assertTrue("Resource is not of type WSDLResourceImpl", resourceImpl instanceof WSDLResourceImpl);
-
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/LoadStoreCompare/LoadAndPrintTest.wsdl");
- Assert.assertTrue(definition.eResource() instanceof WSDLResourceImpl);
- Element element = definition.getElement();
- Document document = definition.getDocument();
-
- if (element != null)
- {
- WSDLResourceImpl.serialize(System.out, element, null);
- }
-
- if (document != null)
- {
- WSDLResourceImpl.serialize(System.out, document, null);
- }
-
- try
- {
- resourceImpl.attached(definition);
- }
- catch (Exception e)
- {
-
- }
-
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- public void testExtensibilityElementFactory()
- {
- try
- {
- ExtensibilityElementFactory factory = WSDLPlugin.INSTANCE.getExtensibilityElementFactory(SOAPConstants.SOAP_NAMESPACE_URI);
- if (factory != null)
- {
- ExtensibilityElement ee = factory.createExtensibilityElement(SOAPConstants.SOAP_NAMESPACE_URI, SOAPConstants.HEADER_ELEMENT_TAG);
- Assert.assertTrue("Problem creating SOAP extensibility element", ee instanceof SOAPHeader);
- }
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- class TestExtensibilityElement extends ExtensibilityElementImpl implements ExtensibilityElement
- {
- String ns, name;
-
- public TestExtensibilityElement(String ns, String name)
- {
- super();
- this.ns = ns;
- this.name = name;
- }
-
- public QName getElementType()
- {
- if (elementType == null)
- {
- elementType = new QName(ns, name);
- }
- return elementType;
- }
- }
-
- class WSDLTestFactory implements ExtensibilityElementFactory
- {
- public WSDLTestFactory()
- {
- }
-
- public ExtensibilityElement createExtensibilityElement(String namespace, String localName)
- {
- return new TestExtensibilityElement(namespace, localName);
- }
- }
-
- public void testExtensibilityElementFactoryRegistry()
- {
- try
- {
- ExtensibilityElementFactoryRegistry factoryRegistry = WSDLPlugin.INSTANCE.getExtensibilityElementFactoryRegistry();
- factoryRegistry.registerFactory("http://org.eclipse.wst.wsdl.tests", new WSDLTestFactory());
-
- ExtensibilityElementFactory factory = WSDLPlugin.INSTANCE.getExtensibilityElementFactory("http://org.eclipse.wst.wsdl.tests");
- ExtensibilityElement ee = factory.createExtensibilityElement("http://org.eclipse.wst.wsdl.tests", "TestElement");
- Assert.assertTrue("1. Problem creating custom Test extensibility element", ee instanceof TestExtensibilityElement);
- Assert.assertTrue("2. Problem creating custom Test extensibility element", ee.getElementType().getLocalPart().equals("TestElement"));
- Assert.assertTrue("3. Problem creating custom Test extensibility element", ee.getElementType().getNamespaceURI().equals(
- "http://org.eclipse.wst.wsdl.tests"));
-
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDL4JAPITest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDL4JAPITest.java
deleted file mode 100644
index 2adac7539..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDL4JAPITest.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import java.io.FileInputStream;
-import java.util.Iterator;
-
-import javax.wsdl.Binding;
-import javax.wsdl.BindingFault;
-import javax.wsdl.BindingInput;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.BindingOutput;
-import javax.wsdl.Definition;
-import javax.wsdl.Fault;
-import javax.wsdl.Import;
-import javax.wsdl.Input;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Output;
-import javax.wsdl.Part;
-import javax.wsdl.Port;
-import javax.wsdl.PortType;
-import javax.wsdl.Service;
-import javax.wsdl.Types;
-import javax.wsdl.extensions.ExtensibilityElement;
-import javax.wsdl.extensions.soap.SOAPAddress;
-import javax.wsdl.extensions.soap.SOAPBinding;
-import javax.wsdl.extensions.soap.SOAPBody;
-import javax.wsdl.extensions.soap.SOAPOperation;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.wst.wsdl.WSDLPlugin;
-import org.eclipse.wst.wsdl.tests.util.WSDL4JDefinitionVisitor;
-import org.xml.sax.InputSource;
-
-
-/**
- * @author Kihup Boo
- */
-public class WSDL4JAPITest extends WSDL4JDefinitionVisitor
-{
- private static String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- private WSDLFactory factory = WSDLPlugin.INSTANCE.createWSDL4JFactory();
-
- private Definition newDefinition;
-
- private Message currentMessage;
-
- private Service currentService;
-
- private PortType currentPortType;
-
- private Operation currentOperation;
-
- private Binding currentBinding;
-
- private BindingOperation currentBindingOperation;
-
- // Added for JUnit
- public WSDL4JAPITest(String name)
- {
- super(name);
- }
-
- /**
- * @param definition
- */
- public WSDL4JAPITest(Definition definition)
- {
- super(definition);
- }
-
- private void println(String s)
- {
- System.out.println(s);
- }
-
- protected void visitDefinition(Definition def)
- {
- newDefinition = factory.newDefinition();
- newDefinition.setDocumentationElement(def.getDocumentationElement());
- newDefinition.setQName(def.getQName());
- newDefinition.setTargetNamespace(def.getTargetNamespace());
- newDefinition.setDocumentBaseURI(def.getDocumentBaseURI());
-
- Iterator iterator = def.getNamespaces().keySet().iterator();
- String prefix = null;
- String namespace = null;
-
- while (iterator.hasNext())
- {
- prefix = (String)iterator.next();
- namespace = def.getNamespace(prefix);
- newDefinition.addNamespace(prefix, namespace);
- }
-
- super.visitDefinition(def);
- }
-
- protected void visitImport(Import wsdlImport)
- {
- Import myImport = newDefinition.createImport();
- newDefinition.addImport(myImport);
-
- // e.g. <xs:import namespace="http://foo.com" schemaLocation= "bar.xsd"/>
- myImport.setNamespaceURI(wsdlImport.getNamespaceURI());
- myImport.setLocationURI(wsdlImport.getLocationURI());
- myImport.setDocumentationElement(wsdlImport.getDocumentationElement());
-
- myImport.setDefinition(newDefinition);
- }
-
- protected void visitTypes(Types types)
- {
- Types myTypes = newDefinition.createTypes();
- myTypes.setDocumentationElement(types.getDocumentationElement());
-
- /*
- Iterator iterator = types.getExtensibilityElements().iterator();
- ExtensibilityElement extensibilitElement = null;
- while (iterator.hasNext())
- {
- extensibilitElement = (ExtensibilityElement)iterator.next();
- myTypes.addExtensibilityElement(extensibilitElement);
- }*/
- newDefinition.setTypes(myTypes);
- }
-
- protected void visitPart(Part part)
- {
- Part myPart = newDefinition.createPart();
- myPart.setDocumentationElement(part.getDocumentationElement());
- myPart.setName(part.getName());
- myPart.setElementName(part.getElementName());
- myPart.setTypeName(part.getTypeName());
-
- Iterator iterator = part.getExtensionAttributes().keySet().iterator();
- QName key = null;
- QName value = null;
- while (iterator.hasNext())
- {
- key = (QName)iterator.next();
- value = (QName)part.getExtensionAttribute(key);
- myPart.setExtensionAttribute(key, value);
- }
- currentMessage.addPart(myPart);
- }
-
- protected void visitMessage(Message message)
- {
- currentMessage = newDefinition.createMessage();
- super.visitMessage(message);
- }
-
- protected void visitPortType(PortType portType)
- {
- currentPortType = newDefinition.createPortType();
- currentPortType.setDocumentationElement(portType.getDocumentationElement());
- currentPortType.setQName(portType.getQName());
- currentPortType.setUndefined(portType.isUndefined());
- newDefinition.addPortType(currentPortType);
-
- super.visitPortType(portType);
- }
-
- protected void visitOperation(Operation operation)
- {
- currentOperation = newDefinition.createOperation();
- currentOperation.setDocumentationElement(operation.getDocumentationElement());
- currentOperation.setName(operation.getName());
- currentOperation.setStyle(operation.getStyle());
- currentOperation.setUndefined(operation.isUndefined());
- currentOperation.setParameterOrdering(operation.getParameterOrdering());
- currentPortType.addOperation(currentOperation);
-
- super.visitOperation(operation);
- }
-
- protected void visitInput(Input input)
- {
- Input myInput = newDefinition.createInput();
- myInput.setDocumentationElement(input.getDocumentationElement());
- myInput.setName(input.getName());
- myInput.setMessage(input.getMessage());
- currentOperation.setInput(myInput);
- }
-
- protected void visitOutput(Output output)
- {
- Output myOutput = newDefinition.createOutput();
- myOutput.setDocumentationElement(output.getDocumentationElement());
- myOutput.setName(output.getName());
- myOutput.setMessage(output.getMessage());
- currentOperation.setOutput(myOutput);
- }
-
- protected void visitFault(Fault fault)
- {
- Fault myFault = newDefinition.createFault();
- myFault.setDocumentationElement(fault.getDocumentationElement());
- myFault.setName(fault.getName());
- myFault.setMessage(fault.getMessage());
- currentOperation.addFault(myFault);
- }
-
- protected void visitBinding(Binding binding)
- {
- currentBinding = newDefinition.createBinding();
- newDefinition.addBinding(currentBinding);
-
- currentBinding.setDocumentationElement(binding.getDocumentationElement());
- currentBinding.setQName(binding.getQName());
- currentBinding.setPortType(binding.getPortType());
- currentBinding.setUndefined(binding.isUndefined());
-
- super.visitBinding(binding);
- }
-
- protected void visitBindingOperation(BindingOperation bindingOperation)
- {
- currentBindingOperation = newDefinition.createBindingOperation();
- currentBindingOperation.setDocumentationElement(bindingOperation.getDocumentationElement());
- currentBindingOperation.setOperation(bindingOperation.getOperation());
- currentBindingOperation.setName(bindingOperation.getName());
- currentBinding.addBindingOperation(currentBindingOperation);
-
- super.visitBindingOperation(bindingOperation);
- }
-
- protected void visitBindingInput(BindingInput input)
- {
- BindingInput myInput = newDefinition.createBindingInput();
- myInput.setDocumentationElement(input.getDocumentationElement());
- myInput.setName(input.getName());
- currentBindingOperation.setBindingInput(myInput);
-
- super.visitBindingInput(input);
- }
-
- protected void visitBindingOutput(BindingOutput output)
- {
- BindingOutput myOutput = newDefinition.createBindingOutput();
- myOutput.setDocumentationElement(output.getDocumentationElement());
- myOutput.setName(output.getName());
- currentBindingOperation.setBindingOutput(myOutput);
-
- super.visitBindingOutput(output);
- }
-
- protected void visitBindingFault(BindingFault fault)
- {
- BindingFault myFault = newDefinition.createBindingFault();
- myFault.setDocumentationElement(fault.getDocumentationElement());
- myFault.setName(fault.getName());
- currentBindingOperation.addBindingFault(myFault);
-
- super.visitBindingFault(fault);
- }
-
- protected void visitService(Service service)
- {
- currentService = newDefinition.createService();
- currentService.setDocumentationElement(service.getDocumentationElement());
- currentService.setQName(service.getQName());
- newDefinition.addService(currentService);
-
- super.visitService(service);
- }
-
- protected void visitPort(Port port)
- {
- Port myPort = newDefinition.createPort();
- myPort.setDocumentationElement(port.getDocumentationElement());
- myPort.setName(port.getName());
- myPort.setBinding(port.getBinding());
- currentService.addPort(myPort);
-
- super.visitPort(port);
- }
-
- protected void visitExtensibilityElement(ExtensibilityElement extensibilityElement)
- {
- if (extensibilityElement instanceof SOAPBody)
- visitSOAPBody((SOAPBody)extensibilityElement);
- else if (extensibilityElement instanceof SOAPBinding)
- visitSOAPBinding((SOAPBinding)extensibilityElement);
- else if (extensibilityElement instanceof SOAPAddress)
- visitSOAPAddress((SOAPAddress)extensibilityElement);
- else if (extensibilityElement instanceof SOAPOperation)
- visitSOAPOperation((SOAPOperation)extensibilityElement);
- }
-
- private void visitSOAPOperation(SOAPOperation soapOperation)
- {
- println("Visiting SOAPOperation...");
- println("soapAction: " + soapOperation.getSoapActionURI());
- println("Leaving SOAPOperation...");
- }
-
- private void visitSOAPBody(SOAPBody soapBody)
- {
- println("Visiting SOAPBody...");
- println("use: " + soapBody.getUse());
- println("Leaving SOAPBody...");
- }
-
- private void visitSOAPBinding(SOAPBinding soapBinding)
- {
- println("Visiting SOAPBinding...");
- println("style: " + soapBinding.getStyle());
- println("transport: " + soapBinding.getTransportURI());
- println("Leaving SOAPBinding...");
- }
-
- private void visitSOAPAddress(SOAPAddress soapAddress)
- {
- println("Visiting SOAPAddress...");
- println("location: " + soapAddress.getLocationURI());
- println("Leaving SOAPAddress...");
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new WSDL4JAPITest("ModelSemanticTest")
- {
- protected void runTest()
- {
- testModelSemantic();
- }
- });
- return suite;
- }
-
- public void testModelSemantic()
- {
- try
- {
- Definition def = loadDefinitionForWSDL4J("./samples/LoadStoreCompare/LoadAndPrintTest.wsdl");
- WSDL4JAPITest test = new WSDL4JAPITest(def);
- test.visit();
- serialize(test.newDefinition, "./samples/ClonedLoadAndPrintTest.wsdl");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- Assert.fail(e.toString());
- }
- }
-
- private void serialize(Definition definition, String clonedFile) throws Exception
- {
- // WSDLWriter writer = factory.newWSDLWriter();
- // String s = PLUGIN_ABSOLUTE_PATH + clonedFile;
- // writer.writeWSDL(definition, new FileOutputStream(s));
- }
-
- private Definition loadDefinitionForWSDL4J(String wsdlFile) throws Exception
- {
- WSDLReader reader = factory.newWSDLReader();
- String s = PLUGIN_ABSOLUTE_PATH + wsdlFile;
- Definition definition = reader.readWSDL(s, new InputSource(new FileInputStream(s)));
- return definition;
- }
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(suite());
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLEMFAPITest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLEMFAPITest.java
deleted file mode 100644
index 66ac5c768..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLEMFAPITest.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import java.util.Iterator;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.wst.wsdl.Binding;
-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.ExtensibilityElement;
-import org.eclipse.wst.wsdl.ExtensibleElement;
-import org.eclipse.wst.wsdl.Fault;
-import org.eclipse.wst.wsdl.Import;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.MessageReference;
-import org.eclipse.wst.wsdl.Namespace;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-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.WSDLElement;
-import org.eclipse.wst.wsdl.WSDLFactory;
-import org.eclipse.wst.wsdl.WSDLPlugin;
-import org.eclipse.wst.wsdl.XSDSchemaExtensibilityElement;
-import org.eclipse.wst.wsdl.binding.soap.SOAPAddress;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBinding;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBody;
-import org.eclipse.wst.wsdl.binding.soap.SOAPFactory;
-import org.eclipse.wst.wsdl.binding.soap.SOAPFault;
-import org.eclipse.wst.wsdl.binding.soap.SOAPHeader;
-import org.eclipse.wst.wsdl.binding.soap.SOAPHeaderBase;
-import org.eclipse.wst.wsdl.binding.soap.SOAPHeaderFault;
-import org.eclipse.wst.wsdl.binding.soap.SOAPOperation;
-import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.wst.wsdl.tests.util.DefinitionVisitor;
-import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
-
-
-/**
- * @author Kihup Boo
- */
-public class WSDLEMFAPITest extends DefinitionVisitor
-{
- private String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- private WSDLFactory factory = WSDLFactory.eINSTANCE;
-
- Definition newDefinition;
-
- private Message currentMessage;
-
- private Service currentService;
-
- private PortType currentPortType;
-
- private Operation currentOperation;
-
- private Binding currentBinding;
-
- private BindingOperation currentBindingOperation;
-
- private ExtensibleElement currentExtensibleElement;
-
- // Added for JUnit
- public WSDLEMFAPITest(String name)
- {
- super(name);
- }
-
- /**
- * @param definition
- */
- public WSDLEMFAPITest(Definition definition)
- {
- super(definition);
- }
-
- protected void visitDefinition(Definition def)
- {
- // Use WSDLElement to increase the API coverage in the reports
- WSDLElement root = factory.createDefinition();
- newDefinition = (Definition)root;
-
- root.setDocumentationElement(def.getDocumentationElement());
- root.getDocumentationElement();
- root.setEnclosingDefinition(newDefinition);
- root.getEnclosingDefinition();
- root.getContainer();
-
- newDefinition.setQName(def.getQName());
- newDefinition.setTargetNamespace(def.getTargetNamespace());
- newDefinition.setDocumentBaseURI(def.getDocumentBaseURI());
- newDefinition.setLocation(def.getLocation());
- newDefinition.setEncoding(def.getEncoding());
-
- // getENamespaces does not work.
- Iterator iterator = def.getENamespaces().iterator();
- Namespace ns = null;
- String prefix = null;
- String uri = null;
- while (iterator.hasNext())
- {
- ns = factory.createNamespace();
- prefix = ((Namespace)iterator.next()).getPrefix();
- uri = ((Namespace)iterator.next()).getURI();
- ns.setURI(uri);
- ns.setPrefix(prefix);
- newDefinition.getENamespaces().add(ns);
- }
-
- iterator = def.getNamespaces().keySet().iterator();
- prefix = null;
- String namespace = null;
-
- while (iterator.hasNext())
- {
- prefix = (String)iterator.next();
- namespace = def.getNamespace(prefix);
- newDefinition.addNamespace(prefix, namespace);
- }
- //newDefinition.updateElement();
-
- currentExtensibleElement = def;
- super.visitDefinition(def);
-
- root.setElement(null);
- root.updateElement(true);
- root.getElement();
- root.setElement(null);
- root.updateElement();
- }
-
- protected void visitImport(Import wsdlImport)
- {
- Import myImport = factory.createImport();
- newDefinition.getEImports().add(myImport);
-
- // e.g. <xs:import namespace="http://foo.com" schemaLocation= "bar.xsd"/>
- myImport.setNamespaceURI(wsdlImport.getNamespaceURI());
- myImport.setLocationURI(wsdlImport.getLocationURI());
- myImport.setDocumentationElement(wsdlImport.getDocumentationElement());
- myImport.setEDefinition(wsdlImport.getEDefinition());
- myImport.setESchema(wsdlImport.getESchema());
- myImport.setSchema(wsdlImport.getSchema());
- myImport.setEnclosingDefinition(newDefinition);
- }
-
- protected void visitTypes(Types types)
- {
- Types myTypes = factory.createTypes();
- myTypes.setDocumentationElement(types.getDocumentationElement());
-
- Iterator iterator = types.getEExtensibilityElements().iterator();
- ExtensibilityElement ee = null;
- types.getSchemas("http://tempuri.org/LoadAndPrintTest/");
-
- currentExtensibleElement = myTypes;
- while (iterator.hasNext())
- {
- ee = (ExtensibilityElement)iterator.next();
- visitExtensibilityElement(ee);
- }
-
- myTypes.setEnclosingDefinition(newDefinition);
- newDefinition.getETypes();
- newDefinition.setETypes(myTypes);
- }
-
- protected void visitPart(Part part)
- {
- Part myPart = factory.createPart();
- myPart.setDocumentationElement(part.getDocumentationElement());
- myPart.setName(part.getName());
- myPart.setElementName(part.getElementName());
- myPart.setTypeName(part.getTypeName());
- myPart.setEMessage(part.getEMessage());
- myPart.setElementDeclaration(part.getElementDeclaration());
- myPart.setTypeDefinition(part.getTypeDefinition());
-
- Iterator iterator = part.getExtensionAttributes().keySet().iterator();
- QName key = null;
- QName value = null;
- while (iterator.hasNext())
- {
- key = (QName)iterator.next();
- value = (QName)part.getExtensionAttribute(key);
- myPart.setExtensionAttribute(key, value);
- }
- currentMessage.setEnclosingDefinition(newDefinition);
- currentMessage.addPart(myPart);
- }
-
- protected void visitPortType(PortType portType)
- {
- currentPortType = factory.createPortType();
- currentPortType.setDocumentationElement(portType.getDocumentationElement());
- currentPortType.setQName(portType.getQName());
- currentPortType.setUndefined(portType.isUndefined());
-
- currentPortType.setEnclosingDefinition(newDefinition);
- newDefinition.getEPortTypes().add(currentPortType);
-
- super.visitPortType(portType);
- }
-
- protected void visitOperation(Operation operation)
- {
- currentOperation = factory.createOperation();
- currentOperation.setDocumentationElement(operation.getDocumentationElement());
- currentOperation.setName(operation.getName());
- currentOperation.setStyle(operation.getStyle());
- currentOperation.setUndefined(operation.isUndefined());
- operation.getEParameterOrdering(); // TBD
- currentOperation.setEnclosingDefinition(newDefinition);
- currentPortType.getEOperations().add(currentOperation);
-
- super.visitOperation(operation);
- //System.out.println("Operation Type is: " + operation.getStyle());
- //operation.setStyle(OperationType.REQUEST_RESPONSE);
- //System.out.println("Operation Type is: " + operation.getStyle());
- }
-
- protected void visitMessage(Message message)
- {
- currentMessage = factory.createMessage();
- currentMessage.setQName(message.getQName());
- currentMessage.setUndefined(message.isUndefined());
- newDefinition.addMessage(currentMessage);
-
- super.visitMessage(message);
- }
-
- protected void visitInput(Input input)
- {
- MessageReference myInput = factory.createInput();
- myInput.setDocumentationElement(input.getDocumentationElement());
- myInput.setName(input.getName());
- myInput.getName();
- myInput.setEMessage(input.getEMessage());
- myInput.setEnclosingDefinition(newDefinition);
- currentOperation.setEInput((Input)myInput);
- }
-
- protected void visitOutput(Output output)
- {
- Output myOutput = factory.createOutput();
- myOutput.setDocumentationElement(output.getDocumentationElement());
- myOutput.setName(output.getName());
- myOutput.setEMessage(output.getEMessage());
- myOutput.setEnclosingDefinition(newDefinition);
- currentOperation.setEOutput(myOutput);
- }
-
- protected void visitFault(Fault fault)
- {
- Fault myFault = factory.createFault();
- myFault.setDocumentationElement(fault.getDocumentationElement());
- myFault.setName(fault.getName());
- myFault.setEMessage(fault.getEMessage());
- myFault.setEnclosingDefinition(newDefinition);
- currentOperation.getEFaults().add(myFault);
- }
-
- protected void visitBinding(Binding binding)
- {
- currentBinding = factory.createBinding();
- newDefinition.getEBindings().add(currentBinding);
-
- currentBinding.setDocumentationElement(binding.getDocumentationElement());
- currentBinding.setQName(binding.getQName());
- currentBinding.setEPortType(binding.getEPortType());
- currentBinding.setUndefined(binding.isUndefined());
-
- currentExtensibleElement = currentBinding;
- super.visitBinding(binding);
- }
-
- protected void visitBindingOperation(BindingOperation bindingOperation)
- {
- currentBindingOperation = factory.createBindingOperation();
- currentBindingOperation.setDocumentationElement(bindingOperation.getDocumentationElement());
- currentBindingOperation.setEOperation(bindingOperation.getEOperation());
- currentBindingOperation.setName(bindingOperation.getName());
- currentBinding.getBindingOperations().add(currentBindingOperation);
-
- currentExtensibleElement = currentBindingOperation;
- super.visitBindingOperation(bindingOperation);
- }
-
- protected void visitBindingInput(BindingInput input)
- {
- BindingInput myInput = factory.createBindingInput();
- myInput.setDocumentationElement(input.getDocumentationElement());
- myInput.setName(input.getName());
- myInput.setInput(input.getInput());
- myInput.setEInput(input.getEInput());
- currentBindingOperation.setEBindingInput(myInput);
-
- currentExtensibleElement = myInput;
- super.visitBindingInput(input);
- }
-
- protected void visitBindingOutput(BindingOutput output)
- {
- BindingOutput myOutput = factory.createBindingOutput();
- myOutput.setDocumentationElement(output.getDocumentationElement());
- myOutput.setName(output.getName());
- myOutput.setOutput(output.getOutput());
- myOutput.setEOutput(output.getEOutput());
- currentBindingOperation.setEBindingOutput(myOutput);
-
- currentExtensibleElement = myOutput;
- super.visitBindingOutput(output);
- }
-
- protected void visitBindingFault(BindingFault fault)
- {
- BindingFault myFault = factory.createBindingFault();
- myFault.setDocumentationElement(fault.getDocumentationElement());
- myFault.setName(fault.getName());
- myFault.setEFault(fault.getEFault());
- myFault.setFault(fault.getFault());
- currentBindingOperation.getEBindingFaults().add(myFault);
-
- currentExtensibleElement = myFault;
- super.visitBindingFault(fault);
- }
-
- protected void visitService(Service service)
- {
- currentService = factory.createService();
- currentService.setDocumentationElement(service.getDocumentationElement());
- currentService.setQName(service.getQName());
- currentService.setUndefined(service.isUndefined());
-
- newDefinition.getEServices().add(currentService);
-
- super.visitService(service);
- }
-
- protected void visitPort(Port port)
- {
- Port myPort = factory.createPort();
- myPort.setDocumentationElement(port.getDocumentationElement());
- myPort.setName(port.getName());
- myPort.setEBinding(port.getEBinding());
-
- currentService.getEPorts().add(myPort);
-
- currentExtensibleElement = myPort;
- super.visitPort(port);
- }
-
- protected void visitExtensibilityElement(ExtensibleElement owner, ExtensibilityElement extensibilityElement)
- {
- // To move up the API test coverage
- owner.getEExtensibilityElements();
- owner.getExtensibilityElements();
- factory.createExtensibilityElement();
- WSDLPlugin.getPlugin();
- WSDLPlugin.INSTANCE.getPluginResourceLocator();
-
- visitExtensibilityElement(extensibilityElement);
- }
-
- private void visitExtensibilityElement(ExtensibilityElement extensibilityElement)
- {
- XSDSchemaExtensibilityElement xsee = null;
- UnknownExtensibilityElement uee = null;
- ExtensibilityElement myEE = null;
- if (extensibilityElement instanceof XSDSchemaExtensibilityElement)
- {
- myEE = factory.createXSDSchemaExtensibilityElement();
- xsee = (XSDSchemaExtensibilityElement)myEE;
- xsee.setSchema(((XSDSchemaExtensibilityElement)extensibilityElement).getSchema());
- }
- else
- {
- myEE = factory.createUnknownExtensibilityElement();
- uee = (UnknownExtensibilityElement)myEE;
- uee.getChildren(); // TBD
- }
- myEE.setElementType(extensibilityElement.getElementType());
- myEE.setRequired(extensibilityElement.getRequired());
- myEE.setRequired(extensibilityElement.isRequired());
- if (currentExtensibleElement != null)
- currentExtensibleElement.addExtensibilityElement(myEE);
-
- if (extensibilityElement instanceof SOAPBody)
- visitSOAPBody((SOAPBody)extensibilityElement);
- else if (extensibilityElement instanceof SOAPBinding)
- visitSOAPBinding((SOAPBinding)extensibilityElement);
- else if (extensibilityElement instanceof SOAPAddress)
- visitSOAPAddress((SOAPAddress)extensibilityElement);
- else if (extensibilityElement instanceof SOAPOperation)
- visitSOAPOperation((SOAPOperation)extensibilityElement);
- else if (extensibilityElement instanceof SOAPFault)
- visitSOAPFault((SOAPFault)extensibilityElement);
- else if (extensibilityElement instanceof SOAPHeader)
- visitSOAPHeader((SOAPHeader)extensibilityElement);
- else if (extensibilityElement instanceof SOAPHeaderFault)
- visitSOAPHeaderFault((SOAPHeaderFault)extensibilityElement);
- }
-
- private void visitSOAPFault(SOAPFault soapFault)
- {
- SOAPFault mySoapFault = SOAPFactory.eINSTANCE.createSOAPFault();
- mySoapFault.setEncodingStyles(soapFault.getEncodingStyles());
- mySoapFault.setName(soapFault.getName());
- mySoapFault.setNamespaceURI(soapFault.getNamespaceURI());
- mySoapFault.setUse(soapFault.getUse());
- }
-
- private void visitSOAPHeader(SOAPHeader soapHeader)
- {
- // Use SOAPHeaderBase to increase the API coverage values in the reports
-
- SOAPHeaderBase yourSoapHeader = SOAPFactory.eINSTANCE.createSOAPHeaderBase();
- yourSoapHeader.getEncodingStyles();
-
- SOAPHeaderBase mySoapHeader = SOAPFactory.eINSTANCE.createSOAPHeader();
- mySoapHeader.setMessage(soapHeader.getMessage());
- mySoapHeader.getMessage();
- mySoapHeader.setPart(soapHeader.getPart());
- mySoapHeader.getPart();
- mySoapHeader.setNamespaceURI(soapHeader.getNamespaceURI());
- mySoapHeader.getNamespaceURI();
- mySoapHeader.setUse(soapHeader.getUse());
- mySoapHeader.getUse();
- ((SOAPHeader)soapHeader).getHeaderFaults(); // TBD
- }
-
- private void visitSOAPHeaderFault(SOAPHeaderFault soapHeaderFault)
- {
- SOAPHeaderFault mySoapHeaderFault = SOAPFactory.eINSTANCE.createSOAPHeaderFault();
- mySoapHeaderFault.setMessage(soapHeaderFault.getMessage());
- mySoapHeaderFault.setPart(soapHeaderFault.getPart());
- mySoapHeaderFault.setNamespaceURI(soapHeaderFault.getNamespaceURI());
- mySoapHeaderFault.setUse(soapHeaderFault.getUse());
- }
-
- private void visitSOAPOperation(SOAPOperation soapOperation)
- {
- SOAPOperation mySoapOperation = SOAPFactory.eINSTANCE.createSOAPOperation();
- mySoapOperation.setSoapActionURI(soapOperation.getSoapActionURI());
- mySoapOperation.setStyle(soapOperation.getStyle());
- }
-
- private void visitSOAPBody(SOAPBody soapBody)
- {
- SOAPBody mySoapBody = SOAPFactory.eINSTANCE.createSOAPBody();
- mySoapBody.setEncodingStyles(soapBody.getEncodingStyles());
- mySoapBody.setNamespaceURI(soapBody.getNamespaceURI());
- mySoapBody.setParts(soapBody.getParts());
- mySoapBody.setUse(soapBody.getUse());
- }
-
- private void visitSOAPBinding(SOAPBinding soapBinding)
- {
- SOAPBinding mySoapBinding = SOAPFactory.eINSTANCE.createSOAPBinding();
- mySoapBinding.setStyle(soapBinding.getStyle());
- mySoapBinding.setTransportURI(soapBinding.getTransportURI());
- }
-
- private void visitSOAPAddress(SOAPAddress soapAddress)
- {
- SOAPAddress mySoapAddress = SOAPFactory.eINSTANCE.createSOAPAddress();
- mySoapAddress.setLocationURI(soapAddress.getLocationURI());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new WSDLEMFAPITest("ModelSemanticTest")
- {
- protected void runTest()
- {
- testModelSemantic();
- }
- });
- return suite;
- }
-
- public void testModelSemantic()
- {
- try
- {
- Definition def = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/LoadStoreCompare/LoadAndPrintTest.wsdl", true);
- WSDLEMFAPITest test = new WSDLEMFAPITest(def);
- test.visit();
- serialize(test.newDefinition);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- Assert.fail(e.toString());
- }
- }
-
- private void serialize(Definition def) throws Exception
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLResourceImpl wsdlMainResource = (WSDLResourceImpl)resourceSet.createResource(URI.createURI("*.wsdl"));
- wsdlMainResource.getContents().add(def);
-
- IWorkspaceRoot myWorkspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IProject myWebProject = myWorkspaceRoot.getProject("org.eclipse.wst.wsdl.tests");
- if (!myWebProject.exists())
- myWebProject.create(null);
-
- String baseDir = myWebProject.getLocation().toString();
-
- DefinitionLoader.store(def, baseDir + "/ClonedLoadAndPrintTest.wsdl");
- }
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(suite());
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLGenerationTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLGenerationTest.java
deleted file mode 100644
index 87a9b5f87..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLGenerationTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests;
-
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.wst.wsdl.Binding;
-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.Input;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.WSDLFactory;
-import org.eclipse.wst.wsdl.binding.soap.SOAPAddress;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBinding;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBody;
-import org.eclipse.wst.wsdl.binding.soap.SOAPFactory;
-import org.eclipse.wst.wsdl.binding.soap.SOAPOperation;
-import org.eclipse.wst.wsdl.binding.soap.internal.impl.SOAPBodyImpl;
-import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-
-
-public class WSDLGenerationTest extends TestCase
-{
- public WSDLGenerationTest()
- {
- }
-
- public WSDLGenerationTest(String name)
- {
- super(name);
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new WSDLGenerationTest("SampleWSDLGeneration")
- {
- protected void runTest()
- {
- testSampleWSDLGeneration();
- }
- });
-
- return suite;
- }
-
- public void testSampleWSDLGeneration()
- {
- try
- {
- generateTemperatureService(WSDLTestsPlugin.getInstallURL() +"samples/generated/TemperatureService.wsdl");
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- public void generateTemperatureService(String outputFile) throws Exception
- {
- ResourceSet resourceSet = new ResourceSetImpl();
- Resource resource = resourceSet.createResource(URI.createFileURI(outputFile));
- resourceSet.getResources().add(resource);
-
- // Create a Definition - Temperature
- Definition definition = WSDLFactory.eINSTANCE.createDefinition();
- definition.setQName(new QName(WSDLConstants.WSDL_NAMESPACE_URI, "Temperature"));
- resource.getContents().add(definition);
-
- // Target namespace - http://www.temperature.com
- definition.setTargetNamespace("http://www.temperature.com");
- definition.addNamespace("tns", "http://www.temperature.com");
-
- // Other namespaces - wsdl, soap, xsd
- definition.addNamespace("wsdl", WSDLConstants.WSDL_NAMESPACE_URI);
- definition.addNamespace("xsd", WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001);
- definition.getNamespaces().put("soap", SOAPConstants.SOAP_NAMESPACE_URI);
-
- //
- // Let's start building two messages
- //
-
- // Create a Part - ZipCode
- Part part = WSDLFactory.eINSTANCE.createPart();
- part.setName("ZipCode");
- part.setTypeName(new QName(WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string"));
-
- // Create a Message - GetTemperatureInput
- Message inputMessage = WSDLFactory.eINSTANCE.createMessage();
- inputMessage.setQName(new QName(definition.getTargetNamespace(), "GetTemperatureInput"));
- inputMessage.addPart(part);
- definition.addMessage(inputMessage);
-
- // Create a Part - Temperature
- part = WSDLFactory.eINSTANCE.createPart();
- part.setName("Temperature");
- part.setTypeName(new QName(WSDLConstants.SCHEMA_FOR_SCHEMA_URI_2001, "float"));
-
- // Create a Message - GetTemperatureOutput
- Message outputMessage = WSDLFactory.eINSTANCE.createMessage();
- outputMessage.setQName(new QName(definition.getTargetNamespace(), "GetTemperatureOutput"));
- outputMessage.addPart(part);
- definition.addMessage(outputMessage);
-
- //
- // Next, build a PortType
- //
-
- // Create an Input - GetTemperatureInput
- Input input = WSDLFactory.eINSTANCE.createInput();
- input.setMessage(inputMessage);
-
- // Create an Output - GetTemperatureOutput
- Output output = WSDLFactory.eINSTANCE.createOutput();
- output.setMessage(outputMessage);
-
- // Create an Operation - GetTemperatureForZipCode
- Operation operation = WSDLFactory.eINSTANCE.createOperation();
- operation.setName("GetTemperatureForZipCode");
- operation.setInput(input);
- operation.setOutput(output);
-
- // Create a PortType
- PortType portType = WSDLFactory.eINSTANCE.createPortType();
- portType.setQName(new QName(definition.getTargetNamespace(), "GetTemperatureInfoSOAP"));
- portType.addOperation(operation);
- definition.addPortType(portType);
-
- //
- // Now, let's work on Binding
- //
-
- // Create a Binding - GetTemperatureInfoSOAP
- Binding binding = WSDLFactory.eINSTANCE.createBinding();
- binding.setQName(new QName(definition.getTargetNamespace(), "GetTemperatureInfoSOAP"));
- binding.setPortType(portType);
- definition.addBinding(binding);
-
- // Create a SOAP Binding
- SOAPBinding soapBinding = SOAPFactory.eINSTANCE.createSOAPBinding();
- soapBinding.setStyle("rpc");
- soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
- binding.addExtensibilityElement(soapBinding);
-
- // Create a Binding Operation
- BindingOperation bindingOperation = WSDLFactory.eINSTANCE.createBindingOperation();
- bindingOperation.setName("GetTemperatureForZipCode");
- binding.addBindingOperation(bindingOperation);
-
- // Create a SOAP Operation
- SOAPOperation soapOperation = SOAPFactory.eINSTANCE.createSOAPOperation();
- soapOperation.setSoapActionURI("http://www.temperature.com/GetTemperatureForZipCode");
- bindingOperation.addExtensibilityElement(soapOperation);
-
- // Create a SOAP Body
- SOAPBody soapBody = SOAPFactory.eINSTANCE.createSOAPBody();
- soapBody.setUse("encoded");
- soapBody.getEncodingStyles().add("http://schemas.xmlsoap.org/soap/encoding/");
- soapBody.setNamespaceURI("http://www.temperature.com/");
-
- // Add a part (Temperature) to the SOAP body (Bugzilla 108176)
- java.util.Vector v = new java.util.Vector();
- v.add(part);
- soapBody.setParts(v);
- ((SOAPBodyImpl)soapBody).updateElement();
-
- // Create a Binding Input
- BindingInput bindingInput = WSDLFactory.eINSTANCE.createBindingInput();
- bindingInput.addExtensibilityElement(soapBody);
- bindingOperation.setBindingInput(bindingInput);
-
- // Create a SOAP Body
- soapBody = SOAPFactory.eINSTANCE.createSOAPBody();
- soapBody.setUse("encoded");
- soapBody.getEncodingStyles().add("http://schemas.xmlsoap.org/soap/encoding/");
- soapBody.setNamespaceURI("http://www.temperature.com/");
-
- // Create a Binding Output
- BindingOutput bindingOuput = WSDLFactory.eINSTANCE.createBindingOutput();
- bindingOuput.addExtensibilityElement(soapBody);
- bindingOperation.setBindingOutput(bindingOuput);
-
- //
- // Finally, we are building a Service
- //
-
- // Create a SOAP Address
- SOAPAddress soapAddress = SOAPFactory.eINSTANCE.createSOAPAddress();
- soapAddress.setLocationURI("http://todo-some-address/");
-
- // Create a Port - GetTemperatureInfoSOAP
- Port port = WSDLFactory.eINSTANCE.createPort();
- port.setName("GetTemperatureInfoSOAP");
- port.setBinding(binding);
- port.addExtensibilityElement(soapAddress);
-
- // Create a Service - TemperatureService
- Service service = WSDLFactory.eINSTANCE.createService();
- service.setQName(new QName(definition.getTargetNamespace(), "TemperatureService"));
- service.addPort(port);
- definition.addService(service);
-
- //
- // Phew, we are done. Let's serialize it.
- //
-
- resource.save(null);
-
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLTestsPlugin.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLTestsPlugin.java
deleted file mode 100644
index b2d460143..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLTestsPlugin.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- * All rights reserved.   This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
-  *
- * Contributors:
- * IBM - Initial API and implementation
- **********************************************************************/
-
-package org.eclipse.wst.wsdl.tests;
-
-
-import java.io.IOException;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-
-/**
- * The main plug-in class to be used in the desktop.
- */
-public class WSDLTestsPlugin extends Plugin
-{
- //The shared instance.
- private static WSDLTestsPlugin plugin;
-
- //Resource bundle.
- private ResourceBundle resourceBundle;
-
- private static Bundle pluginBundle;
-
- /**
- * The constructor.
- */
- public WSDLTestsPlugin()
- {
- super();
- plugin = this;
- }
-
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception
- {
- super.start(context);
- pluginBundle = context.getBundle();
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception
- {
- super.stop(context);
- plugin = null;
- resourceBundle = null;
- pluginBundle = context.getBundle();
- }
-
- /**
- * Returns the shared instance.
- */
- public static WSDLTestsPlugin getDefault()
- {
- return plugin;
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- */
- public static String getResourceString(String key)
- {
- ResourceBundle bundle = WSDLTestsPlugin.getDefault().getResourceBundle();
- try
- {
- return (bundle != null) ? bundle.getString(key) : key;
- }
- catch (MissingResourceException e)
- {
- return key;
- }
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle()
- {
- try
- {
- if (resourceBundle == null)
- {
- resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.wsdl.tests.WSDLTestsPluginResources");
- }
- }
- catch (MissingResourceException x)
- {
- resourceBundle = null;
- }
- return resourceBundle;
- }
-
- /**
- * Get the install URL of this plug-in.
- *
- * @return the install URL of this plug-in
- */
- public static String getInstallURL()
- {
- try
- {
- return FileLocator.resolve(pluginBundle.getEntry("/")).getFile();
- }
- catch (IOException e)
- {
- return null;
- }
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/HTTPExtensionsTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/HTTPExtensionsTest.java
deleted file mode 100644
index 2c8b98dc3..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/HTTPExtensionsTest.java
+++ /dev/null
@@ -1,314 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.wsdl.tests.extensions;
-
-
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.wst.wsdl.Binding;
-import org.eclipse.wst.wsdl.BindingInput;
-import org.eclipse.wst.wsdl.BindingOperation;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.ExtensibilityElement;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.binding.http.HTTPAddress;
-import org.eclipse.wst.wsdl.binding.http.HTTPBinding;
-import org.eclipse.wst.wsdl.binding.http.HTTPFactory;
-import org.eclipse.wst.wsdl.binding.http.HTTPOperation;
-import org.eclipse.wst.wsdl.binding.http.HTTPPackage;
-import org.eclipse.wst.wsdl.binding.http.HTTPUrlEncoded;
-import org.eclipse.wst.wsdl.binding.http.HTTPUrlReplacement;
-import org.eclipse.wst.wsdl.binding.http.internal.generator.HTTPContentGenerator;
-import org.eclipse.wst.wsdl.binding.http.internal.util.HTTPConstants;
-import org.eclipse.wst.wsdl.internal.generator.extension.ContentGeneratorExtensionFactoryRegistry;
-import org.eclipse.wst.wsdl.tests.WSDLTestsPlugin;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-
-
-/**
- * Tests the HTTP binding extensions.
- */
-public class HTTPExtensionsTest extends WSDLExtensionsTest
-{
- private static final String ADDRESS_LOCATION_URI = "http://www.example.org/"; //$NON-NLS-1$
-
- private static final HTTPFactory HTTP_FACTORY = HTTPFactory.eINSTANCE;
-
- private static final String HTTP_LOCATION_URI = "http://www.example.org/HTTPTest/NewOperation";
-
- private static final String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- private static final String TARGET_NAMESPACE = "http://www.example.org/HTTPTest/"; //$NON-NLS-1$
-
- private static final String VERB_GET = "GET"; //$NON-NLS-1$
-
- private static final String VERB_PUT = "PUT"; //$NON-NLS-1$
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new HTTPExtensionsTest("HTTPExtensionsCreation") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testHTTPExtensionsCreation();
- }
- });
-
- suite.addTest(new HTTPExtensionsTest("EMFSerialization") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testEMFSerialization();
- }
- });
-
- suite.addTest(new HTTPExtensionsTest("HTTPExtensionsReconciliation") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testHTTPExtensionsReconciliation();
- }
- });
-
- suite.addTest(new HTTPExtensionsTest("HTTPContentGenerator") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testHTTPContentGenerator();
- }
- });
-
- return suite;
- }
-
- public HTTPExtensionsTest(String name)
- {
- super(name);
- }
-
- public void testHTTPExtensionsCreation()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/HTTP/HTTPTest.wsdl"); //$NON-NLS-1$
-
- String bindingName = "HTTPTestHTTP"; //$NON-NLS-1$
- QName bindingQName = new QName(TARGET_NAMESPACE, bindingName);
- Binding binding = (Binding)definition.getBinding(bindingQName);
-
- addHTTPBinding(binding);
-
- BindingOperation bindingOperation = (BindingOperation)binding.getBindingOperation("NewOperation", null, null); //$NON-NLS-1$
-
- addHTTPOperation(bindingOperation);
-
- BindingInput bindingInput = bindingOperation.getEBindingInput();
-
- addHTTPBindingInput(bindingInput);
-
- addHTTPAddress(definition);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- public void testHTTPExtensionsReconciliation()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/HTTP/HTTPExample.wsdl", true); //$NON-NLS-1$
-
- String serviceName = "HTTPExample"; //$NON-NLS-1$
- String targetNamespace = "http://www.example.org/HTTPExample/"; //$NON-NLS-1$
- QName serviceQName = new QName(targetNamespace, serviceName);
- Service service = (Service)definition.getService(serviceQName);
- service.toString();
-
- Port port = (Port)service.getPort("HTTPExampleHTTP"); //$NON-NLS-1$
- List extensibilityElements = port.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- HTTPAddress httpAddress = (HTTPAddress)extensibilityElements.get(0);
-
- String locationURI = httpAddress.getLocationURI();
- assertEquals("http://www.example.org/", locationURI);
-
- checkStringAttributeReconciliation(
- httpAddress,
- HTTPConstants.LOCATION_URI_ATTRIBUTE,
- "test",
- HTTPPackage.Literals.HTTP_ADDRESS__LOCATION_URI);
-
- String bindingName = "HTTPExampleHTTP"; //$NON-NLS-1$
- QName bindingQName = new QName(targetNamespace, bindingName);
- Binding binding = (Binding)definition.getBinding(bindingQName);
-
- extensibilityElements = binding.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- HTTPBinding httpBinding = (HTTPBinding)extensibilityElements.get(0);
-
- String verb = httpBinding.getVerb();
- assertEquals(VERB_GET, verb);
-
- checkStringAttributeReconciliation(httpBinding, HTTPConstants.VERB_ATTRIBUTE, VERB_PUT, HTTPPackage.Literals.HTTP_BINDING__VERB);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- /**
- * This method loads a WSDL model then saves it using the default EMF serialization
- * instead of the WSDL XML format, then loads it again. The intent is to exercise
- * the EMF e* methods to aid in identifying real code coverage issues.
- */
- public void testEMFSerialization()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/HTTP/HTTPExample.wsdl", true); //$NON-NLS-1$
-
- ResourceSet resourceSet = new ResourceSetImpl();
- URI fileURI = URI.createFileURI(PLUGIN_ABSOLUTE_PATH + "samples/generated/HTTPExample.xml");
- Resource resource = resourceSet.createResource(fileURI);
- resource.getContents().add(definition);
- resource.save(null);
- resourceSet = new ResourceSetImpl();
- resource = resourceSet.getResource(fileURI, true);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- public void testHTTPContentGenerator()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/HTTP/HTTPTest.wsdl"); //$NON-NLS-1$
-
- HTTPContentGenerator contentGenerator = (HTTPContentGenerator)ContentGeneratorExtensionFactoryRegistry.getInstance().getGeneratorClassFromName(
- "HTTP");
- String locationURI = "http://test.org/example"; //$NON-NLS-1$
- contentGenerator.setAddressLocation(locationURI);
- contentGenerator.setVerb(HTTPContentGenerator.VERB_GET);
-
- String serviceName = "HTTPTest"; //$NON-NLS-1$
- QName serviceQName = new QName(TARGET_NAMESPACE, serviceName);
- Service service = (Service)definition.getService(serviceQName);
-
- Port port = (Port)service.getPort("HTTPTestHTTP"); //$NON-NLS-1$
- List extensibilityElements = port.getExtensibilityElements();
- assertEquals(0, extensibilityElements.size());
- contentGenerator.generatePortContent(port);
-
- extensibilityElements = port.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- ExtensibilityElement extensibilityElement = (ExtensibilityElement)extensibilityElements.get(0);
- assertTrue(extensibilityElement instanceof HTTPAddress);
- HTTPAddress httpAddress = (HTTPAddress)extensibilityElement;
- assertEquals(locationURI, httpAddress.getLocationURI());
-
- QName bindingQName = new QName(TARGET_NAMESPACE, "HTTPTestHTTP"); //$NON-NLS-1$
- Binding binding = (Binding)definition.getBinding(bindingQName);
-
- QName portTypeQName = new QName(TARGET_NAMESPACE, "HTTPTest"); //$NON-NLS-1$
- PortType portType = (PortType)definition.getPortType(portTypeQName);
-
- contentGenerator.generateBindingContent(binding, portType);
-
- // TODO Complete this test.
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
-
- }
-
- private void addHTTPAddress(Definition definition)
- {
- HTTPAddress httpAddress = HTTP_FACTORY.createHTTPAddress();
- httpAddress.setLocationURI(ADDRESS_LOCATION_URI);
-
- httpAddress.toString();
-
- String serviceName = "HTTPTest"; //$NON-NLS-1$
- QName serviceQName = new QName(TARGET_NAMESPACE, serviceName);
- Service service = (Service)definition.getService(serviceQName);
- service.toString();
-
- Port port = (Port)service.getPort("HTTPTestHTTP"); //$NON-NLS-1$
- port.addExtensibilityElement(httpAddress);
- port.toString();
- }
-
- private void addHTTPBinding(Binding binding)
- {
- binding.toString();
-
- HTTPBinding httpBinding = HTTP_FACTORY.createHTTPBinding();
- binding.addExtensibilityElement(httpBinding);
-
- httpBinding.setVerb(VERB_GET);
-
- httpBinding.toString();
- }
-
- private void addHTTPBindingInput(BindingInput bindingInput)
- {
- bindingInput.toString();
-
- HTTPUrlEncoded httpURLEncoded = HTTP_FACTORY.createHTTPUrlEncoded();
- bindingInput.addExtensibilityElement(httpURLEncoded);
-
- bindingInput.getExtensibilityElements().clear();
-
- HTTPUrlReplacement httpURLReplacement = HTTP_FACTORY.createHTTPUrlReplacement();
- bindingInput.addExtensibilityElement(httpURLReplacement);
- }
-
- private void addHTTPOperation(BindingOperation bindingOperation)
- {
- bindingOperation.toString();
-
- HTTPOperation httpOperation = HTTP_FACTORY.createHTTPOperation();
-
- httpOperation.setLocationURI(HTTP_LOCATION_URI);
-
- httpOperation.toString();
-
- bindingOperation.addExtensibilityElement(httpOperation);
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/MIMEExtensionsTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/MIMEExtensionsTest.java
deleted file mode 100644
index b38a2a098..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/MIMEExtensionsTest.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.wsdl.tests.extensions;
-
-
-import java.util.List;
-
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.wst.wsdl.Binding;
-import org.eclipse.wst.wsdl.BindingOperation;
-import org.eclipse.wst.wsdl.BindingOutput;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.binding.mime.MIMEContent;
-import org.eclipse.wst.wsdl.binding.mime.MIMEFactory;
-import org.eclipse.wst.wsdl.binding.mime.MIMEMimeXml;
-import org.eclipse.wst.wsdl.binding.mime.MIMEMultipartRelated;
-import org.eclipse.wst.wsdl.binding.mime.MIMEPart;
-import org.eclipse.wst.wsdl.binding.mime.internal.util.MIMEConstants;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBody;
-import org.eclipse.wst.wsdl.binding.soap.SOAPFactory;
-import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants;
-import org.eclipse.wst.wsdl.tests.WSDLTestsPlugin;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-
-/**
- * Tests the MIME binding extensions.
- */
-public class MIMEExtensionsTest extends TestCase
-{
- private static final MIMEFactory MIME_FACTORY = MIMEFactory.eINSTANCE;
-
- private static final SOAPFactory SOAP_FACTORY = SOAPFactory.eINSTANCE;
-
- private static final String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- private static final String TARGET_NAMESPACE = "http://www.example.org/MIMETest"; //$NON-NLS-1$
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new MIMEExtensionsTest("MIMEExtensionsCreation") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testMIMEExtensionsCreation();
- }
- });
-
- suite.addTest(new MIMEExtensionsTest("EMFSerialization") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testMIMEEMFSerialization();
- }
- });
-
- suite.addTest(new MIMEExtensionsTest("MIMEExtensionsReconciliation") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testMIMEExtensionsReconciliation();
- }
- });
-
- return suite;
- }
-
- public MIMEExtensionsTest(String name)
- {
- super(name);
- }
-
- public void testMIMEExtensionsCreation()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/MIME/MIMETest.wsdl", true); //$NON-NLS-1$
-
- String bindingName = "MIMETestBinding"; //$NON-NLS-1$
- QName bindingQName = new QName(TARGET_NAMESPACE, bindingName);
- Binding binding = (Binding)definition.getBinding(bindingQName);
-
- BindingOperation bindingOperation = (BindingOperation)binding.getBindingOperation("testOperation", null, null); //$NON-NLS-1$
-
- BindingOutput bindingOutput = bindingOperation.getEBindingOutput();
-
- MIMEMultipartRelated multipart = MIME_FACTORY.createMIMEMultipartRelated();
- bindingOutput.addExtensibilityElement(multipart);
- multipart.toString();
- Element multipartElement = multipart.getElement();
- assertNotNull(multipartElement);
-
- MIMEPart mimePart = MIME_FACTORY.createMIMEPart();
- multipart.addMIMEPart(mimePart);
- Element mimePartElement = mimePart.getElement();
- NodeList mimePartElements = multipartElement.getElementsByTagNameNS(MIMEConstants.MIME_NAMESPACE_URI, MIMEConstants.PART_ELEMENT_TAG);
- assertEquals(1, mimePartElements.getLength());
- assertEquals(mimePartElement, mimePartElements.item(0));
-
- SOAPBody soapBody = SOAP_FACTORY.createSOAPBody();
- soapBody.setUse("literal");
- mimePart.addExtensibilityElement(soapBody);
- mimePart.toString();
- Element soapBodyElement = soapBody.getElement();
- NodeList soapBodyElements = mimePartElement.getElementsByTagNameNS(SOAPConstants.SOAP_NAMESPACE_URI, SOAPConstants.BODY_ELEMENT_TAG);
- assertEquals(1, soapBodyElements.getLength());
- assertEquals(soapBodyElement, soapBodyElements.item(0));
-
- mimePart = MIME_FACTORY.createMIMEPart();
- multipart.addMIMEPart(mimePart);
-
- MIMEContent mimeContent = MIME_FACTORY.createMIMEContent();
- mimeContent.setPart("responseData");
- mimeContent.setType("text/binary");
- mimeContent.toString();
-
- mimePart.addExtensibilityElement(mimeContent);
-
- mimePartElement = mimePart.getElement();
- mimePartElements = multipartElement.getElementsByTagNameNS(MIMEConstants.MIME_NAMESPACE_URI, MIMEConstants.PART_ELEMENT_TAG);
- assertEquals(2, mimePartElements.getLength());
- assertEquals(mimePartElement, mimePartElements.item(1));
-
- List mimeParts = multipart.getMIMEParts();
- assertEquals(2, mimeParts.size());
-
- MIMEMimeXml mimeXML = MIME_FACTORY.createMIMEMimeXml();
- bindingOutput.addExtensibilityElement(mimeXML);
- mimeXML.setPart("xmlData");
- mimeXML.toString();
-
- DefinitionLoader.store(definition, "samples/generated/MIMETestOut.wsdl");
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- public void testMIMEExtensionsReconciliation()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/MIME/MIMEExample.wsdl", true); //$NON-NLS-1$
- String targetNamespace = "http://www.example.org/MIMEExample"; //$NON-NLS-1$
- String bindingName = "MIMEExampleBinding"; //$NON-NLS-1$
- QName bindingQName = new QName(targetNamespace, bindingName);
- definition.getBinding(bindingQName);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- /**
- * This method loads a WSDL model then saves it using the default EMF serialization
- * instead of the WSDL XML format, then loads it again. The intent is to exercise
- * the EMF e* methods to aid in identifying real code coverage issues.
- */
- public void testMIMEEMFSerialization()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/MIME/MIMEExample.wsdl", true); //$NON-NLS-1$
-
- ResourceSet resourceSet = new ResourceSetImpl();
- URI fileURI = URI.createFileURI(PLUGIN_ABSOLUTE_PATH + "samples/generated/MIMEExample.xml");
- Resource resource = resourceSet.createResource(fileURI);
- resource.getContents().add(definition);
- resource.save(null);
- resourceSet = new ResourceSetImpl();
- resource = resourceSet.getResource(fileURI, false);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/SOAPExtensionsTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/SOAPExtensionsTest.java
deleted file mode 100644
index 104c2d390..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/SOAPExtensionsTest.java
+++ /dev/null
@@ -1,512 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.wsdl.tests.extensions;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.wsdl.extensions.ExtensibilityElement;
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.wst.wsdl.Binding;
-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.Message;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.binding.soap.SOAPAddress;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBinding;
-import org.eclipse.wst.wsdl.binding.soap.SOAPBody;
-import org.eclipse.wst.wsdl.binding.soap.SOAPFactory;
-import org.eclipse.wst.wsdl.binding.soap.SOAPFault;
-import org.eclipse.wst.wsdl.binding.soap.SOAPHeader;
-import org.eclipse.wst.wsdl.binding.soap.SOAPHeaderFault;
-import org.eclipse.wst.wsdl.binding.soap.SOAPOperation;
-import org.eclipse.wst.wsdl.binding.soap.SOAPPackage;
-import org.eclipse.wst.wsdl.binding.soap.internal.generator.SOAPContentGenerator;
-import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants;
-import org.eclipse.wst.wsdl.internal.generator.extension.ContentGeneratorExtensionFactoryRegistry;
-import org.eclipse.wst.wsdl.tests.WSDLTestsPlugin;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-
-/**
- * Tests the SOAP binding extensions.
- */
-public class SOAPExtensionsTest extends WSDLExtensionsTest
-{
- private static final String HTTP_TRANSPORT_URI = "http://schemas.xmlsoap.org/soap/http"; //$NON-NLS-1$
-
- private static final String LOCATION_URI = "http://www.example.org/"; //$NON-NLS-1$
-
- private static final String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
-
- private static final String SOAP_ACTION_URI = "http://www.example.org/SOAPTest/NewOperation";
-
- private static final SOAPFactory SOAP_FACTORY = SOAPFactory.eINSTANCE;
-
- private static final String STYLE_DOCUMENT = "document"; //$NON-NLS-1$
-
- private static final String STYLE_RPC = "rpc"; //$NON-NLS-1$
-
- private static final String USE_LITERAL = "literal"; //$NON-NLS-1$
-
- private static final String USE_ENCODED = "encoded"; //$NON-NLS-1$
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new SOAPExtensionsTest("SOAPExtensionsCreation") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testSOAPExtensionsCreation();
- }
- });
-
- suite.addTest(new SOAPExtensionsTest("EMFSerialization") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testEMFSerialization();
- }
- });
-
- suite.addTest(new SOAPExtensionsTest("SOAPExtensionsReconciliation") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testSOAPExtensionsReconciliation();
- }
- });
-
- suite.addTest(new SOAPExtensionsTest("SOAPContentGenerator") //$NON-NLS-1$
- {
- protected void runTest()
- {
- testSOAPContentGenerator();
- }
- });
-
- return suite;
- }
-
- public SOAPExtensionsTest(String name)
- {
- super(name);
- }
-
- public void testSOAPExtensionsCreation()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/SOAP/SOAPTest.wsdl"); //$NON-NLS-1$
-
- String bindingName = "SOAPTestSOAP"; //$NON-NLS-1$
- String targetNamespace = "http://www.example.org/SOAPTest/"; //$NON-NLS-1$
- QName bindingQName = new QName(targetNamespace, bindingName);
- Binding binding = (Binding)definition.getBinding(bindingQName);
-
- addSOAPBinding(binding);
-
- BindingOperation bindingOperation = (BindingOperation)binding.getBindingOperation("NewOperation", null, null); //$NON-NLS-1$
-
- addSOAPOperation(bindingOperation);
-
- BindingInput bindingInput = bindingOperation.getEBindingInput();
-
- addSOAPBindingInput(bindingInput);
-
- BindingOutput bindingOutput = bindingOperation.getEBindingOutput();
-
- addSOAPBindingOutput(bindingOutput);
-
- String faultName = "fault"; //$NON-NLS-1$
- BindingFault bindingFault = (BindingFault)bindingOperation.getBindingFault(faultName);
-
- addSOAPBindingFault(bindingFault);
-
- addSOAPAddress(definition);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- public void testSOAPContentGenerator()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/SOAP/SOAPTest.wsdl"); //$NON-NLS-1$
-
- SOAPContentGenerator contentGenerator = (SOAPContentGenerator)ContentGeneratorExtensionFactoryRegistry.getInstance().getGeneratorClassFromName(
- "SOAP");
- String locationURI = "http://test.org/example"; //$NON-NLS-1$
- contentGenerator.setAddressLocation(locationURI);
- contentGenerator.setStyle(SOAPContentGenerator.STYLE_DOCUMENT);
-
- String serviceName = "SOAPTest"; //$NON-NLS-1$
- String targetNamespace = "http://www.example.org/SOAPTest/"; //$NON-NLS-1$
- QName serviceQName = new QName(targetNamespace, serviceName);
- Service service = (Service)definition.getService(serviceQName);
-
- Port port = (Port)service.getPort("SOAPTestSOAP"); //$NON-NLS-1$
- List extensibilityElements = port.getExtensibilityElements();
- assertEquals(0, extensibilityElements.size());
- contentGenerator.generatePortContent(port);
-
- extensibilityElements = port.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- ExtensibilityElement extensibilityElement = (ExtensibilityElement)extensibilityElements.get(0);
- assertTrue(extensibilityElement instanceof SOAPAddress);
- SOAPAddress soapAddress = (SOAPAddress)extensibilityElement;
- assertEquals(locationURI, soapAddress.getLocationURI());
-
- QName bindingQName = new QName(targetNamespace, "SOAPTestSOAP"); //$NON-NLS-1$
- Binding binding = (Binding)definition.getBinding(bindingQName);
-
- QName portTypeQName = new QName(targetNamespace, "SOAPTest"); //$NON-NLS-1$
- PortType portType = (PortType)definition.getPortType(portTypeQName);
-
- contentGenerator.generateBindingContent(binding, portType);
-
- // TODO Complete this test.
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- /**
- * This method loads a WSDL model then saves it using the default EMF serialization
- * instead of the WSDL XML format, then loads it again. The intent is to exercise
- * the EMF e* methods to aid in identifying real code coverage issues.
- */
- public void testEMFSerialization()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/SOAP/DocumentLiteralSOAPExample.wsdl", true); //$NON-NLS-1$
-
- ResourceSet resourceSet = new ResourceSetImpl();
- URI fileURI = URI.createFileURI(PLUGIN_ABSOLUTE_PATH + "samples/generated/DocumentLiteralSOAPExample.xml");
- Resource resource = resourceSet.createResource(fileURI);
- resource.getContents().add(definition);
- resource.save(null);
- resourceSet = new ResourceSetImpl();
- resource = resourceSet.getResource(fileURI, false);
-
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/SOAP/RPCLiteralSOAPExample.wsdl", true); //$NON-NLS-1$
- fileURI = URI.createFileURI(PLUGIN_ABSOLUTE_PATH + "samples/generated/RPCLiteralSOAPExample.xml");
- resourceSet = new ResourceSetImpl();
- resource = resourceSet.createResource(fileURI);
- resource.getContents().add(definition);
- resource.save(null);
- resourceSet = new ResourceSetImpl();
- resource = resourceSet.getResource(fileURI, true);
-
- definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/SOAP/RPCEncodedSOAPExample.wsdl", true); //$NON-NLS-1$
- fileURI = URI.createFileURI(PLUGIN_ABSOLUTE_PATH + "samples/generated/RPCEncodedSOAPExample.xml");
- resourceSet = new ResourceSetImpl();
- resource = resourceSet.createResource(fileURI);
- resource.getContents().add(definition);
- resource.save(null);
- resourceSet = new ResourceSetImpl();
- resource = resourceSet.getResource(fileURI, true);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- public void testSOAPExtensionsReconciliation()
- {
- try
- {
- Definition definition = DefinitionLoader.load(PLUGIN_ABSOLUTE_PATH + "samples/Extensions/SOAP/DocumentLiteralSOAPExample.wsdl", true); //$NON-NLS-1$
-
- String serviceName = "DocumentLiteralSOAPExample"; //$NON-NLS-1$
- String targetNamespace = "http://www.example.org/DocumentLiteralSOAPExample/"; //$NON-NLS-1$
- QName serviceQName = new QName(targetNamespace, serviceName);
- Service service = (Service)definition.getService(serviceQName);
- service.toString();
-
- Port port = (Port)service.getPort("DocumentLiteralSOAPExampleSOAP"); //$NON-NLS-1$
- List extensibilityElements = port.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- SOAPAddress soapAddress = (SOAPAddress)extensibilityElements.get(0);
-
- checkStringAttributeReconciliation(soapAddress, SOAPConstants.LOCATION_ATTRIBUTE, "http://www.example.org/", SOAPPackage.Literals.SOAP_ADDRESS__LOCATION_URI);
-
- String bindingName = "DocumentLiteralSOAPExampleSOAP"; //$NON-NLS-1$
- QName bindingQName = new QName(targetNamespace, bindingName);
- Binding binding = (Binding)definition.getBinding(bindingQName);
-
- extensibilityElements = binding.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- SOAPBinding soapBinding = (SOAPBinding)extensibilityElements.get(0);
-
- String style = soapBinding.getStyle();
- assertEquals(STYLE_DOCUMENT, style);
-
- checkStringAttributeReconciliation(soapBinding, SOAPConstants.STYLE_ATTRIBUTE, STYLE_RPC, SOAPPackage.Literals.SOAP_BINDING__STYLE);
-
- checkStringAttributeReconciliation(soapBinding, SOAPConstants.TRANSPORT_ATTRIBUTE, HTTP_TRANSPORT_URI, SOAPPackage.Literals.SOAP_BINDING__TRANSPORT_URI);
-
- BindingOperation bindingOperation = (BindingOperation)binding.getBindingOperation("NewOperation", null, null);
- extensibilityElements = bindingOperation.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- SOAPOperation soapOperation = (SOAPOperation)extensibilityElements.get(0);
-
- style = soapOperation.getStyle();
- assertEquals(STYLE_DOCUMENT, style);
-
- checkStringAttributeReconciliation(soapOperation, SOAPConstants.STYLE_ATTRIBUTE, STYLE_RPC, SOAPPackage.Literals.SOAP_OPERATION__STYLE);
-
- BindingInput bindingInput = (BindingInput)bindingOperation.getBindingInput();
- extensibilityElements = bindingInput.getExtensibilityElements();
- assertEquals(2, extensibilityElements.size());
-
- SOAPBody soapBody = (SOAPBody)extensibilityElements.get(0);
-
- String use = soapBody.getUse();
- assertEquals(USE_LITERAL, use);
-
- checkStringAttributeReconciliation(soapBody, SOAPConstants.USE_ATTRIBUTE, USE_ENCODED, SOAPPackage.Literals.SOAP_BODY__USE);
-
- SOAPHeader soapHeader = (SOAPHeader)extensibilityElements.get(1);
-
- String part = soapHeader.getPart();
- assertEquals("header", part);
-
- checkStringAttributeReconciliation(soapHeader, SOAPConstants.PART_ATTRIBUTE, "test", SOAPPackage.Literals.SOAP_HEADER_BASE__PART);
-
- QName inputMessageQName = new QName(targetNamespace, "NewOperationRequestMsg");
- Message inputMessage = (Message)definition.getMessage(inputMessageQName);
- assertNotNull(inputMessage);
-
- QName soapHeaderMessageQName = soapHeader.getMessage();
- assertEquals(inputMessageQName, soapHeaderMessageQName);
-
- Element soapHeaderElement = soapHeader.getElement();
- Attr messageAttribute = soapHeaderElement.getAttributeNode(SOAPConstants.MESSAGE_ATTRIBUTE);
-
- QName testMessageQName = new QName(targetNamespace, "TestMsg");
- Message testMessage = (Message)definition.getMessage(testMessageQName);
- messageAttribute.setValue("tns:TestMsg");
- assertEquals(testMessage, soapHeader.getEMessage());
-
- QName message = soapHeader.getMessage();
- assertEquals(testMessageQName, message);
-
- soapHeader.setMessage(null);
- messageAttribute = soapHeaderElement.getAttributeNode(SOAPConstants.MESSAGE_ATTRIBUTE);
- assertNull(messageAttribute);
-
- List soapHeaderFaults = soapHeader.getSOAPHeaderFaults();
- assertEquals(1, soapHeaderFaults.size());
- soapHeaderFaults.clear();
- NodeList headerFaultNodes = soapHeaderElement.getElementsByTagName(SOAPConstants.HEADER_FAULT_ELEMENT_TAG);
- assertEquals(0, headerFaultNodes.getLength());
-
- Document document = soapHeaderElement.getOwnerDocument();
- Element soapHeaderFaultElement = document.createElementNS(SOAPConstants.SOAP_NAMESPACE_URI, SOAPConstants.HEADER_FAULT_ELEMENT_TAG);
- soapHeaderElement.appendChild(soapHeaderFaultElement);
- assertEquals(1, soapHeader.getSOAPHeaderFaults().size());
- soapHeaderFaultElement.setAttribute(SOAPConstants.MESSAGE_ATTRIBUTE, "tns:TestMsg");
- SOAPHeaderFault soapHeaderFault = (SOAPHeaderFault)soapHeader.getSOAPHeaderFaults().get(0);
- assertEquals(testMessageQName, soapHeaderFault.getMessage());
- assertEquals(testMessage, soapHeaderFault.getEMessage());
-
- BindingFault bindingFault = (BindingFault)bindingOperation.getBindingFault("fault");
- extensibilityElements = bindingFault.getExtensibilityElements();
- assertEquals(1, extensibilityElements.size());
- SOAPFault soapFault = (SOAPFault)extensibilityElements.get(0);
-
- String name = soapFault.getName();
- assertEquals("fault", name);
-
- checkStringAttributeReconciliation(soapFault, SOAPConstants.NAME_ATTRIBUTE, "test", SOAPPackage.Literals.SOAP_FAULT__NAME);
-
- soapFault.setNamespaceURI("http://www.example.com/test");
- checkStringAttributeReconciliation(soapFault, SOAPConstants.NAMESPACE_ATTRIBUTE, "test", SOAPPackage.Literals.SOAP_FAULT__NAMESPACE_URI);
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage()); //$NON-NLS-1$
- }
- }
-
- private void addSOAPAddress(Definition definition)
- {
- SOAPAddress soapAddress = SOAP_FACTORY.createSOAPAddress();
- soapAddress.setLocationURI(LOCATION_URI);
-
- soapAddress.toString();
-
- String serviceName = "SOAPTest"; //$NON-NLS-1$
- QName serviceQName = new QName(definition.getTargetNamespace(), serviceName);
- Service service = (Service)definition.getService(serviceQName);
- service.toString();
-
- Port port = (Port)service.getPort("SOAPTestSOAP"); //$NON-NLS-1$
- port.addExtensibilityElement(soapAddress);
- port.toString();
- }
-
- private void addSOAPBinding(Binding binding)
- {
- SOAPBinding soapBinding = SOAP_FACTORY.createSOAPBinding();
-
- soapBinding.setStyle(STYLE_DOCUMENT);
- soapBinding.setTransportURI(HTTP_TRANSPORT_URI);
-
- soapBinding.toString();
-
- binding.addExtensibilityElement(soapBinding);
- binding.toString();
- }
-
- private void addSOAPBindingFault(BindingFault bindingFault)
- {
- String faultName = bindingFault.getName();
-
- SOAPFault soapFault = SOAP_FACTORY.createSOAPFault();
- soapFault.setName(faultName);
- soapFault.toString();
-
- soapFault.setUse(USE_LITERAL);
-
- bindingFault.addExtensibilityElement(soapFault);
- bindingFault.toString();
- }
-
- private void addSOAPBindingInput(BindingInput bindingInput)
- {
- bindingInput.toString();
-
- SOAPBody inputSOAPBody = SOAP_FACTORY.createSOAPBody();
- bindingInput.addExtensibilityElement(inputSOAPBody);
-
- inputSOAPBody.setUse(USE_LITERAL);
-
- List parts = new ArrayList();
- String messageName = "NewOperationRequest"; //$NON-NLS-1$
- Definition enclosingDefinition = bindingInput.getEnclosingDefinition();
- String targetNamespace = enclosingDefinition.getTargetNamespace();
- QName messageQName = new QName(targetNamespace, messageName);
- Definition definition = enclosingDefinition;
- Message message = (Message)definition.getMessage(messageQName);
- Part part = (Part)message.getPart("parameters"); //$NON-NLS-1$
- parts.add(part);
- inputSOAPBody.setParts(parts);
- inputSOAPBody.toString();
-
- SOAPHeader soapHeader = SOAP_FACTORY.createSOAPHeader();
- bindingInput.addExtensibilityElement(soapHeader);
-
- soapHeader.setMessage(messageQName);
-
- String headerPart = "header"; //$NON-NLS-1$
- soapHeader.setPart(headerPart);
-
- soapHeader.setUse(USE_LITERAL);
-
- soapHeader.toString();
-
- addSOAPHeaderFault(messageQName, soapHeader);
- }
-
- private void addSOAPBindingOutput(BindingOutput bindingOutput)
- {
- // Exercise some of the RPC / encoded stuff.
-
- SOAPBody soapBody = SOAP_FACTORY.createSOAPBody();
- soapBody.setUse(USE_ENCODED);
-
- EList encodingStyles = new BasicEList();
- encodingStyles.add("http://schemas.xmlsoap.org/soap/encoding/");
- encodingStyles.add("test");
-
- soapBody.setEncodingStyles(encodingStyles);
-
- List eEncodingStyles = soapBody.getEEncodingStyles();
- assertEquals(2, eEncodingStyles.size());
-
- soapBody.toString();
-
- bindingOutput.toString();
- bindingOutput.addExtensibilityElement(soapBody);
- }
-
- private void addSOAPHeaderFault(QName messageQName, SOAPHeader soapHeader)
- {
- SOAPHeaderFault soapHeaderFault = SOAP_FACTORY.createSOAPHeaderFault();
- soapHeader.addSOAPHeaderFault(soapHeaderFault);
-
- List soapHeaderFaults = soapHeader.getSOAPHeaderFaults();
- assertEquals(1, soapHeaderFaults.size());
- SOAPHeaderFault expectedSoapHeaderFault = (SOAPHeaderFault)soapHeaderFaults.get(0);
- assertEquals(expectedSoapHeaderFault, soapHeaderFault);
-
- soapHeaderFault.setMessage(messageQName);
-
- String headerFaultPart = "headerFault1"; //$NON-NLS-1$
- soapHeaderFault.setPart(headerFaultPart);
-
- // Test the remove part.
-
- soapHeader.getSOAPHeaderFaults().clear();
- }
-
- private void addSOAPOperation(BindingOperation bindingOperation)
- {
- SOAPOperation soapOperation = SOAP_FACTORY.createSOAPOperation();
- soapOperation.setStyle(STYLE_DOCUMENT);
- soapOperation.setSoapActionURI(SOAP_ACTION_URI);
-
- soapOperation.toString();
-
- bindingOperation.addExtensibilityElement(soapOperation);
- bindingOperation.toString();
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/WSDLExtensionsTest.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/WSDLExtensionsTest.java
deleted file mode 100644
index 42779aa57..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/extensions/WSDLExtensionsTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.wsdl.tests.extensions;
-
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.wst.wsdl.WSDLElement;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-
-import junit.framework.TestCase;
-
-
-/**
- * Base class for WSDL extension tests.
- */
-public abstract class WSDLExtensionsTest extends TestCase
-{
- /**
- * Constructs a test with the given name.
- * @param name the test name.
- */
- public WSDLExtensionsTest(String name)
- {
- super(name);
- }
-
- /**
- * Tests a String attribute reconciliation. The code changes the attribute value through the DOM and compares it with the value obtained by calling eGet.
- * @param wsdlElement the WSDL element to test
- * @param attributeName the attribute name
- * @param expectedValue the expected value
- * @param feature the EMF feature of the attribute to test.
- */
- protected void checkStringAttributeReconciliation(
- WSDLElement wsdlElement,
- String attributeName,
- String expectedValue,
- EStructuralFeature feature)
- {
- EObject eObject = (EObject)wsdlElement;
-
- String initialValue = (String)eObject.eGet(feature);
-
- Element element = wsdlElement.getElement();
- eObject.eUnset(feature);
- Attr attribute = element.getAttributeNode(attributeName);
- assertNull(attribute);
-
- eObject.eSet(feature, initialValue);
-
- attribute = element.getAttributeNode(attributeName);
- attribute.setValue(expectedValue);
-
- String actualValue = (String)eObject.eGet(feature);
- assertEquals(expectedValue, actualValue);
-
- element.removeAttribute(attributeName);
- actualValue = (String)eObject.eGet(feature);
- assertNull(actualValue);
-
- eObject.eSet(feature, initialValue);
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionLoader.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionLoader.java
deleted file mode 100644
index 8b90b6d5b..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionLoader.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests.util;
-
-
-import java.io.IOException;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
-
-
-/**
- * @author Kihup Boo
- */
-public final class DefinitionLoader
-{
- /**
- * This class provides static methods only.
- */
- private DefinitionLoader()
- {
- }
-
- static public Definition load(String filename) throws IOException
- {
- return load(filename, false);
- }
-
- static public Definition load(String filename, boolean useExtensionFactories) throws IOException
- {
- return load(filename, useExtensionFactories, false);
- }
-
- static public Definition load(String filename, boolean useExtensionFactories, boolean trackLocation) throws IOException
- {
- // filename is an absolute path
-
- URI uri = null;
- uri = URI.createFileURI(filename);
-
- ResourceSet resourceSet = new ResourceSetImpl();
- resourceSet.getAdapterFactories().add(new WSDLModelLocatorAdapterFactory());
- resourceSet.getAdapterFactories().add(new XSDSchemaLocationResolverAdapterFactory());
-
- WSDLResourceImpl wsdlMainResource = (WSDLResourceImpl)resourceSet.createResource(URI.createURI("*.wsdl"));
- wsdlMainResource.setURI(uri);
- java.util.Map map = new Hashtable();
- map.put(WSDLResourceImpl.CONTINUE_ON_LOAD_ERROR, Boolean.valueOf(true));
- map.put(WSDLResourceImpl.USE_EXTENSION_FACTORIES, Boolean.valueOf(useExtensionFactories));
- map.put(WSDLResourceImpl.TRACK_LOCATION, Boolean.valueOf(trackLocation));
- wsdlMainResource.load(map);
-
- Definition definition = null;
- for (Iterator resources = resourceSet.getResources().iterator(); resources.hasNext();)
- {
- Object resource = resources.next();
- if (resource instanceof WSDLResourceImpl)
- {
- WSDLResourceImpl wsdlResource = (WSDLResourceImpl)resource;
- definition = wsdlResource.getDefinition();
- return definition;
- }
- }
-
- return null;
- }
-
- static public void store(Definition definition, String filename) throws IOException
- {
- // filename is an absolute path
-
- Resource resource = definition.eResource();
- resource.setURI(URI.createFileURI(filename));
- resource.save(null);
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionVisitor.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionVisitor.java
deleted file mode 100644
index 3dfa6232e..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionVisitor.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests.util;
-
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.eclipse.wst.wsdl.Binding;
-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.ExtensibilityElement;
-import org.eclipse.wst.wsdl.ExtensibleElement;
-import org.eclipse.wst.wsdl.Fault;
-import org.eclipse.wst.wsdl.Import;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.Message;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.Types;
-
-
-/**
- * @author Kihup Boo
- */
-public abstract class DefinitionVisitor extends TestCase
-{
- protected Definition definition;
-
- // Added for JUnit
- public DefinitionVisitor(String name)
- {
- super(name);
- }
-
- protected DefinitionVisitor(Definition definition)
- {
- this.definition = definition;
- }
-
- // main entry
- public void visit()
- {
- visitDefinition(definition);
- }
-
- protected void visitDefinition(Definition def)
- {
- Iterator iterator = def.getEImports().iterator();
- while (iterator.hasNext())
- visitImport((Import)iterator.next());
-
- Types types = def.getETypes();
- if (types != null)
- visitTypes(types);
-
- iterator = def.getEMessages().iterator();
- while (iterator.hasNext())
- visitMessage((Message)iterator.next());
-
- iterator = def.getEPortTypes().iterator();
- while (iterator.hasNext())
- visitPortType((PortType)iterator.next());
-
- iterator = def.getEBindings().iterator();
- while (iterator.hasNext())
- visitBinding((Binding)iterator.next());
-
- iterator = def.getEServices().iterator();
- while (iterator.hasNext())
- visitService((Service)iterator.next());
-
- iterator = def.getEExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement(def, (ExtensibilityElement)iterator.next());
-
- }
-
- abstract protected void visitImport(Import wsdlImport);
-
- abstract protected void visitTypes(Types types);
-
- protected void visitMessage(Message message)
- {
- Iterator iterator = message.getEParts().iterator();
- while (iterator.hasNext())
- visitPart((Part)iterator.next());
- }
-
- abstract protected void visitPart(Part part);
-
- protected void visitPortType(PortType portType)
- {
- Iterator iterator = portType.getEOperations().iterator();
- while (iterator.hasNext())
- visitOperation((Operation)iterator.next());
- }
-
- protected void visitOperation(Operation operation)
- {
- Input input = operation.getEInput();
- visitInput((Input)input);
-
- Output output = operation.getEOutput();
- visitOutput((Output)output);
-
- Iterator iterator = operation.getEFaults().iterator();
- while (iterator.hasNext())
- visitFault((Fault)iterator.next());
- }
-
- protected abstract void visitInput(Input input);
-
- protected abstract void visitOutput(Output output);
-
- protected abstract void visitFault(Fault fault);
-
- protected void visitBinding(Binding binding)
- {
- Iterator iterator = binding.getEBindingOperations().iterator();
- while (iterator.hasNext())
- visitBindingOperation((BindingOperation)iterator.next());
-
- iterator = binding.getEExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement(binding, (ExtensibilityElement)iterator.next());
- }
-
- protected void visitBindingOperation(BindingOperation operation)
- {
- BindingInput input = operation.getEBindingInput();
- visitBindingInput((BindingInput)input);
-
- BindingOutput output = operation.getEBindingOutput();
- visitBindingOutput((BindingOutput)output);
-
- Iterator iterator = operation.getEBindingFaults().iterator();
- while (iterator.hasNext())
- visitBindingFault((BindingFault)iterator.next());
-
- iterator = operation.getEExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement(operation, (ExtensibilityElement)iterator.next());
-
- }
-
- protected void visitBindingInput(BindingInput input)
- {
- Iterator iterator = input.getEExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement(input, (ExtensibilityElement)iterator.next());
- }
-
- protected void visitBindingOutput(BindingOutput output)
- {
- Iterator iterator = output.getEExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement(output, (ExtensibilityElement)iterator.next());
- }
-
- protected void visitBindingFault(BindingFault fault)
- {
- Iterator iterator = fault.getEExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement(fault, (ExtensibilityElement)iterator.next());
- }
-
- protected void visitService(Service service)
- {
- Iterator iterator = service.getEPorts().iterator();
- while (iterator.hasNext())
- visitPort((Port)iterator.next());
-
- iterator = service.getEExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement(service, (ExtensibilityElement)iterator.next());
- }
-
- protected void visitPort(Port port)
- {
- Iterator iterator = port.getEExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement(port, (ExtensibilityElement)iterator.next());
- }
-
- abstract protected void visitExtensibilityElement(ExtensibleElement owner, ExtensibilityElement extensibilityElement);
-
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDL4JDefinitionVisitor.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDL4JDefinitionVisitor.java
deleted file mode 100644
index b70bf7c29..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDL4JDefinitionVisitor.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests.util;
-
-
-import java.util.Iterator;
-
-import javax.wsdl.Binding;
-import javax.wsdl.BindingFault;
-import javax.wsdl.BindingInput;
-import javax.wsdl.BindingOperation;
-import javax.wsdl.BindingOutput;
-import javax.wsdl.Definition;
-import javax.wsdl.Fault;
-import javax.wsdl.Import;
-import javax.wsdl.Input;
-import javax.wsdl.Message;
-import javax.wsdl.Operation;
-import javax.wsdl.Output;
-import javax.wsdl.Part;
-import javax.wsdl.Port;
-import javax.wsdl.PortType;
-import javax.wsdl.Service;
-import javax.wsdl.Types;
-import javax.wsdl.extensions.ExtensibilityElement;
-
-import junit.framework.TestCase;
-
-
-/**
- * @author Kihup Boo
- */
-public abstract class WSDL4JDefinitionVisitor extends TestCase
-{
- protected Definition definition;
-
- // Added for JUnit
- public WSDL4JDefinitionVisitor(String name)
- {
- super(name);
- }
-
- protected WSDL4JDefinitionVisitor(Definition definition)
- {
- this.definition = definition;
- }
-
- // main entry
- public void visit()
- {
- visitDefinition(definition);
- }
-
- protected void visitDefinition(Definition def)
- {
- java.util.Map imports = def.getImports();
- Iterator iterator = imports.keySet().iterator();
- Import myImport = null;
- while (iterator.hasNext())
- {
- myImport = (Import)((java.util.ArrayList)imports.get(iterator.next())).get(0);
- visitImport(myImport);
- }
-
- Types types = def.getTypes();
- if (types != null)
- visitTypes(types);
-
- iterator = def.getMessages().values().iterator();
- while (iterator.hasNext())
- visitMessage((Message)iterator.next());
-
- iterator = def.getPortTypes().values().iterator();
- while (iterator.hasNext())
- visitPortType((PortType)iterator.next());
-
- iterator = def.getBindings().values().iterator();
- while (iterator.hasNext())
- visitBinding((Binding)iterator.next());
-
- iterator = def.getServices().values().iterator();
- while (iterator.hasNext())
- visitService((Service)iterator.next());
-
- iterator = def.getExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement((ExtensibilityElement)iterator.next());
-
- }
-
- abstract protected void visitImport(Import wsdlImport);
-
- abstract protected void visitTypes(Types types);
-
- protected void visitMessage(Message message)
- {
- Iterator iterator = message.getParts().values().iterator();
- while (iterator.hasNext())
- visitPart((Part)iterator.next());
- }
-
- abstract protected void visitPart(Part part);
-
- protected void visitPortType(PortType portType)
- {
- Iterator iterator = portType.getOperations().iterator();
- while (iterator.hasNext())
- visitOperation((Operation)iterator.next());
- }
-
- protected void visitOperation(Operation operation)
- {
- Input input = operation.getInput();
- visitInput((Input)input);
-
- Output output = operation.getOutput();
- visitOutput((Output)output);
-
- java.util.Map faults = operation.getFaults();
- Iterator iterator = faults.keySet().iterator();
- Fault fault = null;
- while (iterator.hasNext())
- {
- fault = (Fault)faults.get(iterator.next());
- visitFault(fault);
- }
- }
-
- protected abstract void visitInput(Input input);
-
- protected abstract void visitOutput(Output output);
-
- protected abstract void visitFault(Fault fault);
-
- protected void visitBinding(Binding binding)
- {
- Iterator iterator = binding.getBindingOperations().iterator();
- while (iterator.hasNext())
- visitBindingOperation((BindingOperation)iterator.next());
-
- iterator = binding.getExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement((ExtensibilityElement)iterator.next());
- }
-
- protected void visitBindingOperation(BindingOperation operation)
- {
- BindingInput input = operation.getBindingInput();
- visitBindingInput((BindingInput)input);
-
- BindingOutput output = operation.getBindingOutput();
- visitBindingOutput((BindingOutput)output);
-
- java.util.Map bindingFaults = operation.getBindingFaults();
- Iterator iterator = bindingFaults.keySet().iterator();
- BindingFault bindingFault = null;
- while (iterator.hasNext())
- {
- bindingFault = (BindingFault)bindingFaults.get(iterator.next());
- visitBindingFault(bindingFault);
- }
-
- iterator = operation.getExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement((ExtensibilityElement)iterator.next());
-
- }
-
- protected void visitBindingInput(BindingInput input)
- {
- Iterator iterator = input.getExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement((ExtensibilityElement)iterator.next());
- }
-
- protected void visitBindingOutput(BindingOutput output)
- {
- Iterator iterator = output.getExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement((ExtensibilityElement)iterator.next());
- }
-
- protected void visitBindingFault(BindingFault fault)
- {
- Iterator iterator = fault.getExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement((ExtensibilityElement)iterator.next());
- }
-
- protected void visitService(Service service)
- {
- Iterator iterator = service.getPorts().values().iterator();
- while (iterator.hasNext())
- visitPort((Port)iterator.next());
-
- iterator = service.getExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement((ExtensibilityElement)iterator.next());
- }
-
- protected void visitPort(Port port)
- {
- Iterator iterator = port.getExtensibilityElements().iterator();
- while (iterator.hasNext())
- visitExtensibilityElement((ExtensibilityElement)iterator.next());
- }
-
- abstract protected void visitExtensibilityElement(ExtensibilityElement extensibilityElement);
-
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLConverter.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLConverter.java
deleted file mode 100644
index fe9b029ef..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLConverter.java
+++ /dev/null
@@ -1,598 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests.util;
-
-
-import java.io.FileOutputStream;
-import java.util.Iterator;
-
-import javax.wsdl.OperationType;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.wst.wsdl.Binding;
-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.ExtensibilityElement;
-import org.eclipse.wst.wsdl.ExtensibleElement;
-import org.eclipse.wst.wsdl.Fault;
-import org.eclipse.wst.wsdl.Import;
-import org.eclipse.wst.wsdl.Input;
-import org.eclipse.wst.wsdl.MessageReference;
-import org.eclipse.wst.wsdl.Operation;
-import org.eclipse.wst.wsdl.Output;
-import org.eclipse.wst.wsdl.Part;
-import org.eclipse.wst.wsdl.Port;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.Types;
-import org.eclipse.xsd.XSDSchema;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- * @author Kihup Boo
- */
-public class WSDLConverter extends DefinitionVisitor
-{
- private Document doc;
-
- private Element description;
-
- private Element currentTypes;
-
- private Element currentService;
-
- private Element currentEndpoint;
-
- private Element currentInterface;
-
- private Element currentOperation;
-
- private Element currentBinding;
-
- private Element currentBindingOperation;
-
- private Element currentBindingInput;
-
- private Element currentBindingOutput;
-
- private Element currentBindingFault;
-
- private String wsdlNamespacePrefix;
-
- private String xsdNamespacePrefix;
-
- // Added for JUnit
- public WSDLConverter(String name)
- {
- super(name);
- }
-
- /**
- * @param definition
- */
- public WSDLConverter(Definition definition)
- {
- super(definition);
- // TODO Auto-generated constructor stub
- }
-
- public void generate20(String filename) throws Exception
- {
- createDocument();
- visit();
- serialize(filename);
- }
-
- private void serialize(String filename) throws Exception
- {
- Source domSource = new DOMSource(doc);
- Transformer transformer = TransformerFactory.newInstance().newTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes");
- transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
- transformer.transform(domSource, new StreamResult(new FileOutputStream(filename)));
- }
-
- private void createDocument() throws ParserConfigurationException
- {
- doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- }
-
- private Element createWSDLElement(String name)
- {
- Element element = doc.createElementNS("http://www.w3.org/2004/08/wsdl", name);
- if (wsdlNamespacePrefix != null)
- element.setPrefix(wsdlNamespacePrefix);
-
- return element;
- }
-
- private void processDocumentation(Element docElement, Element parent)
- {
- if (docElement == null)
- return;
-
- Element adoptedDocElement = (Element)doc.importNode(docElement, true);
- parent.appendChild(adoptedDocElement);
- }
-
- protected void visitDefinition(Definition def)
- {
- description = createWSDLElement("description");
- processDocumentation(def.getDocumentationElement(), description);
-
- // TBD - Determine later if we want to convert the document to use SOAP 1.2.
- // However adding these two namespaces may not be harmful.
- description.setAttribute("xmlns:soapenv", "http://www.w3.org/2003/05/soap-envelop");
- description.setAttribute("xmlns:wsoap", "http://www.w3.org/2004/08/soap12");
-
- String targetNamespace = def.getTargetNamespace();
- if (targetNamespace != null)
- description.setAttribute("targetNamespace", targetNamespace);
-
- Iterator iterator = def.getNamespaces().keySet().iterator();
- String prefix = null;
- String namespace = null;
- /*
- xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"*/
- while (iterator.hasNext())
- {
- prefix = (String)iterator.next();
- namespace = def.getNamespace(prefix);
-
- if ("http://schemas.xmlsoap.org/wsdl/".equals(namespace))
- {
- if (prefix.length() == 0) // meant to be default namespace
- description.setAttribute("xmlns", "http://www.w3.org/2004/08/wsdl");
- else
- {
- description.setAttribute("xmlns:" + prefix, "http://www.w3.org/2004/08/wsdl");
- wsdlNamespacePrefix = prefix;
- description.setPrefix(wsdlNamespacePrefix);
- }
- continue;
- }
-
- // SOAP 1.2
- if ("http://schemas.xmlsoap.org/wsdl/soap/".equals(namespace))
- {
- // SOAP 1.2
- description.setAttribute("xmlns:" + prefix, "http://www.w3.org/2003/05/soap-envelop");
-
- // WSDL 2.0 binding for SOAP 1.2
- description.setAttribute("xmlns:wsoap", "http://www.w3.org/2004/08/soap12");
- continue;
- }
-
- //if ("http://schemas.xmlsoap.org/soap/encoding/".equals(namespace))
- // continue;
-
- if ("http://www.w3.org/2001/XMLSchema".equals(namespace))
- xsdNamespacePrefix = prefix; // We will use this in visitImport().
-
- if (prefix.length() == 0) // meant to be default namespace
- description.setAttribute("xmlns" + prefix, namespace);
- else
- description.setAttribute("xmlns:" + prefix, namespace);
- }
-
- doc.appendChild(description);
- super.visitDefinition(def);
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitImport(org.eclipse.wst.wsdl.Import)
- */
- protected void visitImport(Import wsdlImport)
- {
- // Determine if we <import> a schema.
- if (importingSchema(wsdlImport))
- {
- currentTypes = createWSDLElement("types");
- description.appendChild(currentTypes);
-
- // <xs:import namespace="http://foo.com" schemaLocation= "bar.xsd"/>
- Element schemaImport = doc.createElementNS("http://www.w3.org/2001/XMLSchema", "import");
- if (xsdNamespacePrefix == null) // need to add one
- {
- description.setAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema");
- xsdNamespacePrefix = "xs";
- schemaImport.setPrefix(xsdNamespacePrefix);
- }
- else if (!"".equals(xsdNamespacePrefix)) // it is not default namespace
- schemaImport.setPrefix(xsdNamespacePrefix);
-
- schemaImport.setAttribute("namespace", wsdlImport.getNamespaceURI());
- schemaImport.setAttribute("schemaLocation", wsdlImport.getLocationURI());
- processDocumentation(wsdlImport.getDocumentationElement(), schemaImport);
- currentTypes.appendChild(schemaImport);
- }
- else
- {
- Element importElement = wsdlImport.getElement();
- Element adoptedImportElement = (Element)doc.importNode(importElement, true);
- processDocumentation(wsdlImport.getDocumentationElement(), adoptedImportElement);
- description.appendChild(adoptedImportElement);
- }
- }
-
- private boolean importingSchema(Import myImport)
- {
- if (myImport.getDefinition() != null) // it is WSDL import
- return false;
- else
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitTypes(org.eclipse.wst.wsdl.Types)
- */
- protected void visitTypes(Types types)
- {
- // currentTypes may have been created in visitImport().
- if (currentTypes == null)
- {
- currentTypes = createWSDLElement("types");
- processDocumentation(types.getDocumentationElement(), currentTypes);
- description.appendChild(currentTypes);
- }
-
- Iterator iterator = types.getSchemas().iterator();
- XSDSchema schema = null;
- Element schemaElement = null;
- Element adoptedSchemaElement = null;
- while (iterator.hasNext())
- {
- schema = (XSDSchema)iterator.next();
- schema.updateElement();
- schemaElement = schema.getElement();
- adoptedSchemaElement = (Element)doc.importNode(schemaElement, true);
- currentTypes.appendChild(adoptedSchemaElement);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitPart(org.eclipse.wst.wsdl.Part)
- */
- protected void visitPart(Part part)
- {
- // TODO Auto-generated method stub
- }
-
- protected void visitPortType(PortType portType)
- {
- currentInterface = createWSDLElement("interface");
- processDocumentation(portType.getDocumentationElement(), currentInterface);
-
- Element portTypeElement = portType.getElement();
- if (portTypeElement.hasAttribute("name"))
- currentInterface.setAttribute("name", portTypeElement.getAttribute("name"));
-
- description.appendChild(currentInterface);
- super.visitPortType(portType);
- }
-
- protected void visitOperation(Operation operation)
- {
- currentOperation = createWSDLElement("operation");
- processDocumentation(operation.getDocumentationElement(), currentOperation);
-
- Element operationElement = operation.getElement();
- if (operationElement.hasAttribute("name"))
- currentOperation.setAttribute("name", operationElement.getAttribute("name"));
-
- OperationType opType = operation.getStyle();
- if (OperationType.REQUEST_RESPONSE == opType)
- currentOperation.setAttribute("pattern", "http://www.w3.org/2004/03/wsdl/in-out");
- else if (OperationType.SOLICIT_RESPONSE == opType)
- currentOperation.setAttribute("pattern", "http://www.w3.org/2004/03/wsdl/out-in");
- else if (OperationType.NOTIFICATION == opType)
- currentOperation.setAttribute("pattern", "http://www.w3.org/2004/03/wsdl/out-only");
- else if (OperationType.ONE_WAY == opType)
- currentOperation.setAttribute("pattern", "http://www.w3.org/2004/03/wsdl/in-only");
-
- currentInterface.appendChild(currentOperation);
- super.visitOperation(operation);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitInput(org.eclipse.wst.wsdl.Input)
- */
- protected void visitInput(Input input)
- {
- Element currentInput = createWSDLElement("input");
- processDocumentation(input.getDocumentationElement(), currentInput);
-
- Element inputElement = input.getElement();
-
- if (inputElement.hasAttribute("name"))
- currentInput.setAttribute("messageLabel", inputElement.getAttribute("name"));
-
- Element partElement = getPartElement(input);
- if (partElement.hasAttribute("element"))
- currentInput.setAttribute("element", partElement.getAttribute("element"));
- // TBD - what if the part uses "type"?
-
- currentOperation.appendChild(currentInput);
- }
-
- private Element getPartElement(MessageReference messageRef)
- {
- Iterator iterator = messageRef.getEMessage().getEParts().iterator();
- // TBD - for now, take the first part.
- Part part = (Part)iterator.next();
- Element partElement = part.getElement();
- return partElement;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitOutput(org.eclipse.wst.wsdl.Output)
- */
- protected void visitOutput(Output output)
- {
- Element currentOutput = createWSDLElement("output");
- processDocumentation(output.getDocumentationElement(), currentOutput);
-
- Element outputElement = output.getElement();
-
- if (outputElement.hasAttribute("name"))
- currentOutput.setAttribute("messageLabel", outputElement.getAttribute("name"));
-
- Element partElement = getPartElement(output);
- if (partElement.hasAttribute("element"))
- currentOutput.setAttribute("element", partElement.getAttribute("element"));
- // TBD - what if the part uses "type"?
-
- currentOperation.appendChild(currentOutput);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitFault(org.eclipse.wst.wsdl.Fault)
- */
- protected void visitFault(Fault fault)
- {
- // TODO Auto-generated method stub
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitBinding(org.eclipse.wst.wsdl.Binding)
- */
- protected void visitBinding(Binding binding)
- {
- currentBinding = createWSDLElement("binding");
- processDocumentation(binding.getDocumentationElement(), currentBinding);
-
- Element bindingElement = binding.getElement();
- if (bindingElement.hasAttribute("name"))
- currentBinding.setAttribute("name", bindingElement.getAttribute("name"));
- if (bindingElement.hasAttribute("type"))
- currentBinding.setAttribute("interface", bindingElement.getAttribute("type"));
-
- // TBD - is the next line fixed for SOAP?
- currentBinding.setAttribute("type", "http://www.w3.org/2004/08/wsdl/soap12");
- currentBinding.setAttribute("wsoap:protocol", "http://www.w3.org/2003/05/soap/bindings/HTTP");
- currentBinding.setAttribute("wsoap:mepDefault", "http://www.w3.org.2003/05/soap/mep/request-response");
-
- description.appendChild(currentBinding);
- super.visitBinding(binding);
- }
-
- protected void visitBindingOperation(BindingOperation operation)
- {
- currentBindingOperation = createWSDLElement("operation");
- processDocumentation(operation.getDocumentationElement(), currentBindingOperation);
-
- String operationName = operation.getEOperation().getName();
-
- // Determine prefix
- String prefix = null;
- String targetNamespace = null;
- Definition def = operation.getEnclosingDefinition();
- if (def != null)
- targetNamespace = def.getTargetNamespace();
- if (targetNamespace != null)
- prefix = def.getPrefix(targetNamespace);
-
- if (prefix == null)
- prefix = "";
- else
- prefix += ":";
-
- currentBindingOperation.setAttribute("ref", prefix + operationName);
-
- currentBinding.appendChild(currentBindingOperation);
- super.visitBindingOperation(operation);
- }
-
- protected void visitBindingInput(BindingInput input)
- {
- currentBindingInput = createWSDLElement("input");
- processDocumentation(input.getDocumentationElement(), currentBindingInput);
-
- Element inputElement = input.getElement();
- String inputName = input.getName();
- if (inputName != null)
- inputElement.setAttribute("name", inputName);
-
- currentBindingOperation.appendChild(currentBindingInput);
- super.visitBindingInput(input);
- }
-
- protected void visitBindingOutput(BindingOutput output)
- {
- currentBindingOutput = createWSDLElement("output");
- processDocumentation(output.getDocumentationElement(), currentBindingOutput);
-
- Element outputElement = output.getElement();
- String outputName = output.getName();
- if (outputName != null)
- outputElement.setAttribute("name", outputName);
-
- currentBindingOperation.appendChild(currentBindingOutput);
- super.visitBindingOutput(output);
- }
-
- protected void visitBindingFault(BindingFault fault)
- {
- currentBindingFault = createWSDLElement("fault");
- processDocumentation(fault.getDocumentationElement(), currentBindingFault);
-
- Element faultElement = fault.getElement();
- String faultName = fault.getName();
- if (faultName != null)
- faultElement.setAttribute("name", faultName);
-
- currentBindingOperation.appendChild(currentBindingFault);
- super.visitBindingFault(fault);
- }
-
- protected void visitService(Service service)
- {
- currentService = createWSDLElement("service");
- processDocumentation(service.getDocumentationElement(), currentService);
-
- Element serviceElement = service.getElement();
- if (serviceElement.hasAttribute("name"))
- currentService.setAttribute("name", serviceElement.getAttribute("name"));
-
- description.appendChild(currentService);
- super.visitService(service);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitPort(org.eclipse.wst.wsdl.Port)
- */
- protected void visitPort(Port port)
- {
- currentEndpoint = createWSDLElement("endpoint");
- processDocumentation(port.getDocumentationElement(), currentEndpoint);
-
- Element portElement = port.getElement();
- if (portElement.hasAttribute("name"))
- currentEndpoint.setAttribute("name", portElement.getAttribute("name"));
- if (portElement.hasAttribute("binding"))
- currentEndpoint.setAttribute("binding", portElement.getAttribute("binding"));
-
- // Add interface to current service
- Binding binding = port.getEBinding();
- if (binding != null) // binding could not be resolved
- {
- Element bindingElement = binding.getElement();
- if (bindingElement.hasAttribute("type"))
- currentService.setAttribute("interface", bindingElement.getAttribute("type"));
- }
-
- currentService.appendChild(currentEndpoint);
- super.visitPort(port);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.wsdl.tests.util.DefinitionVisitor#visitExtensibilityElement(org.eclipse.wst.wsdl.ExtensibleElement, org.eclipse.wst.wsdl.ExtensibilityElement)
- */
- protected void visitExtensibilityElement(ExtensibleElement owner, ExtensibilityElement extensibilityElement)
- {
- // TBD - It is not just SOAP binding
- if (owner instanceof org.eclipse.wst.wsdl.internal.impl.PortImpl)
- {
- Element soapElement = extensibilityElement.getElement();
- if (soapElement.hasAttribute("location"))
- currentEndpoint.setAttribute("address", soapElement.getAttribute("location"));
- }
- else
- {
- Element domElement = extensibilityElement.getElement();
- Element adoptedDOMElement = (Element)doc.importNode(domElement, true);
-
- if (owner instanceof org.eclipse.wst.wsdl.internal.impl.DefinitionImpl)
- description.insertBefore(adoptedDOMElement, description.getFirstChild());
- else if (owner instanceof org.eclipse.wst.wsdl.internal.impl.ServiceImpl)
- currentService.insertBefore(adoptedDOMElement, currentService.getFirstChild());
- else if (owner instanceof org.eclipse.wst.wsdl.internal.impl.PortTypeImpl)
- currentInterface.insertBefore(adoptedDOMElement, currentInterface.getFirstChild());
- else if (owner instanceof org.eclipse.wst.wsdl.internal.impl.OperationImpl)
- currentOperation.insertBefore(adoptedDOMElement, currentOperation.getFirstChild());
- else if (owner instanceof org.eclipse.wst.wsdl.internal.impl.BindingImpl)
- currentBinding.insertBefore(adoptedDOMElement, currentBinding.getFirstChild());
- else if (owner instanceof org.eclipse.wst.wsdl.internal.impl.BindingOperationImpl)
- currentBindingOperation.insertBefore(adoptedDOMElement, currentBindingOperation.getFirstChild());
- else if (owner instanceof org.eclipse.wst.wsdl.internal.impl.BindingInputImpl)
- currentBindingInput.insertBefore(adoptedDOMElement, currentBindingInput.getFirstChild());
- else if (owner instanceof org.eclipse.wst.wsdl.internal.impl.BindingOutputImpl)
- currentBindingOutput.insertBefore(adoptedDOMElement, currentBindingOutput.getFirstChild());
- else if (owner instanceof org.eclipse.wst.wsdl.internal.impl.BindingFaultImpl)
- currentBindingFault.insertBefore(adoptedDOMElement, currentBindingFault.getFirstChild());
-
- }
-
- }
-
- public static Test suite()
- {
- TestSuite suite = new TestSuite();
-
- suite.addTest(new WSDLConverter("Convert")
- {
- protected void runTest()
- {
- testConvert();
- }
- });
- return suite;
- }
-
- public void testConvert()
- {
- try
- {
- Definition def = DefinitionLoader.load("d:/eclipse301/eclipse/workspace/org.eclipse.wst.wsdl.tests/PTATimeDistribution.wsdl");
- WSDLConverter converter = new WSDLConverter(def);
- converter.generate20("d:/eclipse301/eclipse/workspace/org.eclipse.wst.wsdl.tests/PTATimeDistribution20.wsdl");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
- public static void main(String[] args)
- {
- junit.textui.TestRunner.run(suite());
- /*
- try
- {
- Definition def = DefinitionLoader.load(args[0]);
- WSDLConverter converter = new WSDLConverter(def);
- converter.generate20("test20.wsdl");
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }*/
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLModelLocatorAdapterFactory.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLModelLocatorAdapterFactory.java
deleted file mode 100644
index 1757a8200..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLModelLocatorAdapterFactory.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests.util;
-
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.wsdl.internal.util.WSDLModelLocator;
-
-
-public class WSDLModelLocatorAdapterFactory extends AdapterFactoryImpl
-{
- protected CustomWSDLModelLocator customWSDLModelLocator = new CustomWSDLModelLocator();
-
- class CustomWSDLModelLocator extends AdapterImpl implements WSDLModelLocator
- {
- public String resolveURI(String baseLocation, String namespace, String location)
- {
- return URIResolverPlugin.createResolver().resolve(baseLocation, namespace, location);
- }
-
- public boolean isAdatperForType(Object type)
- {
- return type == WSDLModelLocator.class;
- }
- }
-
- public boolean isFactoryForType(Object type)
- {
- return type == WSDLModelLocator.class;
- }
-
- public Adapter adaptNew(Notifier target, Object type)
- {
- return customWSDLModelLocator;
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XMLDiff.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XMLDiff.java
deleted file mode 100644
index 55ce939bc..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XMLDiff.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests.util;
-
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-
-/**
- * @author Kihup Boo
- */
-public class XMLDiff
-{
- private PrintStream out = System.out;
-
- private boolean DIFF_ELEMENT_NODE_ONLY = false;
-
- public boolean diff(String file1, String file2) throws ParserConfigurationException, SAXException, IOException
- {
- return diff(file1, file2, false);
- }
-
- public boolean diff(String file1, String file2, boolean elementOnly) throws ParserConfigurationException, SAXException, IOException
- {
- Document doc1 = getDocument(file1);
- Document doc2 = getDocument(file2);
- DIFF_ELEMENT_NODE_ONLY = elementOnly;
- return diff(doc1, doc2);
- }
-
- public boolean diff(Document doc1, Document doc2)
- {
- Element root1 = doc1.getDocumentElement();
- Element root2 = doc2.getDocumentElement();
- return compareNodes(root1, root2);
- }
-
- private Document getDocument(String uri) throws ParserConfigurationException, SAXException, IOException
- {
- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- Document doc = builder.parse(uri);
- return doc;
- }
-
- private boolean compareNodes(Node node1, Node node2)
- {
- if (DIFF_ELEMENT_NODE_ONLY)
- {
- // Compare only element nodes in the children.
- filterNonElementNodes(node1);
- filterNonElementNodes(node2);
- }
-
- if (node1.getNodeType() != node2.getNodeType() || node1.getNodeName() != node2.getNodeName())
- {
- println("Node type or node name is different:");
- println("Node 1: " + node1.getNodeName());
- println("Node 2: " + node2.getNodeName());
- return false;
- }
-
- if (!compareAttributes(node1, node2))
- return false;
-
- NodeList nodeList1 = node1.getChildNodes();
- NodeList nodeList2 = node2.getChildNodes();
- if (nodeList1.getLength() != nodeList2.getLength())
- {
- println("The number of children is different:");
- //println("Node 1: " + nodeList1.getLength());
- //println("Node 2: " + nodeList2.getLength());
- println("Node 1: " + node1.getNodeName());
- println("Node 2: " + node2.getNodeName());
- return false;
- }
-
- boolean result = true;
- int length = nodeList1.getLength();
- for (int i = 0; i < length; i++)
- {
- result = compareNodes(nodeList1.item(i), nodeList2.item(i));
- if (!result)
- return false;
- }
- return true;
- }
-
- private void filterNonElementNodes(Node node)
- {
- Node firstChild = node.getFirstChild();
- while (firstChild.getNodeType() != Node.ELEMENT_NODE)
- {
- node.removeChild(firstChild);
- firstChild = node.getFirstChild();
- }
-
- Node sibling = firstChild.getNextSibling();
- Node deleteMe = null;
- while (sibling != null)
- {
- if (sibling.getNodeType() != Node.ELEMENT_NODE)
- {
- deleteMe = sibling;
- sibling = sibling.getNextSibling();
- node.removeChild(deleteMe);
- }
-
- }
- }
-
- private boolean compareAttributes(Node node1, Node node2)
- {
- NamedNodeMap nodeMap1 = node1.getAttributes();
- NamedNodeMap nodeMap2 = node2.getAttributes();
-
- if (nodeMap1 == null || nodeMap2 == null)
- {
- if (nodeMap1 == null && nodeMap2 == null)
- return true;
- else
- return false;
- }
-
- if (nodeMap1.getLength() != nodeMap2.getLength())
- {
- println("The number of attributes is different:");
- println("Node 1: " + node1.getNodeName());
- println("Node 2: " + node2.getNodeName());
- return false;
- }
-
- Node attrNode1 = null;
- Node attrNode2 = null;
- int length = nodeMap1.getLength();
- for (int i = 0; i < length; i++)
- {
- attrNode1 = nodeMap1.item(i);
- attrNode2 = nodeMap2.getNamedItem(attrNode1.getNodeName());
- if (attrNode2 == null)
- {
- println("The attribute is not found in Node 2: " + attrNode1.getNodeName());
- println("Node 1: " + node1.getNodeName());
- println("Node 2: " + node2.getNodeName());
- return false;
- }
- else if (!attrNode1.getNodeValue().equals(attrNode2.getNodeValue()))
- {
- println("The attribute values are different:");
- println("Node 1: " + node1.getNodeName() + "," + attrNode1.getNodeValue());
- println("Node 2: " + node2.getNodeName() + "," + attrNode2.getNodeValue());
- return false;
- }
- }
- return true;
- }
-
- private void println(String s)
- {
- out.println(s);
- }
-} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverAdapterFactory.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverAdapterFactory.java
deleted file mode 100644
index 6e9fb2854..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverAdapterFactory.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests.util;
-
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.xsd.util.XSDSchemaLocationResolver;
-
-
-public class XSDSchemaLocationResolverAdapterFactory extends AdapterFactoryImpl
-{
- protected XSDSchemaLocationResolverImpl schemaLocator = new XSDSchemaLocationResolverImpl();
-
- public boolean isFactoryForType(Object type)
- {
- return type == XSDSchemaLocationResolver.class;
- }
-
- public Adapter adaptNew(Notifier target, Object type)
- {
- return schemaLocator;
- }
-}
diff --git a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverImpl.java b/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverImpl.java
deleted file mode 100644
index 202fee5cc..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.wsdl.tests.util;
-
-
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDSchemaLocationResolver;
-import org.eclipse.xsd.util.XSDSchemaLocator;
-
-
-public class XSDSchemaLocationResolverImpl extends AdapterImpl implements XSDSchemaLocationResolver
-{
- public String resolveSchemaLocation(XSDSchema xsdSchema, String namespaceURI, String schemaLocationURI)
- {
- String baseLocation = xsdSchema.getSchemaLocation();
- return URIResolverPlugin.createResolver().resolve(baseLocation, namespaceURI, schemaLocationURI);
- }
-
- public boolean isAdatperForType(Object type)
- {
- return type == XSDSchemaLocator.class;
- }
-}

Back to the top