Author: jlukas(a)redhat.com
Date: 2010-11-04 09:19:02 -0400 (Thu, 04 Nov 2010)
New Revision: 26249
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSClient.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/Action.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/NewFileWizardAction.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/NewSampleWSWizardAction.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/TreeItemAction.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/SampleWSWizard.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/Wizard.java
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.classpath
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.settings/org.eclipse.jdt.core.prefs
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JbossWSTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/SampleWebService.java
Log:
updated test for sample ws wizards
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.classpath
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.classpath 2010-11-04 13:09:57 UTC (rev
26248)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.classpath 2010-11-04 13:19:02 UTC (rev
26249)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="resources"/>
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.settings/org.eclipse.jdt.core.prefs 2010-11-04
13:09:57 UTC (rev 26248)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/.settings/org.eclipse.jdt.core.prefs 2010-11-04
13:19:02 UTC (rev 26249)
@@ -1,8 +1,8 @@
-#Mon Aug 31 15:12:26 CEST 2009
+#Wed Nov 03 12:20:34 CET 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.source=1.6
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF 2010-11-04 13:09:57
UTC (rev 26248)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF 2010-11-04 13:19:02
UTC (rev 26249)
@@ -22,7 +22,7 @@
org.jboss.tools.tests,
org.eclipse.wst.common.project.facet.core
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Eclipse-RegisterBuddy: org.apache.log4j
Bundle-ClassPath: .
Export-Package: org.jboss.tools.ws.ui.bot.test
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JbossWSTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JbossWSTest.java 2010-11-04
13:09:57 UTC (rev 26248)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JbossWSTest.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -1,5 +1,16 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.ws.ui.bot.test;
+import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
@@ -10,7 +21,6 @@
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.Class;
import
org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.JavaEEEnterpriseApplicationProject;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebDynamicWebProject;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWebService;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWebServiceClient;
import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServlet;
@@ -18,6 +28,8 @@
import org.jboss.tools.ui.bot.ext.parts.SWTBotHyperlinkExt;
import org.jboss.tools.ui.bot.ext.parts.SWTBotScaleExt;
import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ws.ui.bot.test.uiutils.actions.NewFileWizardAction;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.DynamicWebProjectWizard;
import org.junit.runner.RunWith;
@RunWith(SWTBotJunit4ClassRunner.class)
@@ -26,12 +38,6 @@
public static final String EAR_PROJECT_NAME="EAR";
public static final String PKG_NAME="jbossws";
- public static final String SAMPLE_WS_PROJ_NAME="SampleWS";
- public static final String SAMPLE_WS_SERVICE_NAME="HelloWorld";
- public static final String
SAMPLE_WS_WSDL_URL="http://localhost:8080/"+SAMPLE_WS_PROJ_NAME+"/"+SAMPLE_WS_SERVICE_NAME+"?wsdl";
- public static final String SAMPLE_WSCLIENT_PROJ_NAME = "SampleWSClient";
- public static final String SAMPLE_WSCLIENT_SERVLET_NAME = "SampleWStest";
- public static final String SAMPLE_WSCLIENT_SERVLET_URL =
"http://localhost:8080/"+SAMPLE_WSCLIENT_PROJ_NAME+"/"+SAMPLE_WSCLIENT_SERVLET_NAME;
public static final String CLASS_A="ClassA";
public static final String CLASS_B="ClassB";
public static final String CLASS_C="ClassC";
@@ -63,6 +69,12 @@
public static final int SERVICE_SCALE_TEST=0;
protected static Map<Integer,String> wizardConfigTexts = new HashMap<Integer,
String>();
+ private static final String SOAP_REQUEST_TEMPLATE = "<?xml
version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"
?>" +
+ "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"" +
+ "
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" +
+ "
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
+ "<soap:Body>{0}</soap:Body>" +
+ "</soap:Envelope>";;
public JbossWSTest() {
@@ -144,9 +156,9 @@
}
protected void createProject(String name) {
- SWTBot wiz = open.newObject(WebDynamicWebProject.LABEL);
- wiz.textWithLabel(WebDynamicWebProject.TEXT_PROJECT_NAME).setText(name);
- open.finish(wiz);
+ new NewFileWizardAction().run().selectTemplate("Web", "Dynamic Web
Project").next();
+ new DynamicWebProjectWizard().setProjectName(name).finish();
+ util.waitForNonIgnoredJobs();
assertTrue(projectExplorer.existsResource(name));
projectExplorer.selectProject(name);
}
@@ -198,4 +210,9 @@
+ servletReturned, servletRetOK);
}
+
+ public static String getSoapRequest(String body) {
+ return MessageFormat.format(SOAP_REQUEST_TEMPLATE, body);
+ }
+
}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/SampleWebService.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/SampleWebService.java 2010-11-04
13:09:57 UTC (rev 26248)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/SampleWebService.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -1,49 +1,229 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.ws.ui.bot.test;
-import org.eclipse.swtbot.swt.finder.SWTBot;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+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.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerType;
import org.jboss.tools.ui.bot.ext.gen.ActionItem;
-import
org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.JBossToolsCreateaSampleWebService;
+import org.jboss.tools.ws.ui.bot.test.uiutils.actions.NewSampleWSWizardAction;
+import org.jboss.tools.ws.ui.bot.test.uiutils.actions.TreeItemAction;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.SampleWSWizard;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.SampleWSWizard.Type;
+import org.junit.AfterClass;
import org.junit.Test;
@SWTBotTestRequires(server=@Server(),perspective="Java EE")
public class SampleWebService extends JbossWSTest {
+ private static final String SOAP_REQUEST = getSoapRequest("<ns1:sayHello
xmlns:ns1=\"http://{0}/\"><arg0>{1}</arg0></ns1:sayHello>");
+ private static final String SERVER_URL = "localhost:8080";
+ private static final Logger L = Logger.getLogger(SampleWebService.class.getName());
+
+ @AfterClass
+ public static void cleanup() {
+ servers.removeAllProjectsFromServer();
+ projectExplorer.deleteAllProjects();
+ }
+
+ @Test
+ public void testSampleSoapWS() {
+ String project = "SampleSOAPWS";
+ createProject(project);
+ IFile dd = getDD(project);
+ if (!dd.exists()) {
+ createDD(project);
+ }
+ assertTrue(dd.exists());
+ createSampleSOAPWS(project, "HelloService", "sample",
"SampleService");
+ checkSOAPService(project, "HelloService", "sample",
"SampleService", "You");
+ createSampleSOAPWS(project, "GreetService", "greeter",
"Greeter");
+ checkSOAPService(project, "GreetService", "greeter",
"Greeter", "Tester");
+ }
+
@Test
- public void sampleWebService() {
- console.show().toolbarToggleButton("Show Console When Standard Out
Changes").deselect();
- console.show().toolbarToggleButton("Show Console When Standard Error
Changes").deselect();
- int testlevel = 3;
- for (int i=0;i<testlevel;i++) {
- sampleWebService(i);
+ public void testSampleRestWS() {
+ if ("JBOSS_AS".equals(configuredState.getServer().type)) {
+ fail("This test requires RESTEasy jars in the server");
}
+ String project = "SampleRESTWS";
+ createProject(project);
+ IFile dd = getDD(project);
+ if (!dd.exists()) {
+ createDD(project);
+ }
+ assertTrue(dd.exists());
+ createSampleRESTWS(project, "RESTSample", "rest.sample",
"Sample", "RESTApp");
+ checkRESTService(project, "RESTSample", "rest.sample",
"Sample", "You", "RESTApp");
}
+
+ private void createDD(String project) {
+ SWTBotTree tree = projectExplorer.tree();
+ SWTBotTreeItem ti = tree.expandNode(project);
+ bot.sleep(500);
+ ti = ti.getNode("Deployment Descriptor: " + project);
+ new TreeItemAction(ti, "Generate Deployment Descriptor Stub").run();
+ util.waitForNonIgnoredJobs();
+ }
+
+ private void createSampleSOAPWS(String project, String name, String pkg, String cls) {
+ createSampleService(Type.SOAP, project, name, pkg, cls, null);
+ }
- private void sampleWebService(int clientType) {
- log.info(" * Running test with ClientType:
'"+wizardConfigTexts.get(clientType)+"'");
- createEARProject(EAR_PROJECT_NAME);
- createProject(SAMPLE_WS_PROJ_NAME);
- SWTBot wiz = open.newObject(JBossToolsCreateaSampleWebService.LABEL);
- wiz.comboBox().setText(SAMPLE_WS_PROJ_NAME);
- open.finish(wiz);
+ private void checkSOAPService(String project, String svcName, String svcPkg, String
svcClass, String msgContent) {
+ checkService(Type.SOAP, project, svcName, svcPkg, svcClass, msgContent, null);
+ }
+
+ private void checkRESTService(String project, String svcName, String svcPkg, String
svcClass, String msgContent, String appCls) {
+ checkService(Type.REST, project, svcName, svcPkg, svcClass, msgContent, appCls);
+ }
+
+ private void createSampleRESTWS(String project, String name, String pkg, String cls,
String appCls) {
+ createSampleService(Type.REST, project, name, pkg, cls, appCls);
+ }
+
+ private void createSampleService(Type type, String project, String name, String pkg,
String cls, String appCls) {
+ SampleWSWizard w = new NewSampleWSWizardAction(type).run();
+ w.setProjectName(project).setServiceName(name);
+ w.setPackageName(pkg).setClassName(cls);
+ if (type == Type.REST) {
+ w.setApplicationClassName(appCls);
+ }
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ }
+
+ private void runProject(String project) {
open.viewOpen(ActionItem.View.ServerServers.LABEL);
- projectExplorer.runOnServer(SAMPLE_WS_PROJ_NAME);
- // browse WSDL
- assertServiceDeployed(SAMPLE_WS_WSDL_URL);
- // create and run WS Sample Client
- createClient(SAMPLE_WSCLIENT_PROJ_NAME, SAMPLE_WSCLIENT_SERVLET_NAME,
SAMPLE_WS_WSDL_URL, clientType);
- // re run project
- if (clientType<=CLIENT_SCALE_DEPLOY) {
- servers.removeProjectFromServers(EAR_PROJECT_NAME);
+ projectExplorer.runOnServer(project);
+ bot.sleep(5000);
+ }
+
+ private void checkService(Type type, String project, String svcName, String svcPkg,
String svcClass, String msgContent, String appCls) {
+ //"RESTSample", "rest.sample", "Sample",
"RESTApp"
+ SWTBotEditor ed = bot.activeEditor();
+ assertEquals(svcClass + ".java", ed.getTitle());
+ String code = ed.toTextEditor().getText();
+ assertContains("package " + svcPkg + ";", code);
+ String dd = readFile(getDD(project));
+ switch (type) {
+ case REST:
+ assertContains("@Path(\"/" + svcName + "\")", code);
+ assertContains("@GET()", code);
+ assertContains("@Produces(\"text/plain\")", code);
+ assertContains("<servlet-name>Resteasy</servlet-name>", dd);
+ assertContains("<param-value>" + svcPkg + "." + appCls +
"</param-value>", dd);
+ break;
+ case SOAP:
+ assertContains("<servlet-name>" + svcName +
"</servlet-name>", dd);
+ break;
}
- projectExplorer.runOnServer(SAMPLE_WSCLIENT_PROJ_NAME);
- assertServiceResponseToClient(SAMPLE_WSCLIENT_SERVLET_URL, "abcdefg");
- servers.removeAllProjectsFromServer(configuredState.getServer().name);
- assertServiceNotDeployed(SAMPLE_WS_WSDL_URL);
- servers.removeAllProjectsFromServer();
- projectExplorer.deleteAllProjects();
+ runProject(project);
+ switch (type) {
+ case REST:
+ try {
+ URL u = new URL("http://" + SERVER_URL + "/" + project +
"/" + svcName);
+ String s = readStream(u.openConnection().getInputStream());
+ assertEquals("Hello World!", s);
+ } catch (MalformedURLException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } catch (IOException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ }
+ break;
+ case SOAP:
+ try {
+ WSClient c = new WSClient(new URL("http://" + SERVER_URL + "/" +
project + "/" + svcName),
+ new QName("http://" + svcPkg + "/", svcClass +
"Service"),
+ new QName("http://" + svcPkg + "/", svcClass +
"Port"));
+ assertContains("Hello " + msgContent + "!",
c.callService(MessageFormat.format(SOAP_REQUEST, svcPkg, msgContent)));
+ } catch (MalformedURLException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ }
+ break;
+ }
}
+
+ private IProject getProject(String project) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(project);
+ }
+
+ private IFile getDD(String project) {
+ return getProject(project).getFile("WebContent/WEB-INF/web.xml");
+ }
+
+ private String readFile(IFile file) {
+ try {
+ return readStream(file.getContents());
+ } catch (CoreException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ }
+ return "";
+ }
+
+ private String readStream(InputStream is) {
+ Reader r = null;
+ Writer w = null;
+ try {
+ char[] buffer = new char[1024];
+ r = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+ w = new StringWriter();
+ int n;
+ while ((n = r.read(buffer)) != -1) {
+ w.write(buffer, 0, n);
+ }
+ } catch (IOException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } finally {
+ if (r != null) {
+ try {
+ r.close();
+ } catch (IOException e) {
+ //ignore
+ L.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+ if (w != null) {
+ try {
+ w.close();
+ } catch (IOException e) {
+ //ignore
+ L.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+ }
+ return w != null ? w.toString() : "";
+ }
}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSClient.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSClient.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSClient.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.bot.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.AttachmentPart;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.MimeHeaders;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+
+public class WSClient {
+
+ private Dispatch<SOAPMessage> d;
+
+ public WSClient(URL location, QName serviceName, QName portName) {
+ Service s = Service.create(location, serviceName);
+ d = s.createDispatch(portName, SOAPMessage.class, Mode.MESSAGE);
+ }
+
+ public String callService(String message) {
+ SOAPMessage result = null;
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ try {
+ SOAPMessage msg = MessageFactory.newInstance().createMessage( null, new
ByteArrayInputStream(message.getBytes()));
+ msg.saveChanges();
+ result = d.invoke(msg);
+ result.writeTo(out);
+ } catch (IOException e) {
+ e.printStackTrace(System.err);
+ } catch (SOAPException e) {
+ e.printStackTrace(System.err);
+ } finally {
+ try {
+ out.close();
+ } catch (IOException e) {
+ //ignore
+ }
+ }
+ return out.toString();
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/Action.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/Action.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/Action.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.bot.test.uiutils.actions;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+
+public abstract class Action<T> {
+
+ private final SWTBotExt bot = new SWTBotExt();
+ private final String[] actionPath;
+
+ public Action(String... path) {
+ assert path.length > 0;
+ this.actionPath = path;
+ }
+
+ public abstract T run();
+
+ protected SWTBot performMenu() {
+ SWTBotMenu m = bot.menu(actionPath[0]);
+ for (int i = 1; i < actionPath.length; i++) {
+ m = m.menu(actionPath[i]);
+ }
+ m.click();
+ return new SWTBot();
+ }
+
+ public String[] getActionPath() {
+ return actionPath;
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/NewFileWizardAction.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/NewFileWizardAction.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/NewFileWizardAction.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.bot.test.uiutils.actions;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.Wizard;
+
+public class NewFileWizardAction extends Action<Wizard> {
+
+ public NewFileWizardAction() {
+ super(IDELabel.Menu.FILE, IDELabel.Menu.NEW, IDELabel.Menu.OTHER);
+ }
+
+ @Override
+ public Wizard run() {
+ SWTBot b = performMenu();
+ return new Wizard(b.activeShell().widget);
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/NewSampleWSWizardAction.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/NewSampleWSWizardAction.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/NewSampleWSWizardAction.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.bot.test.uiutils.actions;
+
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.SampleWSWizard;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.SampleWSWizard.Type;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.Wizard;
+
+public class NewSampleWSWizardAction extends NewFileWizardAction {
+
+ private final Type type;
+
+ public NewSampleWSWizardAction(Type type) {
+ super();
+ this.type = type;
+ }
+
+ @Override
+ public SampleWSWizard run() {
+ Wizard w = super.run();
+ w.selectTemplate("Web Services", type.getLabel());
+ w.next();
+ return new SampleWSWizard(type);
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/TreeItemAction.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/TreeItemAction.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/actions/TreeItemAction.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -0,0 +1,63 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.bot.test.uiutils.actions;
+
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+
+public class TreeItemAction extends Action<SWTBot> {
+
+ private final SWTBotTreeItem item;
+
+ public TreeItemAction(SWTBotTreeItem tree, String... actionPath) {
+ super(actionPath);
+ this.item = tree;
+ }
+
+ @Override
+ public SWTBot run() {
+ return performMenu();
+ }
+
+ @Override
+ protected SWTBot performMenu() {
+ assert item != null : "TreeItem cannot be null!";
+ Tree tree = UIThreadRunnable.syncExec(new Result<Tree>() {
+
+ public Tree run() {
+ return item.widget.getParent();
+ }
+
+ });
+ final SWTBotTree t = new SWTBotTree(tree);
+ final String[] actionPath = super.getActionPath();
+ ContextMenuHelper.prepareTreeItemForContextMenu(t, item);
+ UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
+
+ public SWTBotMenu run() {
+ SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
+ t, actionPath[0], false));
+ for (int i = 1; i < actionPath.length; i++) {
+ m = m.menu(actionPath[i]);
+ }
+ return m;
+ }
+ }).click();
+ return new SWTBot();
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.bot.test.uiutils.wizards;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+
+public class DynamicWebProjectWizard extends Wizard {
+
+ public DynamicWebProjectWizard() {
+ super(new SWTBot().activeShell().widget);
+ assert "New Dynamic Web Project".equals(getText());
+ }
+
+ public DynamicWebProjectWizard setProjectName(String name) {
+ setText("Project name:", name);
+ return this;
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/SampleWSWizard.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/SampleWSWizard.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/SampleWSWizard.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.bot.test.uiutils.wizards;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+import org.osgi.framework.Bundle;
+
+public class SampleWSWizard extends Wizard {
+
+ private static final Bundle WSUI_BUNDLE =
Platform.getBundle("org.jboss.tools.ws.ui");
+
+ public enum Type {
+ SOAP, REST;
+
+ public String getLabel() {
+ switch (this) {
+ case SOAP:
+ return getStringFromBundle("%JBOSSWS_GENERATEACTION_LABEL");
+ case REST:
+ return getStringFromBundle("%restful.wizard.name");
+ default:
+ throw new IllegalArgumentException("Unknown type: " + this);
+ }
+ }
+ }
+
+ private Type type;
+
+ public SampleWSWizard(Type type) throws WidgetNotFoundException {
+ super(new SWTBotExt().activeShell().widget);
+ this.type = type;
+ }
+
+ public SampleWSWizard setProjectName(String name) {
+ SWTBotCombo c =
bot().comboBoxInGroup(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Project_Group);
+ c.setSelection(name);
+ return this;
+ }
+
+ public SampleWSWizard setServiceName(String name) {
+ setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_ServiceName_Label,
name);
+ return this;
+ }
+
+ public SampleWSWizard setPackageName(String name) {
+ setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_Package_Label,
name);
+ return this;
+ }
+
+ public SampleWSWizard setClassName(String name) {
+ setText(JBossWSUIMessages.JBossWS_GenerateWizard_GenerateWizardPage_ClassName_Label,
name);
+ return this;
+ }
+
+ public SampleWSWizard setApplicationClassName(String name) {
+ assert type == Type.REST;
+ setText(JBossWSUIMessages.JBossRSGenerateWizardPage_Label_Application_Class_Name,
name);
+ return this;
+ }
+
+ private static String getStringFromBundle(String key) {
+ return Platform.getResourceString(WSUI_BUNDLE, key);
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/Wizard.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/Wizard.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/Wizard.java 2010-11-04
13:19:02 UTC (rev 26249)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.ws.ui.bot.test.uiutils.wizards;
+
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+
+public class Wizard extends SWTBotShell {
+
+ public Wizard(Shell shell) {
+ super(shell);
+ assert getText().contains("New ");
+ }
+
+ public Wizard selectTemplate(String... item) {
+ assert item.length > 0;
+ SWTBotTree tree = bot().tree();
+ SWTBotTreeItem ti = null;
+ for (int i = 0; i < item.length - 1; i++) {
+ ti = ti != null ? ti.expandNode(item[i]).select() :
tree.expandNode(item[i]).select();
+ }
+ if (ti != null) {
+ ti.select(item[item.length - 1]);
+ } else {
+ tree.select(item[item.length - 1]);
+ }
+ return this;
+ }
+
+ public Wizard back() {
+ clickButton("< Back");
+ return this;
+ }
+
+ public Wizard next() {
+ clickButton("Next >");
+ return this;
+ }
+
+ public void cancel() {
+ clickButton("Cancel");
+ }
+
+ public void finish() {
+ clickButton("Finish");
+ }
+
+ protected void clickButton(String text) {
+ bot().button(text).click();
+ bot().sleep(500);
+ }
+
+ protected void setText(String label, String text) {
+ SWTBotText t = bot().textWithLabel(label);
+ t.setFocus();
+ t.setText(text);
+ }
+}