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/eclipse')
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/AllTestCases.java50
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java684
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/InlineSchemaTest.java226
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LoadAndSerializationTest.java241
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LocationTrackingTest.java106
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/MyResolver.java33
-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.java230
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/SemanticTest.java513
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/UtilTest.java279
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDL4JAPITest.java458
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLEMFAPITest.java612
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLGenerationTest.java267
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLTestsPlugin.java109
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionLoader.java107
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionVisitor.java211
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDL4JDefinitionVisitor.java223
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLConverter.java608
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLModelLocatorAdapterFactory.java46
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XMLDiff.java169
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverAdapterFactory.java31
-rw-r--r--tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverImpl.java31
22 files changed, 0 insertions, 5307 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 0851bb2fa..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/AllTestCases.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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 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();
-
- // Bug 123547 - comment out this test for now.
- // 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());
-
- 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 6ac4255a4..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/BugFixesTest.java
+++ /dev/null
@@ -1,684 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM 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 javax.wsdl.OperationType;
-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.Definition;
-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.Part;
-import org.eclipse.wst.wsdl.PortType;
-import org.eclipse.wst.wsdl.Service;
-import org.eclipse.wst.wsdl.Types;
-import org.eclipse.wst.wsdl.WSDLFactory;
-import org.eclipse.wst.wsdl.WSDLPackage;
-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.WSDLResourceFactoryImpl;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDImport;
-import org.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.XSDTypeDefinition;
-import org.eclipse.xsd.util.XSDConstants;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-import org.w3c.dom.Attr;
-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();
- }
- });
-
- return suite;
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl()); //$NON-NLS-1$
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
- // Silences unused variable warning.
- pkg.eClass();
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl()); //$NON-NLS-1$
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- // Silences unused variable warning.
- xsdpkg.eClass();
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- /**
- * 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=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);
- }
-} \ No newline at end of file
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 b1d2db548..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/InlineSchemaTest.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.IOException;
-import java.net.URL;
-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.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.Import;
-import org.eclipse.wst.wsdl.Types;
-import org.eclipse.wst.wsdl.WSDLPackage;
-import org.eclipse.wst.wsdl.internal.impl.wsdl4j.WSDLFactoryImpl;
-import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDPackage;
-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.eclipse.xsd.util.XSDResourceFactoryImpl;
-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(InlineSchemaTest.class);
- 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;
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- 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 def = myImport.getEDefinition();
- traverseDefinition(def);
- }
-
- 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 loadDefinition(String wsdlFile) throws IOException
- {
- return DefinitionLoader.load(wsdlFile);
- }
-
- private Definition loadDefinitionForWSDL4J(String wsdlFile) throws Exception
- {
- WSDLReader reader = (new WSDLFactoryImpl()).newWSDLReader();
- IPluginDescriptor pd = Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.wst.wsdl.tests");
- URL url = pd.getInstallURL();
- url = new URL(url,wsdlFile);
- String s = Platform.resolve(url).getFile();
- 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 a7ba14ea3..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LoadAndSerializationTest.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.emf.ecore.resource.Resource;
-import org.eclipse.wst.wsdl.Definition;
-import org.eclipse.wst.wsdl.WSDLPackage;
-import org.eclipse.wst.wsdl.internal.impl.DefinitionImpl;
-import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
-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.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-import org.w3c.dom.Element;
-
-/**
- * @author Kihup Boo
- */
-public class LoadAndSerializationTest extends TestCase
-{
- {
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- private String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
- private String TEST_DATA_DIR;
-
- //static private File[] wsdls;
- 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 fe94ed085..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/LocationTrackingTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM 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 4ccaa4dab..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/MyResolver.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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 474d9854c..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, 2004 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 16c2962af..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/RefactoringTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.WSDLPackage;
-import org.eclipse.wst.wsdl.binding.soap.internal.util.SOAPConstants;
-import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-import org.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-
-public class RefactoringTest extends TestCase
-{
- public RefactoringTest()
- {
- //init();
- }
-
- 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("RefactoringTest.wsdl");
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- // 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,"Temparature"));
- 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(), "GetTemparatureInput"));
- 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(), "GetTemparatureOutput"));
- 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(),"GetTemparatureInfoSOAP"));
- 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 d4852a913..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/SemanticTest.java
+++ /dev/null
@@ -1,513 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.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.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.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.WSDLPackage;
-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.internal.util.WSDLResourceFactoryImpl;
-import org.eclipse.wst.wsdl.tests.util.DefinitionLoader;
-import org.eclipse.wst.wsdl.tests.util.DefinitionVisitor;
-import org.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-import org.w3c.dom.Element;
-
-/**
- * @author Kihup Boo
- */
-public class SemanticTest extends DefinitionVisitor
-{
- private String PLUGIN_ABSOLUTE_PATH = WSDLTestsPlugin.getInstallURL();
- //private String wsdlNamespacePrefix;
- //private String xsdNamespacePrefix;
-
- {
- // This is needed because we don't have the following in the plugin.xml
- //
- // <extension point = "org.eclipse.emf.extension_parser">
- // <parser type="wsdl" class="com.ibm.etools.wsdl.util.WSDLResourceFactoryImpl"/>
- // </extension>
- //
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- // 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...");
- }
-
- 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)
- {
- 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 407618b24..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/UtilTest.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.WSDLPackage;
-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.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-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;
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- 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 88da8fc5c..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDL4JAPITest.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.net.URL;
-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.wsdl.xml.WSDLWriter;
-import javax.xml.namespace.QName;
-
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.wst.wsdl.WSDLPackage;
-import org.eclipse.wst.wsdl.WSDLPlugin;
-import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
-import org.eclipse.wst.wsdl.tests.util.WSDL4JDefinitionVisitor;
-import org.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-import org.w3c.dom.Element;
-import org.xml.sax.InputSource;
-
-/**
- * @author Kihup Boo
- */
-public class WSDL4JAPITest extends WSDL4JDefinitionVisitor
-{
- 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;
-
- {
- // This is needed because we don't have the following in the plugin.xml
- //
- // <extension point = "org.eclipse.emf.extension_parser">
- // <parser type="wsdl" class="com.ibm.etools.wsdl.util.WSDLResourceFactoryImpl"/>
- // </extension>
- //
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- // Added for JUnit
- public WSDL4JAPITest(String name)
- {
- super(name);
- }
-
- /**
- * @param definition
- */
- public WSDL4JAPITest(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);
- }
-
- 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 ee = null;
- while (iterator.hasNext())
- {
- ee = (ExtensibilityElement)iterator.next();
- myTypes.addExtensibilityElement(ee);
- }*/
- 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);
- }
-
- // Need 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 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 def, String clonedFile) throws Exception
- {
- WSDLWriter writer = factory.newWSDLWriter();
- IPluginDescriptor pd = Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.wst.wsdl.tests");
- URL url = pd.getInstallURL();
- //System.out.println(url.toString());
- url = new URL(url,clonedFile);
- //System.out.println(url.toString());
- //String s = Platform.resolve(url).getFile();
- //System.out.println(Platform.getInstanceLocation().getURL().toString());
- //String s = url.toString();
- //System.out.println(s);
- //writer.writeWSDL(def,new FileOutputStream(s));
- }
-
- private Definition loadDefinitionForWSDL4J(String wsdlFile) throws Exception
- {
- WSDLReader reader = factory.newWSDLReader();
- IPluginDescriptor pd = Platform.getPluginRegistry().getPluginDescriptor("org.eclipse.wst.wsdl.tests");
- URL url = pd.getInstallURL();
- url = new URL(url,wsdlFile);
- String s = Platform.resolve(url).getFile();
- //System.out.println("loading " + s);
- 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 671466acc..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLEMFAPITest.java
+++ /dev/null
@@ -1,612 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.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.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.WSDLPackage;
-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;
-import org.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-import org.w3c.dom.Element;
-
-/**
- * @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;
-
- {
- // This is needed because we don't have the following in the plugin.xml
- //
- // <extension point = "org.eclipse.emf.extension_parser">
- // <parser type="wsdl" class="com.ibm.etools.wsdl.util.WSDLResourceFactoryImpl"/>
- // </extension>
- //
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- // Added for JUnit
- public WSDLEMFAPITest(String name)
- {
- super(name);
- }
-
- /**
- * @param definition
- */
- public WSDLEMFAPITest(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)
- {
- // 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 boolean soapOperationVisited = false;
- private void visitSOAPOperation(SOAPOperation soapOperation)
- {
- soapOperationVisited = true;
- SOAPOperation mySoapOperation = SOAPFactory.eINSTANCE.createSOAPOperation();
- mySoapOperation.setSoapActionURI(soapOperation.getSoapActionURI());
- mySoapOperation.setStyle(soapOperation.getStyle());
- }
-
- //Needs to improve this part
- private boolean soapBodyVisited = false;
- private void visitSOAPBody(SOAPBody soapBody)
- {
- soapBodyVisited = true;
- SOAPBody mySoapBody = SOAPFactory.eINSTANCE.createSOAPBody();
- mySoapBody.setEncodingStyles(soapBody.getEncodingStyles());
- mySoapBody.setNamespaceURI(soapBody.getNamespaceURI());
- mySoapBody.setParts(soapBody.getParts());
- mySoapBody.setUse(soapBody.getUse());
- }
-
- //Needs to improve this part
- private boolean soapBindingVisited = false;
- private void visitSOAPBinding(SOAPBinding soapBinding)
- {
- soapBindingVisited = true;
- SOAPBinding mySoapBinding = SOAPFactory.eINSTANCE.createSOAPBinding();
- mySoapBinding.setStyle(soapBinding.getStyle());
- mySoapBinding.setTransportURI(soapBinding.getTransportURI());
- }
-
- // Needs to improve this part
- private boolean soapAddressVisited = false;
- private void visitSOAPAddress(SOAPAddress soapAddress)
- {
- soapAddressVisited = true;
- 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 5f25a785a..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLGenerationTest.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.WSDLPackage;
-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.util.SOAPConstants;
-import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
-import org.eclipse.wst.wsdl.util.WSDLConstants;
-import org.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-import org.eclipse.wst.wsdl.binding.soap.internal.impl.SOAPBodyImpl;
-
-public class WSDLGenerationTest extends TestCase
-{
- public WSDLGenerationTest()
- {
- init();
- }
-
- 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("./TemperatureService.wsdl");
- }
- catch (Exception e)
- {
- Assert.fail("Test failed due to an exception: " + e.getLocalizedMessage());
- }
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- 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,"Temparature"));
- 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(), "GetTemparatureInput"));
- 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(), "GetTemparatureOutput"));
- 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(),"GetTemparatureInfoSOAP"));
- 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(), "GetTemparatureInfoSOAP"));
- 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);
-
- }
-
- private void init()
- {
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
- }
-
-}
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 0bb5f4f5b..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLTestsPlugin.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2004 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 org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-import java.io.IOException;
-import java.util.*;
-
-/**
- * The main plugin 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 = null;
-
- /**
- * 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 plugin.
- *
- * @return the install url of this plugin
- */
- public static String getInstallURL()
- {
- try
- {
- return Platform.resolve(pluginBundle.getEntry("/")).getFile();
- }
- catch (IOException e)
- {
- return null;
- }
- }
-
-}
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 6abed7718..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionLoader.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.WSDLPackage;
-import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
-import org.eclipse.wst.wsdl.util.WSDLResourceImpl;
-import org.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-
-/**
- * @author Kihup Boo
- */
-public final class DefinitionLoader
-{
- {
- // This is needed because we don't have the following in the plugin.xml
- //
- // <extension point = "org.eclipse.emf.extension_parser">
- // <parser type="wsdl" class="com.ibm.etools.wsdl.util.WSDLResourceFactoryImpl"/>
- // </extension>
- //
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- /**
- * 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 4b139a6f2..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionVisitor.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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;
-
- /**
- * Use DefinitionVisitor(Definition definition)
- */
- private DefinitionVisitor()
- {
- }
-
- // 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 ba7fa2dd3..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDL4JDefinitionVisitor.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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;
-
- /**
- * Use DefinitionVisitor(Definition definition)
- */
- private WSDL4JDefinitionVisitor()
- {
- }
-
- // 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 9247256d4..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLConverter.java
+++ /dev/null
@@ -1,608 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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.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.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.wst.wsdl.WSDLPackage;
-import org.eclipse.wst.wsdl.internal.util.WSDLResourceFactoryImpl;
-import org.eclipse.xsd.XSDPackage;
-import org.eclipse.xsd.XSDSchema;
-import org.eclipse.xsd.util.XSDResourceFactoryImpl;
-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;
-
- {
- // This is needed because we don't have the following in the plugin.xml
- //
- // <extension point = "org.eclipse.emf.extension_parser">
- // <parser type="wsdl" class="com.ibm.etools.wsdl.util.WSDLResourceFactoryImpl"/>
- // </extension>
- //
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("wsdl", new WSDLResourceFactoryImpl());
- WSDLPackage pkg = WSDLPackage.eINSTANCE;
-
- // We need this for XSD <import>.
- Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xsd", new XSDResourceFactoryImpl());
- XSDPackage xsdpkg = XSDPackage.eINSTANCE;
- }
-
- // 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);
-
- Element operationElement = operation.getElement();
- 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 a4c5b3bc8..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/WSDLModelLocatorAdapterFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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;
- }
-} \ No newline at end of file
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 907a3306e..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XMLDiff.java
+++ /dev/null
@@ -1,169 +0,0 @@
-package org.eclipse.wst.wsdl.tests.util;
-
-import org.w3c.dom.*;
-import org.xml.sax.SAXException;
-
-import java.io.*;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-/**
- * @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 print(String s)
- {
- out.print(s);
- }
-
- private void println(String s)
- {
- out.println(s);
- }
-}
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 5bbba8750..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverAdapterFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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 7a4387a09..000000000
--- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/XSDSchemaLocationResolverImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 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