Skip to main content

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

summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenEditorOAGISWSDLTestcase.java129
-rw-r--r--tests/org.eclipse.wst.wsdl.tests.performance/test.xml19
2 files changed, 148 insertions, 0 deletions
diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenEditorOAGISWSDLTestcase.java b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenEditorOAGISWSDLTestcase.java
new file mode 100644
index 000000000..8db0bd5c1
--- /dev/null
+++ b/tests/org.eclipse.wst.wsdl.tests.performance/performance/org/eclipse/wst/wsdl/tests/performance/OpenEditorOAGISWSDLTestcase.java
@@ -0,0 +1,129 @@
+package org.eclipse.wst.wsdl.tests.performance;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import javax.wsdl.WSDLException;
+import junit.framework.Assert;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResourceProxy;
+import org.eclipse.core.resources.IResourceProxyVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.test.performance.Dimension;
+import org.eclipse.test.performance.PerformanceTestCase;
+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 OpenEditorOAGISWSDLTestcase extends PerformanceTestCase
+{
+ private final String ID_WSDL_EDITOR = "org.eclipse.wst.wsdl.ui.internal.WSDLEditor";
+
+ public void testReadWSDL() throws MalformedURLException, WSDLException, CoreException, FileNotFoundException
+ {
+ String oagis80Dir = System.getProperty("oagis80Dir");
+ Assert.assertNotNull(oagis80Dir);
+ if (!oagis80Dir.endsWith("/") && !oagis80Dir.endsWith("\\"))
+ oagis80Dir = oagis80Dir + "/";
+ File dir = new File(oagis80Dir);
+ if (dir.exists() && dir.isDirectory())
+ {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("sp");
+ project.create(null);
+ project.open(null);
+ copy(dir, project);
+ joinBackgroundJobs();
+ final List wsdls = new ArrayList();
+ project.accept
+ (
+ new IResourceProxyVisitor()
+ {
+ public boolean visit(IResourceProxy proxy) throws CoreException
+ {
+ if (proxy.getName().endsWith(".wsdl"))
+ {
+ wsdls.add(proxy.requestResource());
+ }
+ return true;
+ }
+ },
+ IContainer.INCLUDE_PHANTOMS
+ );
+ tagAsSummary("Open WSDL Editor", new Dimension[] {Dimension.ELAPSED_PROCESS, Dimension.WORKING_SET});
+ startMeasuring();
+ for (Iterator it = wsdls.iterator(); it.hasNext();)
+ openWSDL((IFile)it.next());
+ stopMeasuring();
+ commitMeasurements();
+ assertPerformance();
+ }
+ else
+ fail(dir.toString());
+ }
+
+ private void copy(File src, IContainer dest) throws CoreException, FileNotFoundException
+ {
+ File[] children = src.listFiles();
+ for (int i = 0; i < children.length; i++)
+ {
+ String name = children[i].getName();
+ if (children[i].isDirectory())
+ {
+ IFolder folder = dest.getFolder(new Path(name));
+ folder.create(true, true, null);
+ copy(children[i], folder);
+ }
+ else if (name.endsWith(".wsdl") || name.endsWith(".xsd"))
+ {
+ IFile file = dest.getFile(new Path(name));
+ file.create(new FileInputStream(children[i]), true, null);
+ }
+ }
+ }
+
+ private void joinBackgroundJobs()
+ {
+ Display.getDefault().syncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ Platform.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_BUILD, null);
+ }
+ catch (InterruptedException e)
+ {
+ }
+ long start = System.currentTimeMillis();
+ Display display = Display.getDefault();
+ while (System.currentTimeMillis() - start < 5000)
+ {
+ if (!display.readAndDispatch())
+ {
+ display.sleep();
+ }
+ }
+ }
+ });
+ }
+
+ private void openWSDL(IFile file) throws PartInitException
+ {
+ IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ IEditorPart editor = workbenchWindow.getActivePage().openEditor(new FileEditorInput(file), ID_WSDL_EDITOR, true);
+ workbenchWindow.getActivePage().closeEditor(editor, false);
+ }
+} \ No newline at end of file
diff --git a/tests/org.eclipse.wst.wsdl.tests.performance/test.xml b/tests/org.eclipse.wst.wsdl.tests.performance/test.xml
index 3a781b62e..e4b18f4c5 100644
--- a/tests/org.eclipse.wst.wsdl.tests.performance/test.xml
+++ b/tests/org.eclipse.wst.wsdl.tests.performance/test.xml
@@ -35,6 +35,15 @@
<antcall target="readOAGISWSDLTestcase"/>
<antcall target="readOAGISWSDLTestcase"/>
+ <antcall target="openEditorOAGISWSDLTestcase"/>
+ <antcall target="openEditorOAGISWSDLTestcase"/>
+ <antcall target="openEditorOAGISWSDLTestcase"/>
+ <antcall target="openEditorOAGISWSDLTestcase"/>
+ <antcall target="openEditorOAGISWSDLTestcase"/>
+ <antcall target="openEditorOAGISWSDLTestcase"/>
+ <antcall target="openEditorOAGISWSDLTestcase"/>
+ <antcall target="openEditorOAGISWSDLTestcase"/>
+
<delete dir="${workspace}" quiet="true"/>
<ant target="core-test" antfile="${library-file}" dir="${eclipse-home}">
<property name="data-dir" value="${workspace}"/>
@@ -66,6 +75,16 @@
</ant>
</target>
+ <target name="openEditorOAGISWSDLTestcase">
+ <delete dir="${workspace}" quiet="true"/>
+ <ant target="core-test" antfile="${perf-tests-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.OpenEditorOAGISWSDLTestcase"/>
+ <property name="extraVMargs" value="${extraVMargs}"/>
+ </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. -->

Back to the top