diff options
author | csalter | 2004-11-18 04:38:39 +0000 |
---|---|---|
committer | csalter | 2004-11-18 04:38:39 +0000 |
commit | 796ff8a66f7b70b2efd959d43c8ee8ecb9db1d39 (patch) | |
tree | b46ff8c71209c4535678db320cf268e788f66ff2 /tests/org.eclipse.wst.wsdl.tests.performance | |
parent | 678d2af18829ac0fbabfddd4fc84560a7d9d957b (diff) | |
download | webtools.webservices-796ff8a66f7b70b2efd959d43c8ee8ecb9db1d39.tar.gz webtools.webservices-796ff8a66f7b70b2efd959d43c8ee8ecb9db1d39.tar.xz webtools.webservices-796ff8a66f7b70b2efd959d43c8ee8ecb9db1d39.zip |
initial version using path from defect 78216
Diffstat (limited to 'tests/org.eclipse.wst.wsdl.tests.performance')
9 files changed, 504 insertions, 0 deletions
diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/.project b/tests/org.eclipse.wst.wsdl.tests.performance/.project new file mode 100644 index 000000000..322272052 --- /dev/null +++ b/tests/org.eclipse.wst.wsdl.tests.performance/.project @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.wst.wsdl.tests.performance</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + </natures> +</projectDescription> diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/data/StockQuote/StockQuote.wsdl b/tests/org.eclipse.wst.wsdl.tests.performance/data/StockQuote/StockQuote.wsdl new file mode 100644 index 000000000..80bf96545 --- /dev/null +++ b/tests/org.eclipse.wst.wsdl.tests.performance/data/StockQuote/StockQuote.wsdl @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://tempuri.org/StockQuote/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="StockQuote" targetNamespace="http://tempuri.org/StockQuote/">
+ <wsdl:types>
+ <xsd:schema targetNamespace="http://tempuri.org/StockQuote/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <xsd:element name="getQuoteResponse">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element name="tickerSymbol" type="xsd:string"/>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="getQuoteRequest">
+ <xsd:complexType>
+ <xsd:all>
+ <xsd:element name="price" type="xsd:float"/>
+ </xsd:all>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="Headers">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="header" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="name" type="xsd:string"/>
+ <xsd:element name="value" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name="getQuoteResponse">
+ <wsdl:part element="tns:getQuoteResponse" name="getQuoteResponse"/>
+ <wsdl:part element="tns:Headers" name="headers"/>
+ </wsdl:message>
+ <wsdl:message name="getQuoteRequest">
+ <wsdl:part element="tns:getQuoteRequest" name="getQuoteRequest"/>
+ <wsdl:part element="tns:Headers" name="headers"/>
+ </wsdl:message>
+ <wsdl:portType name="StockQuote">
+ <wsdl:operation name="getQuote">
+ <wsdl:input message="tns:getQuoteRequest"/>
+ <wsdl:output message="tns:getQuoteResponse"/>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name="StockQuoteSOAP" type="tns:StockQuote">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <wsdl:operation name="getQuote">
+ <soap:operation soapAction="http://tempuri.org/StockQuote/getQuote"/>
+ <wsdl:input>
+ <soap:body parts="getQuoteRequest" use="literal"/>
+ <soap:header message="tns:getQuoteRequest" part="headers" use="literal"/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body parts="getQuoteResponse" use="literal"/>
+ <soap:header message="tns:getQuoteResponse" part="headers" use="literal"/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name="StockQuote">
+ <wsdl:port binding="tns:StockQuoteSOAP" name="StockQuoteSOAP">
+ <soap:address location="http://tempuri.org"/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/AllTests.java b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/AllTests.java new file mode 100644 index 000000000..0e42e5370 --- /dev/null +++ b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/AllTests.java @@ -0,0 +1,29 @@ +/********************************************************************** + * 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.performance; + +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTests +{ + public static Test suite() + { + TestSuite suite = new TestSuite("Test for org.eclipse.wst.wsdl.tests.performance"); + //$JUnit-BEGIN$ + suite.addTestSuite(ReadStockQuoteWSDLTestCase.class); + suite.addTestSuite(OpenStockQuoteWSDLSetup.class); + suite.addTestSuite(OpenStockQuoteWSDLTestCase.class); + //$JUnit-END$ + return suite; + } +} diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenStockQuoteWSDLSetup.java b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenStockQuoteWSDLSetup.java new file mode 100644 index 000000000..5d5c4ceba --- /dev/null +++ b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenStockQuoteWSDLSetup.java @@ -0,0 +1,82 @@ +/********************************************************************** + * 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.performance; + +import java.io.IOException; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.intro.IIntroManager; +import org.eclipse.ui.intro.IIntroPart; + +public class OpenStockQuoteWSDLSetup extends TestCase +{ + public static String PROJECT_NAME = "Project"; + + public static Test suite() + { + return new TestSuite(OpenStockQuoteWSDLSetup.class, "OpenStockQuoteWSDLSetup"); + } + + protected void closeIntro() + { + IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager(); + IIntroPart introPart = introManager.getIntro(); + if (introPart != null) + introManager.closeIntro(introPart); + } + + protected IProject createSimpleProject(String name) throws CoreException + { + IProject simpleProject = ResourcesPlugin.getWorkspace().getRoot().getProject(name); + simpleProject.create(null); + simpleProject.open(null); + return simpleProject; + } + + protected void copyFile(IProject project, String source, String dest) throws IOException, CoreException + { + IFile file = project.getFile(dest); + file.create(PerformancePlugin.getDefault().getBundle().getEntry(source).openStream(), true, null); + } + + protected void joinAutoBuild() throws CoreException + { + boolean interrupted = true; + while (interrupted) + { + try + { + Platform.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); + interrupted = false; + } + catch (InterruptedException e) + { + interrupted = true; + } + } + } + + public void testSetup() throws Exception + { + closeIntro(); + IProject project = createSimpleProject(PROJECT_NAME); + copyFile(project, "data/StockQuote/StockQuote.wsdl", "StockQuote.wsdl"); + joinAutoBuild(); + } +} diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenStockQuoteWSDLTestCase.java b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenStockQuoteWSDLTestCase.java new file mode 100644 index 000000000..471912f8c --- /dev/null +++ b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenStockQuoteWSDLTestCase.java @@ -0,0 +1,88 @@ +/********************************************************************** + * 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.performance; + +import junit.framework.Test; +import junit.framework.TestSuite; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.test.performance.PerformanceTestCase; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.FileEditorInput; + +public class OpenStockQuoteWSDLTestCase extends PerformanceTestCase +{ + private final String EDITOR_ID = "org.eclipse.wst.wsdl.editor.internal.WSDLEditor"; + + public static Test suite() + { + return new TestSuite(OpenStockQuoteWSDLTestCase.class, "OpenStockQuoteWSDLTestCase"); + } + + protected IProject getProject(String projectName) throws CoreException + { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + assertTrue(project.exists()); + project.open(null); + project.refreshLocal(IProject.DEPTH_INFINITE, null); + joinAutoBuild(); + return project; + } + + protected void joinAutoBuild() throws CoreException + { + boolean interrupted = true; + while (interrupted) + { + try + { + Platform.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null); + interrupted = false; + } + catch (InterruptedException e) + { + interrupted = true; + } + } + } + + protected IEditorPart openEditor(IEditorInput editorInput, String editorid) throws PartInitException + { + IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + return workbenchWindow.getActivePage().openEditor(editorInput, editorid, true); + } + + protected boolean closeEditor(IEditorPart editor) + { + IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + return workbenchWindow.getActivePage().closeEditor(editor, false); + } + + public void testOpenStockQuoteWSDL() throws Exception + { + IProject project = getProject(OpenStockQuoteWSDLSetup.PROJECT_NAME); + IEditorInput editorInput = new FileEditorInput((IFile)project.findMember("StockQuote.wsdl")); + startMeasuring(); + IEditorPart editorPart = openEditor(editorInput, EDITOR_ID); + stopMeasuring(); + commitMeasurements(); + assertPerformance(); + closeEditor(editorPart); + } +} diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/PerformancePlugin.java b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/PerformancePlugin.java new file mode 100644 index 000000000..478f4ab6d --- /dev/null +++ b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/PerformancePlugin.java @@ -0,0 +1,83 @@ +/********************************************************************** + * 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.performance; + +import org.eclipse.core.runtime.Plugin; +import org.osgi.framework.BundleContext; +import java.util.*; + +/** + * The main plugin class to be used in the desktop. + */ +public class PerformancePlugin extends Plugin { + //The shared instance. + private static PerformancePlugin plugin; + //Resource bundle. + private ResourceBundle resourceBundle; + + /** + * The constructor. + */ + public PerformancePlugin() { + super(); + plugin = this; + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + plugin = null; + resourceBundle = null; + } + + /** + * Returns the shared instance. + */ + public static PerformancePlugin 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 = PerformancePlugin.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.performance.PerformancePluginResources"); + } catch (MissingResourceException x) { + resourceBundle = null; + } + return resourceBundle; + } +} diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/ReadStockQuoteWSDLTestCase.java b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/ReadStockQuoteWSDLTestCase.java new file mode 100644 index 000000000..a78fc6bd4 --- /dev/null +++ b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/ReadStockQuoteWSDLTestCase.java @@ -0,0 +1,41 @@ +/********************************************************************** + * 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.performance; + +import java.net.URL; +import javax.wsdl.Definition; +import javax.wsdl.xml.WSDLReader; +import junit.framework.Test; +import junit.framework.TestSuite; +import org.eclipse.test.performance.PerformanceTestCase; +import org.eclipse.wst.wsdl.internal.impl.wsdl4j.WSDLFactoryImpl; +import org.xml.sax.InputSource; + +public class ReadStockQuoteWSDLTestCase extends PerformanceTestCase +{ + public static Test suite() + { + return new TestSuite(ReadStockQuoteWSDLTestCase.class, "ReadStockQuoteWSDLTestCase"); + } + + public void testReadStockQuoteWSDL() throws Exception + { + startMeasuring(); + URL wsdl = PerformancePlugin.getDefault().getBundle().getEntry("data/StockQuote/StockQuote.wsdl"); + WSDLFactoryImpl factory = new WSDLFactoryImpl(); + WSDLReader reader = factory.newWSDLReader(); + Definition definition = reader.readWSDL(wsdl.toString(), new InputSource(wsdl.openStream())); + stopMeasuring(); + commitMeasurements(); + assertPerformance(); + } +} diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/plugin.xml b/tests/org.eclipse.wst.wsdl.tests.performance/plugin.xml new file mode 100644 index 000000000..ec3dd74fd --- /dev/null +++ b/tests/org.eclipse.wst.wsdl.tests.performance/plugin.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> +<plugin + id="org.eclipse.wst.wsdl.tests.performance" + name="WSDL Performance Plug-in" + version="1.0.0" + provider-name="" + class="org.eclipse.wst.wsdl.tests.performance.PerformancePlugin"> + + <runtime> + <library name="performance.jar"> + <export name="*"/> + </library> + </runtime> + + <requires> + <import plugin="org.junit"/> + <import plugin="org.eclipse.core.runtime"/> + <import plugin="org.eclipse.core.resources"/> + <import plugin="org.eclipse.ui"/> + <import plugin="org.eclipse.ui.ide"/> + <import plugin="org.eclipse.test.performance"/> + <import plugin="org.eclipse.wst.wsdl"/> + </requires> + +</plugin> diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/test.xml b/tests/org.eclipse.wst.wsdl.tests.performance/test.xml new file mode 100644 index 000000000..ea03944eb --- /dev/null +++ b/tests/org.eclipse.wst.wsdl.tests.performance/test.xml @@ -0,0 +1,65 @@ +<?xml version="1.0"?> + +<project name="testsuite" default="performance" basedir="."> + <!-- The property ${eclipse-home} should be passed into this script --> + <!-- Set a meaningful default value for when it is not. --> + <property name="eclipse-home" value="${basedir}\..\.."/> + + <!-- sets the properties eclipse-home, and library-file --> + <property name="plugin-name" value="org.eclipse.wst.wsdl.tests.performance"/> + <property name="library-file" + value="${eclipse-home}/plugins/org.eclipse.test_3.1.0/library.xml"/> + + <property name="workspace" value="${eclipse-home}/workspace_wsdl_performance"/> + + <!-- This target holds all initialization code that needs to be done for --> + <!-- all tests that are to be run. Initialization for individual tests --> + <!-- should be done within the body of the suite target. --> + <target name="init"> + <tstamp/> + <delete> + <fileset dir="${eclipse-home}" includes="org.eclipse.wst.wsdl.tests.performance*.xml"/> + </delete> + </target> + + <!-- This target defines the performance tests that need to be run. --> + <target name="performance_suite"> + + <delete dir="${workspace}" quiet="true"/> + <ant target="core-test" antfile="${library-file}" dir="${eclipse-home}"> + <property name="data-dir" value="${workspace}"/> + <property name="plugin-name" value="${plugin-name}"/> + <property name="classname" value="org.eclipse.wst.wsdl.tests.performance.ReadStockQuoteWSDLTestCase"/> + </ant> + + <delete dir="${workspace}" quiet="true"/> + <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}"> + <property name="data-dir" value="${workspace}"/> + <property name="plugin-name" value="${plugin-name}"/> + <property name="classname" value="org.eclipse.wst.wsdl.tests.performance.OpenStockQuoteWSDLSetup"/> + </ant> + <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}"> + <property name="data-dir" value="${workspace}"/> + <property name="plugin-name" value="${plugin-name}"/> + <property name="classname" value="org.eclipse.wst.wsdl.tests.performance.OpenStockQuoteWSDLTestCase"/> + </ant> + + </target> + + <!-- This target holds code to cleanup the testing environment after --> + <!-- after all of the tests have been run. You can use this target to --> + <!-- delete temporary files that have been created. --> + <target name="cleanup"> + <delete dir="${workspace}" quiet="true"/> + </target> + + <!-- This target runs the performance test suite. Any actions that need to happen --> + <!-- after all the tests have been run should go here. --> + <target name="performance" depends="init,performance_suite,cleanup"> + <ant target="collect" antfile="${library-file}" dir="${eclipse-home}"> + <property name="includes" value="org.eclipse.wst.wsdl.tests.performance*.xml"/> + <property name="output-file" value="${plugin-name}.xml"/> + </ant> + </target> + +</project> |