diff options
Diffstat (limited to 'tests/org.eclipse.wst.wsdl.tests/src')
20 files changed, 0 insertions, 4503 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 5fee2e1e6..000000000 --- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/AllTestCases.java +++ /dev/null @@ -1,48 +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()); - - return suite; - } - -} 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 587facfac..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/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/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 c329743d5..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"); // 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/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 4119daf19..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/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 922a78aa4..000000000 --- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/UtilTest.java +++ /dev/null @@ -1,280 +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 - { - WSDLConstants wsdlConstants = new WSDLConstants(); - 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/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/LoadAndPrintTest.wsdl"); - Assert.assertTrue(definition.eResource() instanceof WSDLResourceImpl); - Element element = definition.getElement(); - Document document = definition.getDocument(); - - if (element != null) - { - resourceImpl.serialize(System.out, element, null); - } - - if (document != null) - { - resourceImpl.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 f13b19d00..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/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 ed994b2e2..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/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 26a0fe153..000000000 --- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/WSDLGenerationTest.java +++ /dev/null @@ -1,260 +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; - -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/"); - - // 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 674386bcb..000000000 --- a/tests/org.eclipse.wst.wsdl.tests/src/org/eclipse/wst/wsdl/tests/util/DefinitionLoader.java +++ /dev/null @@ -1,101 +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 - { - // 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)); - 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; - } -} |