Author: jlukas(a)redhat.com
Date: 2010-11-19 09:40:46 -0500 (Fri, 19 Nov 2010)
New Revision: 26768
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/SampleWSTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/WsTesterTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceWizard.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/WSClient.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/BottomUpWSTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/TopDownWSTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/WSTestBase.java
Removed:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/BottomUpWebService.java
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
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/TopDownWebService.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/TwoBUWSInOneProject.java
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/WsTesterTest.java
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/resources/jbossws/ClassA.java.ws
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/ClassB.wsdl
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/Wizard.java
Log:
improving tests reliability and speed (work in progress)
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-19 14:32:37
UTC (rev 26767)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF 2010-11-19 14:40:46
UTC (rev 26768)
@@ -20,9 +20,18 @@
org.jboss.tools.ws.ui;bundle-version="1.1.0",
org.eclipse.core.resources,
org.jboss.tools.tests,
- org.eclipse.wst.common.project.facet.core
+ org.eclipse.wst.common.project.facet.core,
+ org.hamcrest;bundle-version="1.1.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Eclipse-RegisterBuddy: org.apache.log4j
Bundle-ClassPath: .
-Export-Package: org.jboss.tools.ws.ui.bot.test
+Export-Package: org.jboss.tools.ws.ui.bot.test;
+ uses:="org.eclipse.ui.plugin,
+ org.eclipse.swtbot.eclipse.finder,
+ javax.xml.namespace,
+ junit.framework,
+ org.eclipse.core.resources,
+ org.jboss.tools.ui.bot.ext,
+ org.osgi.framework,
+ org.jboss.tools.ws.ui.bot.test.uiutils.wizards"
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/ClassA.java.ws
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/ClassA.java.ws 2010-11-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/ClassA.java.ws 2010-11-19
14:40:46 UTC (rev 26768)
@@ -1,14 +1,14 @@
-package jbossws;
+package {0};
import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService()
-public class ClassA {
+public class {1} '{'
@WebMethod()
- public int method() {
- System.out.println("JbossWS Service : method() was called");
- return 1234567890;
- }
-}
+ public String method() '{'
+ System.out.println({1}.class.getName() + " Service: method() was
called");
+ return "{0}.{1}";
+ '}'
+'}'
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/ClassB.wsdl
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/ClassB.wsdl 2010-11-19
14:32:37 UTC (rev 26767)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/resources/jbossws/ClassB.wsdl 2010-11-19
14:40:46 UTC (rev 26768)
@@ -1,45 +1,45 @@
-<definitions name='ClassBService' targetNamespace='http://jbossws/'
xmlns='http://schemas.xmlsoap.org/wsdl/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://jbossws/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+<definitions name="{1}Service" targetNamespace="http://{0}/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://{0}/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
- <xs:schema targetNamespace='http://jbossws/' version='1.0'
xmlns:tns='http://jbossws/'
xmlns:xs='http://www.w3.org/2001/XMLSchema'>
- <xs:element name='method' type='tns:method'/>
- <xs:element name='methodResponse' type='tns:methodResponse'/>
- <xs:complexType name='method'>
+ <xs:schema targetNamespace="http://{0}/" version="1.0"
xmlns:tns="http://{0}/"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="method" type="tns:method"/>
+ <xs:element name="methodResponse"
type="tns:methodResponse"/>
+ <xs:complexType name="method">
<xs:sequence/>
</xs:complexType>
- <xs:complexType name='methodResponse'>
+ <xs:complexType name="methodResponse">
<xs:sequence>
- <xs:element name='return' type='xs:int'/>
+ <xs:element name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</types>
- <message name='ClassB_methodResponse'>
- <part element='tns:methodResponse'
name='methodResponse'></part>
+ <message name="{1}_methodResponse">
+ <part element="tns:methodResponse"
name="methodResponse"></part>
</message>
- <message name='ClassB_method'>
- <part element='tns:method' name='method'></part>
+ <message name="{1}_method">
+ <part element="tns:method" name="method"></part>
</message>
- <portType name='ClassB'>
- <operation name='method' parameterOrder='method'>
- <input message='tns:ClassB_method'></input>
- <output message='tns:ClassB_methodResponse'></output>
+ <portType name="{1}">
+ <operation name="method" parameterOrder="method">
+ <input message="tns:{1}_method"></input>
+ <output message="tns:{1}_methodResponse"></output>
</operation>
</portType>
- <binding name='ClassBBinding' type='tns:ClassB'>
- <soap:binding style='document'
transport='http://schemas.xmlsoap.org/soap/http'/>
- <operation name='method'>
- <soap:operation soapAction=''/>
+ <binding name="{1}Binding" type="tns:{1}">
+ <soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="method">
+ <soap:operation soapAction=""/>
<input>
- <soap:body use='literal'/>
+ <soap:body use="literal"/>
</input>
<output>
- <soap:body use='literal'/>
+ <soap:body use="literal"/>
</output>
</operation>
</binding>
- <service name='ClassBService'>
- <port binding='tns:ClassBBinding' name='ClassBPort'>
- <soap:address location='http://localhost:8080/JbossWS/ClassB'/>
+ <service name="{1}Service">
+ <port binding="tns:{1}Binding" name="{1}Port">
+ <soap:address location="http://localhost:8080/JbossWS/{1}"/>
</port>
</service>
</definitions>
\ No newline at end of file
Deleted:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/BottomUpWebService.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/BottomUpWebService.java 2010-11-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/BottomUpWebService.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -1,73 +0,0 @@
-package org.jboss.tools.ws.ui.bot.test;
-
-import org.jboss.tools.ui.bot.ext.config.Annotations.*;
-import org.junit.Test;
-
-
-@SWTBotTestRequires(server=@Server(),perspective="Java EE")
-public class BottomUpWebService extends JbossWSTest {
-
- @Test
- public void bottomUpJbossWS1() {
- int testlevel=4;
- for (int j=0;j<testlevel;j++) {
- bottomUpJbossWebService(0, j);
- }
- }
-
- @Test
- public void bottomUpJbossWS2() {
- int testlevel=4;
- for (int j=0;j<testlevel;j++) {
- bottomUpJbossWebService(1, j);
- }
- }
-
- @Test
- public void bottomUpJbossWS3() {
- int testlevel=4;
- for (int j=0;j<testlevel;j++) {
- bottomUpJbossWebService(2, j);
- }
- }
-
- @Test
- public void bottomUpJbossWS4() {
- int testlevel=4;
- for (int j=0;j<testlevel;j++) {
- bottomUpJbossWebService(3, j);
- }
- }
-
- protected void bottomUpJbossWebService(int serverType, int clientType) {
- log.info(" * Running test ServiceType:
'"+wizardConfigTexts.get(serverType)+"', ClientType:
'"+wizardConfigTexts.get(clientType)+"'");
- createEARProject(EAR_PROJECT_NAME);
- createProject(BOTTOMUP_WS_PROJ_NAME);
- bottomUpService(BOTTOMUP_WS_PROJ_NAME, CLASS_A,serverType);
- assertServiceDeployed(BOTTOMUP_WS_WSDL_URL);
- // generate client stubs
- createClient(BOTTOMUP_WS_CLIENT_PROJ_NAME, BOTTOMUP_WS_CLIENT_SERVLET_NAME,
BOTTOMUP_WS_WSDL_URL, clientType);
- servers.removeAllProjectsFromServer(configuredState.getServer().name);
- if (serverType >= SERVICE_SCALE_ASSEMBLE) {
- // service was not assembled into EAR
- projectExplorer.runOnServer(BOTTOMUP_WS_PROJ_NAME);
- } else {
- projectExplorer.runOnServer(EAR_PROJECT_NAME);
- }
- if (clientType >= CLIENT_SCALE_ASSEMBLE) {
- // client was not assembled into EAR
- projectExplorer.runOnServer(BOTTOMUP_WS_CLIENT_PROJ_NAME);
-
- } else {
- projectExplorer.runOnServer(EAR_PROJECT_NAME);
- }
- // but we need to run any of wars on server (to get browser)
- projectExplorer.runOnServer(BOTTOMUP_WS_PROJ_NAME);
- assertServiceResponseToClient(BOTTOMUP_WS_CLIENT_SERVLET_URL,
- "1234567890");
- servers.removeAllProjectsFromServer(configuredState.getServer().name);
- assertServiceNotDeployed(BOTTOMUP_WS_WSDL_URL);
- servers.removeAllProjectsFromServer();
- projectExplorer.deleteAllProjects();
- }
-}
Deleted:
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-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JbossWSTest.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * 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.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.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
-import org.jboss.tools.ui.bot.ext.SWTTestExt;
-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.WebServicesWebService;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWebServiceClient;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServlet;
-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;
-
-(a)RunWith(SWTBotJunit4ClassRunner.class)
-public class JbossWSTest extends SWTTestExt {
-
- public static final String EAR_PROJECT_NAME="EAR";
- public static final String PKG_NAME="jbossws";
-
- public static final String CLASS_A="ClassA";
- public static final String CLASS_B="ClassB";
- public static final String CLASS_C="ClassC";
- public static final String BOTTOMUP_WS_PROJ_NAME="BottomUpJbossWS";
- public static final String
BOTTOMUP_WS_WSDL_URL="http://localhost:8080/"+BOTTOMUP_WS_PROJ_NAME+"/"+CLASS_A+"?wsdl";
- public static final String BOTTOMUP_WS_CLIENT_PROJ_NAME =
"BottomUpJbossWSClient";
- public static final String BOTTOMUP_WS_CLIENT_SERVLET_NAME =
"BottomUpJbossWStest";
- public static final String BOTTOMUP_WS_CLIENT_SERVLET_URL =
"http://localhost:8080/"+BOTTOMUP_WS_CLIENT_PROJ_NAME+"/"+BOTTOMUP_WS_CLIENT_SERVLET_NAME;
- public static final String
TWO_SERVICES_CLIENT_SERVLET_NAME="TwoServicesJbossWStest";
- public static final String TWO_SERVICES_CLIENT_SERVLET_URL =
"http://localhost:8080/"+BOTTOMUP_WS_CLIENT_PROJ_NAME+"/"+TWO_SERVICES_CLIENT_SERVLET_NAME;
- public static final String TOPDOWN_WS_PROJ_NAME="TopDownJbossWS";
- public static final String
TOPDOWN_WS_WSDL_URL="http://localhost:8080/"+TOPDOWN_WS_PROJ_NAME+"/"+CLASS_B+"?wsdl";
- public static final String TOPDOWN_WS_CLIENT_PROJ_NAME =
"TopDownJbossWSClient";
- public static final String TOPDOWN_WS_CLIENT_SERVLET_NAME =
"TopDownJbossWStest";
- public static final String TOPDOWN_WS_CLIENT_SERVLET_URL =
"http://localhost:8080/"+TOPDOWN_WS_CLIENT_PROJ_NAME+"/"+TOPDOWN_WS_CLIENT_SERVLET_NAME;
- public static final String JBOSSWS_CRED_LOGIN="admin";
- public static final String JBOSSWS_CRED_PASS="admin";
- public static final int CLIENT_SCALE_DEVELOP=5;
- public static final int CLIENT_SCALE_ASSEMBLE=4;
- public static final int CLIENT_SCALE_DEPLOY=3;
- public static final int CLIENT_SCALE_INSTALL=2;
- public static final int CLIENT_SCALE_START=1;
- public static final int CLIENT_SCALE_TEST=0;
- public static final int SERVICE_SCALE_DEVELOP=5;
- public static final int SERVICE_SCALE_ASSEMBLE=4;
- public static final int SERVICE_SCALE_DEPLOY=3;
- public static final int SERVICE_SCALE_INSTALL=2;
- public static final int SERVICE_SCALE_START=1;
- 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>";;
-
- private static final Logger L = Logger.getLogger(JbossWSTest.class.getName());
- public JbossWSTest() {
-
- }
-
- static {
- wizardConfigTexts.put(0, "Test");
- wizardConfigTexts.put(1, "Start");
- wizardConfigTexts.put(2, "Install");
- wizardConfigTexts.put(3, "Deploy");
- wizardConfigTexts.put(4, "Assemble");
- wizardConfigTexts.put(5, "Develop");
- }
-
- protected void createClient(String projectName, String servletName,String wsdlDef, int
type) {
- createProject(projectName);
- SWTBot wiz = open.newObject(WebServicesWebServiceClient.LABEL);
- wiz.comboBoxWithLabel(
- WebServicesWebServiceClient.TEXT_SERVICE_DEFINITION).setText(
- wsdlDef);
- SWTBotScaleExt slider = bot.scale();
- slider.setSelection(type);
- selectJbossWSRuntime();
- bot.sleep(TIME_1S); // wait for wizard to validate wsdl url and
- // enable Finish button
- open.finish(wiz);
- projectExplorer.selectProject(projectName);
- // create servlet which will invoke service
- createInvokingServlet(servletName);
- }
-
- /**
- * checks if 'Web Service Runtime' is set to 'JbossWS' and possibly sets
it correctly
- * @param wiz wizard page of new Web Service
- */
- protected void selectJbossWSRuntime() {
- SWTBotHyperlinkExt link = bot.hyperlink(1);
- String linkText = link.getText();
- if (!linkText.contains("JBossWS")) {
- link.click();
- SWTBot dBot = bot.activeShell().bot();
- dBot.tree().select("JBossWS");
- open.finish(dBot,IDELabel.Button.OK);
- }
- }
-
- protected void bottomUpService(String projName, String serviceClass, int serverType)
{
- SWTBot wiz = open.newObject(Class.LABEL);
- wiz.textWithLabel(Class.TEXT_PACKAGE).setText(PKG_NAME);
- wiz.textWithLabel(Class.TEXT_NAME).setText(serviceClass);
- open.finish(wiz);
- eclipse.setClassContentFromResource(bot.editorByTitle(serviceClass
- + ".java"), true,
- org.jboss.tools.ws.ui.bot.test.Activator.PLUGIN_ID,
- PKG_NAME, serviceClass + ".java.ws");
- wiz = open.newObject(ActionItem.NewObject.WebServicesWebService.LABEL);
- wiz.textWithLabel(WebServicesWebService.TEXT_SERVICE_IMPLEMENTATION)
- .setText(PKG_NAME + "." + serviceClass);
- SWTBotScaleExt slider = bot.scale();
- slider.setSelection(serverType);
- selectJbossWSRuntime();
- open.finish(wiz);
- projectExplorer.runOnServer(projName);
- }
-
- protected void createInvokingServlet(String servletName) {
- SWTBot wiz = open.newObject(WebServlet.LABEL);
- wiz.textWithLabel(WebServlet.TEXT_JAVA_PACKAGE).setText(
- PKG_NAME);
- wiz.textWithLabel(WebServlet.TEXT_CLASS_NAME).setText(
- servletName);
- open.finish(wiz);
- eclipse.setClassContentFromResource(bot
- .editorByTitle(servletName
- + ".java"), true,
- org.jboss.tools.ws.ui.bot.test.Activator.PLUGIN_ID,
- PKG_NAME, servletName
- + ".java.servlet");
- }
-
- protected void createProject(String name) {
- new NewFileWizardAction().run().selectTemplate("Web", "Dynamic Web
Project").next();
- new DynamicWebProjectWizard().setProjectName(name).finish();
- util.waitForNonIgnoredJobs();
- assertTrue(projectExplorer.existsResource(name));
- projectExplorer.selectProject(name);
- }
-
- protected void createEARProject(String name) {
- SWTBot wiz = open.newObject(JavaEEEnterpriseApplicationProject.LABEL);
- wiz.textWithLabel(JavaEEEnterpriseApplicationProject.TEXT_PROJECT_NAME).setText(name);
- // set EAR version
- SWTBotCombo combo = wiz.comboBox(1);
- combo.setSelection(combo.itemCount()-1);
- wiz.button(IDELabel.Button.NEXT).click();
- wiz.checkBox("Generate application.xml deployment descriptor").click();
- open.finish(wiz);
- assertTrue(projectExplorer.existsResource(name));
- projectExplorer.selectProject(name);
- }
-
- protected void assertServiceDeployed(String wsdlURL) {
- HttpURLConnection connection = null;
- try {
- URL u = new URL(wsdlURL);
- connection = (HttpURLConnection) u.openConnection();
- assertEquals("Service was not sucessfully deployed, WSDL '" + wsdlURL +
"' was not found",
- HttpURLConnection.HTTP_OK, connection.getResponseCode());
- } catch (MalformedURLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
- protected void assertServiceNotDeployed(String wsdlURL) {
- HttpURLConnection connection = null;
- try {
- URL u = new URL(wsdlURL);
- connection = (HttpURLConnection) u.openConnection();
- assertEquals("Project was not sucessfully undeployed, WSDL '" + wsdlURL
+ "' is still available",
- HttpURLConnection.HTTP_NOT_FOUND, connection.getResponseCode());
- } catch (MalformedURLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- if (connection != null) {
- connection.disconnect();
- }
- }
- }
-
- protected void assertServiceResponseToClient(String startServlet, String response) {
- InputStream is = null;
- try {
- URL u = new URL(startServlet);
- is = u.openStream();
- String rsp = readStream(is);
- assertContains(response, rsp);
- } catch (MalformedURLException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- //ignore
- e.printStackTrace();
- }
- }
- }
- }
-
- public static String getSoapRequest(String body) {
- return MessageFormat.format(SOAP_REQUEST_TEMPLATE, body);
- }
-
- protected 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() : "";
- }
-}
Deleted:
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-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/SampleWebService.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * 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.IOException;
-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.gen.ActionItem;
-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 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", "Hello World!", "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 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(project);
- bot.sleep(5000);
- }
-
- private void checkService(Type type, String project, String svcName, String svcPkg,
String svcClass, String msgContent, String appCls) {
- 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;
- }
- runProject(project);
- switch (type) {
- case REST:
- try {
- URL u = new URL("http://" + SERVER_URL + "/" + project +
"/" + svcName);
- String s = readStream(u.openConnection().getInputStream());
- assertEquals(msgContent, 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 "";
- }
-
-}
Deleted:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/TopDownWebService.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/TopDownWebService.java 2010-11-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/TopDownWebService.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -1,81 +0,0 @@
-package org.jboss.tools.ws.ui.bot.test;
-
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.jboss.tools.ui.bot.ext.config.Annotations.*;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWSDL;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWebService;
-import org.jboss.tools.ui.bot.ext.parts.SWTBotScaleExt;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.junit.Test;
-
-@SWTBotTestRequires(server=@Server(),perspective="Java EE")
-public class TopDownWebService extends JbossWSTest {
-
- @Test
- public void topDownJbossWS1() {
- int testLevel = 3;
- for (int j=0;j<testLevel;j++) {
- topDownJbossWebService(0, j);
- }
- }
-
- @Test
- public void topDownJbossWS2() {
- int testLevel = 3;
- for (int j=0;j<testLevel;j++) {
- topDownJbossWebService(1, j);
- }
- }
-
- @Test
- public void topDownJbossWS3() {
- int testLevel = 3;
- for (int j=0;j<testLevel;j++) {
- topDownJbossWebService(2, j);
- }
- }
-
- private void topDownJbossWebService(int serverType, int clientType) {
- log.info(" * Running test ServiceType:
'"+wizardConfigTexts.get(serverType)+"', ClientType:
'"+wizardConfigTexts.get(clientType)+"'");
- createEARProject(EAR_PROJECT_NAME);
- createProject(TOPDOWN_WS_PROJ_NAME);
- SWTBot wiz = open.newObject(WebServicesWSDL.LABEL);
- wiz.textWithLabel(WebServicesWSDL.TEXT_FILE_NAME).setText(
- CLASS_B + ".wsdl");
- wiz.textWithLabel(
- WebServicesWSDL.TEXT_ENTER_OR_SELECT_THE_PARENT_FOLDER)
- .setText(TOPDOWN_WS_PROJ_NAME + "/src");
- wiz.button(IDELabel.Button.NEXT).click();
- open.finish(wiz);
- eclipse.setClassContentFromResource(bot.editorByTitle(CLASS_B
- + ".wsdl"), true,
- org.jboss.tools.ws.ui.bot.test.Activator.PLUGIN_ID,
- PKG_NAME, CLASS_B + ".wsdl");
- wiz = open.newObject(WebServicesWebService.LABEL);
- wiz.comboBoxWithLabel(WebServicesWebService.TEXT_WEB_SERVICE_TYPE)
- .setSelection(1);
- wiz.comboBoxWithLabel("Service definition:").setText(
- "/" + TOPDOWN_WS_PROJ_NAME + "/src/"
- + CLASS_B + ".wsdl");
- SWTBotScaleExt slider = bot.scale();
- slider.setSelection(serverType);
- selectJbossWSRuntime();
- open.finish(wiz);
- servers.removeProjectFromServers(EAR_PROJECT_NAME);
- projectExplorer.runOnServer(TOPDOWN_WS_PROJ_NAME);
- assertServiceDeployed(TOPDOWN_WS_WSDL_URL);
- // create and run client
-
- createClient(TOPDOWN_WS_CLIENT_PROJ_NAME, TOPDOWN_WS_CLIENT_SERVLET_NAME,
TOPDOWN_WS_WSDL_URL, clientType);
-
- servers.removeProjectFromServers(EAR_PROJECT_NAME);
- projectExplorer.runOnServer(TOPDOWN_WS_PROJ_NAME);
- projectExplorer.runOnServer(TOPDOWN_WS_CLIENT_PROJ_NAME);
-
- assertServiceResponseToClient(TOPDOWN_WS_CLIENT_SERVLET_URL, "0");
- servers.removeAllProjectsFromServer(configuredState.getServer().name);
- assertServiceNotDeployed(TOPDOWN_WS_WSDL_URL);
- servers.removeAllProjectsFromServer();
- projectExplorer.deleteAllProjects();
- }
-}
Deleted:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/TwoBUWSInOneProject.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/TwoBUWSInOneProject.java 2010-11-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/TwoBUWSInOneProject.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -1,53 +0,0 @@
-package org.jboss.tools.ws.ui.bot.test;
-
-import org.eclipse.swtbot.swt.finder.SWTBot;
-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.gen.ActionItem.NewObject.WebServicesWebServiceClient;
-import org.junit.AfterClass;
-import org.junit.Test;
-
-@SWTBotTestRequires(server=@Server(),perspective="Java EE")
-public class TwoBUWSInOneProject extends JbossWSTest {
-
- @Test
- public void twoServices() {
- createEARProject(EAR_PROJECT_NAME);
- createProject(BOTTOMUP_WS_PROJ_NAME);
- // service A
- bottomUpService(BOTTOMUP_WS_PROJ_NAME, CLASS_A,SERVICE_SCALE_START);
- // service B
- bottomUpService(BOTTOMUP_WS_PROJ_NAME, CLASS_B,SERVICE_SCALE_START);
-
- assertServiceDeployed(BOTTOMUP_WS_WSDL_URL);
- assertServiceDeployed(BOTTOMUP_WS_WSDL_URL.replace(CLASS_A, CLASS_B));
-
- // generate client stubs
- createClient(BOTTOMUP_WS_CLIENT_PROJ_NAME, TWO_SERVICES_CLIENT_SERVLET_NAME,
BOTTOMUP_WS_WSDL_URL, CLIENT_SCALE_START);
- util.waitForAll(TIME_5S);
- // service B client
- SWTBot wiz = open.newObject(WebServicesWebServiceClient.LABEL);
- wiz.comboBoxWithLabel(
- WebServicesWebServiceClient.TEXT_SERVICE_DEFINITION).setText(
- BOTTOMUP_WS_WSDL_URL.replace(CLASS_A, CLASS_B));
- bot.sleep(TIME_1S);// wait for wizard to validate wsdl url and enable 'Finish'
button
- selectJbossWSRuntime();
- open.finish(wiz);
- util.waitForAll(TIME_5S);
- // create servlet which will inovke service
- createInvokingServlet(TWO_SERVICES_CLIENT_SERVLET_NAME);
-
- // we need to undeploy auto-created EAR and deploy service and client
- // wars again
- servers.removeAllProjectsFromServer(configuredState.getServer().name);
- projectExplorer.runOnServer(BOTTOMUP_WS_PROJ_NAME);
- projectExplorer.runOnServer(BOTTOMUP_WS_CLIENT_PROJ_NAME);
- assertServiceResponseToClient(TWO_SERVICES_CLIENT_SERVLET_URL,
- "1234567890");
- assertServiceResponseToClient(TWO_SERVICES_CLIENT_SERVLET_URL,
- "11111");
- servers.removeAllProjectsFromServer(configuredState.getServer().name);
- assertServiceNotDeployed(BOTTOMUP_WS_WSDL_URL);
-
- }
-}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2010-11-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -11,14 +11,16 @@
package org.jboss.tools.ws.ui.bot.test;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ws.ui.bot.test.jbt.SampleWSTest;
+import org.jboss.tools.ws.ui.bot.test.wtp.BottomUpWSTest;
+import org.jboss.tools.ws.ui.bot.test.wtp.TopDownWSTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@SuiteClasses({
- //SampleWebService.class,
- TwoBUWSInOneProject.class,
- //BottomUpWebService.class,
- //TopDownWebService.class
+ SampleWSTest.class,
+ BottomUpWSTest.class,
+ TopDownWSTest.class
})
@RunWith(RequirementAwareSuite.class)
public class WSAllBotTests {
Deleted:
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 2010-11-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSClient.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * 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.net.URL;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.namespace.QName;
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPException;
-import javax.xml.soap.SOAPMessage;
-import javax.xml.ws.Dispatch;
-import javax.xml.ws.Service;
-import javax.xml.ws.Service.Mode;
-
-public class WSClient {
-
- private static final Logger L = Logger.getLogger(WSClient.class.getName());
- 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;
- try {
- SOAPMessage msg = MessageFactory.newInstance().createMessage( null, new
ByteArrayInputStream(message.getBytes()));
- msg.saveChanges();
- result = d.invoke(msg);
- } catch (SOAPException e) {
- L.log(Level.WARNING, e.getMessage(), e);
- } catch (IOException e) {
- L.log(Level.WARNING, e.getMessage(), e);
- }
- String s = msgToString(result);
- L.fine("SOAP Request :\n" + message);
- L.fine("SOAP Response:\n" + s);
- return s;
- }
-
- private String msgToString(SOAPMessage msg) {
- if (msg == null) {
- return "";
- }
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- try {
- msg.writeTo(out);
- } catch (SOAPException e) {
- L.log(Level.WARNING, e.getMessage(), e);
- } catch (IOException e) {
- L.log(Level.WARNING, e.getMessage(), e);
- } finally {
- try {
- out.close();
- } catch (IOException e) {
- //ignore
- L.log(Level.WARNING, e.getMessage(), e);
- }
- }
- return out.toString();
- }
-}
Deleted:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WsTesterTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WsTesterTest.java 2010-11-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WsTesterTest.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -1,381 +0,0 @@
-/*******************************************************************************
- * 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.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.util.Arrays;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.jboss.tools.ui.bot.ext.SWTTestExt;
-import org.jboss.tools.ws.ui.bot.test.widgets.SelectWSDLDialog;
-import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView;
-import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView.Request_Arg_Type;
-import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView.Request_Type;
-import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Tests for Web Service Tester
- *
- * @author jlukas
- */
-public class WsTesterTest extends SWTTestExt {
-
- private static final Logger L = Logger.getLogger(WsTesterTest.class.getName());
- private static final String SERVICE_URL =
"http://www.webservicex.net/BibleWebservice.asmx";
-
- /**
- * Test behavior of UI
- */
- @Test
- public void testUI() {
- WsTesterView wstv = new WsTesterView();
- SWTBotView viewBot = wstv.show();
- Assert.assertTrue("Tester View is not active", viewBot.isActive());
- wstv.setRequestType(Request_Type.PUT);
- Assert.assertEquals(Request_Type.PUT, wstv.getRequestType());
- wstv.setRequestType(Request_Type.JAX_WS);
- Assert.assertEquals(Request_Type.JAX_WS, wstv.getRequestType());
-
- wstv.setRequestType(Request_Type.DELETE);
- Assert.assertEquals(Request_Type.DELETE, wstv.getRequestType());
- wstv.expandSection(Request_Arg_Type.HEADER.toString());
- wstv.addRequestArg(Request_Arg_Type.HEADER, "a", "1");
- wstv.addRequestArg(Request_Arg_Type.HEADER, "b", "2");
- wstv.addRequestArg(Request_Arg_Type.HEADER, "c", "3");
- Assert.assertEquals(3, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
- Assert.assertTrue(wstv.getRequestArgs(Request_Arg_Type.HEADER).containsKey("b"));
- wstv.addRequestArg(Request_Arg_Type.HEADER, "d", "4");
- Assert.assertEquals(4, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
- Assert.assertTrue(wstv.getRequestArgs(Request_Arg_Type.HEADER).containsKey("d"));
- Assert.assertEquals(4, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
- wstv.removeRequestArg(Request_Arg_Type.HEADER, "a", "1");
- wstv.removeRequestArg(Request_Arg_Type.HEADER, "c", "3");
- Assert.assertEquals(2, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
- wstv.clearRequestArgs(Request_Arg_Type.HEADER);
- Assert.assertEquals(0, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
-
- wstv.setRequestType(Request_Type.JAX_WS);
- selectPort(wstv, "BibleWebserviceSoap");
-
Assert.assertTrue(wstv.getRequestBody().contains("http://schemas.xml...;
- selectPort(wstv, "BibleWebserviceSoap12");
- Assert.assertTrue("Got: " + wstv.getRequestBody(),
wstv.getRequestBody().contains("http://www.w3.org/2003/05/soap-envel...);
- viewBot.close();
- }
-
- /**
- * Test refreshing body requests in the UI
- */
- @Test
- public void testNamespaces() {
- String uri = new File(prepareWsdl(), "original.wsdl").toURI().toString();
- WsTesterView wstv = new WsTesterView();
- SWTBotView viewBot = wstv.show();
- Assert.assertTrue("Tester View is not active", viewBot.isActive());
- SelectWSDLDialog dlg = wstv.getFromWSDL();
- dlg.setURI(uri);
- bot.sleep(1000);
- List<String> items = dlg.getServices();
- L.log(Level.FINE, "Services: {0}", items);
- Assert.assertEquals(2, items.size());
- Assert.assertTrue(items.contains("EchoService"));
- items = dlg.getPorts();
- L.log(Level.FINE, "Ports: {0}", items);
- Assert.assertEquals(1, items.size());
- Assert.assertTrue(items.contains("EchoPort"));
- items = dlg.getOperations();
- L.log(Level.FINE, "Operations: {0}", items);
- Assert.assertEquals(1, items.size());
- Assert.assertTrue(items.contains("echo"));
- dlg.ok();
- L.log(Level.INFO, "Request: {0}", wstv.getRequestBody());
- Assert.assertTrue(wstv.getRequestBody().contains(
- "<echo xmlns = \"http://test.jboss.org/ns\">"));
-
- dlg = wstv.getFromWSDL();
- dlg.setURI(uri);
- bot.sleep(1000);
- items = dlg.getServices();
- L.log(Level.FINE, "Services: {0}", items);
- Assert.assertEquals(2, items.size());
- Assert.assertTrue(items.contains("gsearch_rss"));
- dlg.selectService("gsearch_rss");
- items = dlg.getPorts();
- L.log(Level.FINE, "Ports: {0}", items);
- Assert.assertEquals(1, items.size());
- Assert.assertTrue(items.contains("gsearch_rssSoap"));
- items = dlg.getOperations();
- L.log(Level.FINE, "Operations: {0}", items);
- Assert.assertEquals(1, items.size());
- Assert.assertTrue(items.contains("GetSearchResults"));
- dlg.ok();
- L.log(Level.INFO, "Request: {0}", wstv.getRequestBody());
- Assert.assertTrue(wstv.getRequestBody().contains(
- "<GetSearchResults xmlns =
\"http://www.ecubicle.net/webservices\">"));
- }
-
- /**
- * Test SOAP service invocation
- */
- @Test
- public void testSOAPService() {
- WsTesterView wstv = new WsTesterView();
- wstv.show();
- wstv.setRequestType(Request_Type.JAX_WS);
- Assert.assertEquals(Request_Type.JAX_WS, wstv.getRequestType());
- wstv.setServiceURL(SERVICE_URL + "?WSDL");
- InputStream is =
WsTesterTest.class.getResourceAsStream("/resources/jbossws/message_soap_out.xml");
- wstv.setRequestBody(readResource(is));
- wstv.invoke();
- String rsp = wstv.getResponseBody();
- L.log(Level.FINE, "SOAP response: {0}", rsp);
- Assert.assertTrue(rsp.trim().length() > 0);
- checkResponse(rsp,
"<BookTitle>Mark</BookTitle>");
- }
-
- /**
- * Test SOAP 1.2 service invocation
- */
- @Test
- public void testSOAP12Service() {
- WsTesterView wstv = new WsTesterView();
- wstv.show();
- wstv.setRequestType(Request_Type.JAX_WS);
- Assert.assertEquals(Request_Type.JAX_WS, wstv.getRequestType());
- SelectWSDLDialog dlg = wstv.getFromWSDL();
- try {
- dlg.openURL();
- SWTBotShell sh = bot.activeShell();
- sh.bot().text().typeText(SERVICE_URL + "?WSDL");
- sh.bot().button("OK").click();
- bot.sleep(1000);
- Assert.assertEquals(SERVICE_URL + "?WSDL", dlg.getURI());
- dlg.selectPort("BibleWebserviceSoap12");
- dlg.ok();
- } finally {
- if (dlg.isOpen()) {
- dlg.close();
- }
- }
- Assert.assertEquals(SERVICE_URL + "?WSDL", wstv.getServiceURL());
- InputStream is =
WsTesterTest.class.getResourceAsStream("/resources/jbossws/message_soap12_out.xml");
- wstv.setRequestBody(readResource(is));
- wstv.invoke();
- String rsp = wstv.getResponseBody();
- L.log(Level.FINE, "SOAP response: {0}", rsp);
- Assert.assertTrue(rsp.trim().length() > 0);
- checkResponse(rsp,
"<BookTitle>Mark</BookTitle>");
- }
-
- /**
- * Test REST service invocation (GET request)
- */
- @Test
- public void testRESTGETService() {
- WsTesterView wstv = new WsTesterView();
- wstv.show();
- wstv.setRequestType(Request_Type.GET);
- wstv.setServiceURL(SERVICE_URL + "/GetBibleWordsByChapterAndVerse");
- wstv.expandSection(Request_Arg_Type.PARAMETER.toString());
- wstv.addRequestArg(Request_Arg_Type.PARAMETER, "BookTitle",
"Luke");
- wstv.addRequestArg(Request_Arg_Type.PARAMETER, "chapter", "2");
- wstv.addRequestArg(Request_Arg_Type.PARAMETER, "Verse", "2");
- wstv.editRequestArg(Request_Arg_Type.PARAMETER, "chapter", "2",
"chapter", "1");
- try {
- wstv.invoke();
- String rsp = wstv.getResponseBody();
- String[] rspHeaders = wstv.getResponseHeaders();
- L.log(Level.FINE, "REST response: {0}", rsp);
- L.log(Level.FINE, "Response headers: {0}", Arrays.asList(rspHeaders));
- Assert.assertTrue(rsp.trim().length() > 0);
- checkResponse(rsp, "<Chapter>1</Chapter>");
- checkResponse(rsp, "ministers of the word");
- } finally {
- wstv.clearRequestArgs(Request_Arg_Type.PARAMETER);
- }
- }
-
- /**
- * Test REST service invocation (POST request)
- */
- @Test
- public void testRESTPOSTService() {
- WsTesterView wstv = new WsTesterView();
- wstv.show();
- wstv.setRequestType(WsTesterView.Request_Type.POST);
- wstv.setServiceURL(SERVICE_URL + "/GetBibleWordsByChapterAndVerse");
- String requestBody = "BookTitle=John&chapter=3&Verse=1\r";
- wstv.setRequestBody(requestBody);
- wstv.expandSection(JBossWSUIMessages.JAXRSWSTestView2_ResponseHeaders_Section);
- wstv.addRequestArg(Request_Arg_Type.HEADER, "Content-Type",
"application/x-www-form-urlencoded");
- wstv.addRequestArg(Request_Arg_Type.HEADER, "Content-Length",
String.valueOf(requestBody.length()));
- try {
- wstv.invoke();
- String rsp = wstv.getResponseBody();
- String[] rspHeaders = wstv.getResponseHeaders();
- L.log(Level.FINE, "REST response: {0}", rsp);
- L.log(Level.FINE, "Response headers: {0}", Arrays.asList(rspHeaders));
- Assert.assertTrue(rsp.trim().length() > 0);
- checkResponse(rsp, "<Chapter>3</Chapter>");
- checkResponse(rsp, "There was a man of the Pharisees, named Nicodemus, a ruler of
the Jews");
- } finally {
- wstv.clearRequestArgs(Request_Arg_Type.HEADER);
- }
- }
-
- @Test
- public void testErrorResponse() {
- WsTesterView wstv = new WsTesterView();
- wstv.show();
- wstv.setRequestType(Request_Type.GET);
-
wstv.setServiceURL("http://www.zvents.com/rest/event_update");
- wstv.invoke();
- Assert.assertEquals(0, wstv.getRequestArgs(Request_Arg_Type.PARAMETER).size());
- String rsp = wstv.getResponseBody();
- String[] rspHeaders = wstv.getResponseHeaders();
- L.log(Level.FINE, "REST response: {0}", rsp);
- L.log(Level.FINE, "Response headers: {0}", Arrays.asList(rspHeaders));
- Assert.assertTrue(rsp.trim().length() > 0);
- checkResponse(rsp, "Invalid API Key.");
- }
-
- private String readResource(InputStream is) {
- StringBuilder sb = new StringBuilder();
- BufferedReader br = null;
- try {
- br = new BufferedReader(new InputStreamReader(is));
- String s;
- while ((s = br.readLine()) != null) {
- sb.append(s);
- sb.append('\n');
- }
- } catch (IOException e) {
- L.log(Level.WARNING, e.getMessage(), e);
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- L.log(Level.FINEST, e.getMessage(), e);
- }
- }
- }
- return sb.toString();
- }
-
- private void checkResponse(String rsp, String expContent) {
- try {
- Assert.assertTrue(rsp, rsp.contains(expContent));
- } catch (AssertionError t) {
- if (rsp.contains("503")) {
- L.log(Level.WARNING, "Service Unavailable: {0}", SERVICE_URL);
- } else {
- throw t;
- }
- }
- }
-
- private File prepareWsdl() {
- String[] files = { "imported.wsdl", "original.wsdl",
"schema.xsd" };
- File targetFolder = new File(System.getProperty("java.io.tmpdir"),
- "WsTesterTest");
- targetFolder.mkdirs();
- for (String file : files) {
- InputStream is = WsTesterTest.class.getResourceAsStream("/wsdl/"
- + file);
- File target = new File(targetFolder, file);
- if (target.exists()) {
- target.delete();
- }
- try {
- OutputStream os = new BufferedOutputStream(
- new FileOutputStream(target));
- copy(is, os);
- } catch (FileNotFoundException fnfe) {
- throw new RuntimeException(fnfe);
- }
- }
- return targetFolder;
- }
-
- private void copy(InputStream in, OutputStream out) {
- byte[] buf = new byte[1024];
- int len;
- try {
- while ((len = in.read(buf)) > 0) {
- out.write(buf, 0, len);
- }
- } catch (IOException ioe) {
- throw new RuntimeException(ioe);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException ioe2) {
- L.log(Level.WARNING, ioe2.getMessage(), ioe2);
- }
- }
- if (out != null) {
- try {
- out.close();
- } catch (IOException ioe2) {
- L.log(Level.WARNING, ioe2.getMessage(), ioe2);
- }
- }
- }
- }
-
- private void selectPort(WsTesterView wstv, String portName) {
- SelectWSDLDialog dlg = wstv.getFromWSDL();
- try {
- dlg.openURL();
- SWTBotShell sh = bot.activeShell();
- sh.bot().text().typeText(SERVICE_URL + "?WSDL");
- sh.bot().button("OK").click();
- bot.sleep(1000);
- Assert.assertEquals(SERVICE_URL + "?WSDL", dlg.getURI());
- List<String> items = dlg.getServices();
- L.log(Level.FINE, "Services: {0}", items);
- Assert.assertEquals(1, items.size());
- Assert.assertTrue(items.contains("BibleWebservice"));
- items = dlg.getPorts();
- L.log(Level.FINE, "Ports: {0}", items);
- Assert.assertEquals(2, items.size());
- Assert.assertTrue(items.contains("BibleWebserviceSoap"));
- Assert.assertTrue(items.contains("BibleWebserviceSoap12"));
- dlg.selectPort(portName);
- items = dlg.getOperations();
- L.log(Level.FINE, "Operations: {0}", items);
- Assert.assertEquals(4, items.size());
- Assert.assertTrue(items.contains("GetBookTitles"));
- Assert.assertTrue(items.contains("GetBibleWordsByChapterAndVerse"));
- dlg.selectOperation("GetBibleWordsbyKeyWord");
- dlg.ok();
-
Assert.assertEquals("http://www.webservicex.net/BibleWebservice.asmx...;,
wstv.getServiceURL());
- } finally {
- if (dlg.isOpen()) {
- dlg.close();
- }
- } }
-}
Copied:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/SampleWSTest.java
(from rev 26699,
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/jbt/SampleWSTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/SampleWSTest.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -0,0 +1,197 @@
+/*******************************************************************************
+ * 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.jbt;
+
+import java.io.IOException;
+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.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.jboss.tools.ws.ui.bot.test.utils.WSClient;
+import org.jboss.tools.ws.ui.bot.test.wtp.WSTestBase;
+import org.junit.AfterClass;
+import org.junit.Test;
+
+
+@SWTBotTestRequires(server=@Server(),perspective="Java EE")
+public class SampleWSTest extends WSTestBase {
+
+ 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(SampleWSTest.class.getName());
+
+ @AfterClass
+ public static void clean() {
+ servers.removeAllProjectsFromServer();
+ projectExplorer.deleteAllProjects();
+ }
+
+ @Override
+ protected String getWsProjectName() {
+ return "SampleSOAPWS";
+ }
+
+ @Test
+ public void testSampleSoapWS() {
+ IFile dd = getDD(getWsProjectName());
+ if (!dd.exists()) {
+ createDD(getWsProjectName());
+ }
+ assertTrue(dd.exists());
+ createSampleSOAPWS(getWsProjectName(), "HelloService", "sample",
"SampleService");
+ checkSOAPService(getWsProjectName(), "HelloService", "sample",
"SampleService", "You");
+
+ createSampleSOAPWS(getWsProjectName(), "GreetService", "greeter",
"Greeter");
+ checkSOAPService(getWsProjectName(), "GreetService", "greeter",
"Greeter", "Tester");
+ }
+
+ @Test
+ 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", "Hello World!", "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 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 checkService(Type type, String project, String svcName, String svcPkg,
String svcClass, String msgContent, String appCls) {
+ 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;
+ }
+ runProject(project);
+ switch (type) {
+ case REST:
+ try {
+ URL u = new URL("http://" + SERVER_URL + "/" + project +
"/" + svcName);
+ String s = readStream(u.openConnection().getInputStream());
+ assertEquals(msgContent, 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 "";
+ }
+
+ @Override
+ protected String getWsPackage() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected String getWsName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
Copied:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/WsTesterTest.java
(from rev 26699,
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WsTesterTest.java)
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/WsTesterTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/jbt/WsTesterTest.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -0,0 +1,381 @@
+/*******************************************************************************
+ * 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.jbt;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ws.ui.bot.test.widgets.SelectWSDLDialog;
+import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView;
+import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView.Request_Arg_Type;
+import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView.Request_Type;
+import org.jboss.tools.ws.ui.messages.JBossWSUIMessages;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests for Web Service Tester
+ *
+ * @author jlukas
+ */
+public class WsTesterTest extends SWTTestExt {
+
+ private static final Logger L = Logger.getLogger(WsTesterTest.class.getName());
+ private static final String SERVICE_URL =
"http://www.webservicex.net/BibleWebservice.asmx";
+
+ /**
+ * Test behavior of UI
+ */
+ @Test
+ public void testUI() {
+ WsTesterView wstv = new WsTesterView();
+ SWTBotView viewBot = wstv.show();
+ Assert.assertTrue("Tester View is not active", viewBot.isActive());
+ wstv.setRequestType(Request_Type.PUT);
+ Assert.assertEquals(Request_Type.PUT, wstv.getRequestType());
+ wstv.setRequestType(Request_Type.JAX_WS);
+ Assert.assertEquals(Request_Type.JAX_WS, wstv.getRequestType());
+
+ wstv.setRequestType(Request_Type.DELETE);
+ Assert.assertEquals(Request_Type.DELETE, wstv.getRequestType());
+ wstv.expandSection(Request_Arg_Type.HEADER.toString());
+ wstv.addRequestArg(Request_Arg_Type.HEADER, "a", "1");
+ wstv.addRequestArg(Request_Arg_Type.HEADER, "b", "2");
+ wstv.addRequestArg(Request_Arg_Type.HEADER, "c", "3");
+ Assert.assertEquals(3, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
+ Assert.assertTrue(wstv.getRequestArgs(Request_Arg_Type.HEADER).containsKey("b"));
+ wstv.addRequestArg(Request_Arg_Type.HEADER, "d", "4");
+ Assert.assertEquals(4, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
+ Assert.assertTrue(wstv.getRequestArgs(Request_Arg_Type.HEADER).containsKey("d"));
+ Assert.assertEquals(4, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
+ wstv.removeRequestArg(Request_Arg_Type.HEADER, "a", "1");
+ wstv.removeRequestArg(Request_Arg_Type.HEADER, "c", "3");
+ Assert.assertEquals(2, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
+ wstv.clearRequestArgs(Request_Arg_Type.HEADER);
+ Assert.assertEquals(0, wstv.getRequestArgs(Request_Arg_Type.HEADER).keySet().size());
+
+ wstv.setRequestType(Request_Type.JAX_WS);
+ selectPort(wstv, "BibleWebserviceSoap");
+
Assert.assertTrue(wstv.getRequestBody().contains("http://schemas.xml...;
+ selectPort(wstv, "BibleWebserviceSoap12");
+ Assert.assertTrue("Got: " + wstv.getRequestBody(),
wstv.getRequestBody().contains("http://www.w3.org/2003/05/soap-envel...);
+ viewBot.close();
+ }
+
+ /**
+ * Test refreshing body requests in the UI
+ */
+ @Test
+ public void testNamespaces() {
+ String uri = new File(prepareWsdl(), "original.wsdl").toURI().toString();
+ WsTesterView wstv = new WsTesterView();
+ SWTBotView viewBot = wstv.show();
+ Assert.assertTrue("Tester View is not active", viewBot.isActive());
+ SelectWSDLDialog dlg = wstv.getFromWSDL();
+ dlg.setURI(uri);
+ bot.sleep(1000);
+ List<String> items = dlg.getServices();
+ L.log(Level.FINE, "Services: {0}", items);
+ Assert.assertEquals(2, items.size());
+ Assert.assertTrue(items.contains("EchoService"));
+ items = dlg.getPorts();
+ L.log(Level.FINE, "Ports: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("EchoPort"));
+ items = dlg.getOperations();
+ L.log(Level.FINE, "Operations: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("echo"));
+ dlg.ok();
+ L.log(Level.INFO, "Request: {0}", wstv.getRequestBody());
+ Assert.assertTrue(wstv.getRequestBody().contains(
+ "<echo xmlns = \"http://test.jboss.org/ns\">"));
+
+ dlg = wstv.getFromWSDL();
+ dlg.setURI(uri);
+ bot.sleep(1000);
+ items = dlg.getServices();
+ L.log(Level.FINE, "Services: {0}", items);
+ Assert.assertEquals(2, items.size());
+ Assert.assertTrue(items.contains("gsearch_rss"));
+ dlg.selectService("gsearch_rss");
+ items = dlg.getPorts();
+ L.log(Level.FINE, "Ports: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("gsearch_rssSoap"));
+ items = dlg.getOperations();
+ L.log(Level.FINE, "Operations: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("GetSearchResults"));
+ dlg.ok();
+ L.log(Level.INFO, "Request: {0}", wstv.getRequestBody());
+ Assert.assertTrue(wstv.getRequestBody().contains(
+ "<GetSearchResults xmlns =
\"http://www.ecubicle.net/webservices\">"));
+ }
+
+ /**
+ * Test SOAP service invocation
+ */
+ @Test
+ public void testSOAPService() {
+ WsTesterView wstv = new WsTesterView();
+ wstv.show();
+ wstv.setRequestType(Request_Type.JAX_WS);
+ Assert.assertEquals(Request_Type.JAX_WS, wstv.getRequestType());
+ wstv.setServiceURL(SERVICE_URL + "?WSDL");
+ InputStream is =
WsTesterTest.class.getResourceAsStream("/resources/jbossws/message_soap_out.xml");
+ wstv.setRequestBody(readResource(is));
+ wstv.invoke();
+ String rsp = wstv.getResponseBody();
+ L.log(Level.FINE, "SOAP response: {0}", rsp);
+ Assert.assertTrue(rsp.trim().length() > 0);
+ checkResponse(rsp,
"<BookTitle>Mark</BookTitle>");
+ }
+
+ /**
+ * Test SOAP 1.2 service invocation
+ */
+ @Test
+ public void testSOAP12Service() {
+ WsTesterView wstv = new WsTesterView();
+ wstv.show();
+ wstv.setRequestType(Request_Type.JAX_WS);
+ Assert.assertEquals(Request_Type.JAX_WS, wstv.getRequestType());
+ SelectWSDLDialog dlg = wstv.getFromWSDL();
+ try {
+ dlg.openURL();
+ SWTBotShell sh = bot.activeShell();
+ sh.bot().text().typeText(SERVICE_URL + "?WSDL");
+ sh.bot().button("OK").click();
+ bot.sleep(1000);
+ Assert.assertEquals(SERVICE_URL + "?WSDL", dlg.getURI());
+ dlg.selectPort("BibleWebserviceSoap12");
+ dlg.ok();
+ } finally {
+ if (dlg.isOpen()) {
+ dlg.close();
+ }
+ }
+ Assert.assertEquals(SERVICE_URL + "?WSDL", wstv.getServiceURL());
+ InputStream is =
WsTesterTest.class.getResourceAsStream("/resources/jbossws/message_soap12_out.xml");
+ wstv.setRequestBody(readResource(is));
+ wstv.invoke();
+ String rsp = wstv.getResponseBody();
+ L.log(Level.FINE, "SOAP response: {0}", rsp);
+ Assert.assertTrue(rsp.trim().length() > 0);
+ checkResponse(rsp,
"<BookTitle>Mark</BookTitle>");
+ }
+
+ /**
+ * Test REST service invocation (GET request)
+ */
+ @Test
+ public void testRESTGETService() {
+ WsTesterView wstv = new WsTesterView();
+ wstv.show();
+ wstv.setRequestType(Request_Type.GET);
+ wstv.setServiceURL(SERVICE_URL + "/GetBibleWordsByChapterAndVerse");
+ wstv.expandSection(Request_Arg_Type.PARAMETER.toString());
+ wstv.addRequestArg(Request_Arg_Type.PARAMETER, "BookTitle",
"Luke");
+ wstv.addRequestArg(Request_Arg_Type.PARAMETER, "chapter", "2");
+ wstv.addRequestArg(Request_Arg_Type.PARAMETER, "Verse", "2");
+ wstv.editRequestArg(Request_Arg_Type.PARAMETER, "chapter", "2",
"chapter", "1");
+ try {
+ wstv.invoke();
+ String rsp = wstv.getResponseBody();
+ String[] rspHeaders = wstv.getResponseHeaders();
+ L.log(Level.FINE, "REST response: {0}", rsp);
+ L.log(Level.FINE, "Response headers: {0}", Arrays.asList(rspHeaders));
+ Assert.assertTrue(rsp.trim().length() > 0);
+ checkResponse(rsp, "<Chapter>1</Chapter>");
+ checkResponse(rsp, "ministers of the word");
+ } finally {
+ wstv.clearRequestArgs(Request_Arg_Type.PARAMETER);
+ }
+ }
+
+ /**
+ * Test REST service invocation (POST request)
+ */
+ @Test
+ public void testRESTPOSTService() {
+ WsTesterView wstv = new WsTesterView();
+ wstv.show();
+ wstv.setRequestType(WsTesterView.Request_Type.POST);
+ wstv.setServiceURL(SERVICE_URL + "/GetBibleWordsByChapterAndVerse");
+ String requestBody = "BookTitle=John&chapter=3&Verse=1\r";
+ wstv.setRequestBody(requestBody);
+ wstv.expandSection(JBossWSUIMessages.JAXRSWSTestView2_ResponseHeaders_Section);
+ wstv.addRequestArg(Request_Arg_Type.HEADER, "Content-Type",
"application/x-www-form-urlencoded");
+ wstv.addRequestArg(Request_Arg_Type.HEADER, "Content-Length",
String.valueOf(requestBody.length()));
+ try {
+ wstv.invoke();
+ String rsp = wstv.getResponseBody();
+ String[] rspHeaders = wstv.getResponseHeaders();
+ L.log(Level.FINE, "REST response: {0}", rsp);
+ L.log(Level.FINE, "Response headers: {0}", Arrays.asList(rspHeaders));
+ Assert.assertTrue(rsp.trim().length() > 0);
+ checkResponse(rsp, "<Chapter>3</Chapter>");
+ checkResponse(rsp, "There was a man of the Pharisees, named Nicodemus, a ruler of
the Jews");
+ } finally {
+ wstv.clearRequestArgs(Request_Arg_Type.HEADER);
+ }
+ }
+
+ @Test
+ public void testErrorResponse() {
+ WsTesterView wstv = new WsTesterView();
+ wstv.show();
+ wstv.setRequestType(Request_Type.GET);
+
wstv.setServiceURL("http://www.zvents.com/rest/event_update");
+ wstv.invoke();
+ Assert.assertEquals(0, wstv.getRequestArgs(Request_Arg_Type.PARAMETER).size());
+ String rsp = wstv.getResponseBody();
+ String[] rspHeaders = wstv.getResponseHeaders();
+ L.log(Level.FINE, "REST response: {0}", rsp);
+ L.log(Level.FINE, "Response headers: {0}", Arrays.asList(rspHeaders));
+ Assert.assertTrue(rsp.trim().length() > 0);
+ checkResponse(rsp, "Invalid API Key.");
+ }
+
+ private String readResource(InputStream is) {
+ StringBuilder sb = new StringBuilder();
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new InputStreamReader(is));
+ String s;
+ while ((s = br.readLine()) != null) {
+ sb.append(s);
+ sb.append('\n');
+ }
+ } catch (IOException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ L.log(Level.FINEST, e.getMessage(), e);
+ }
+ }
+ }
+ return sb.toString();
+ }
+
+ private void checkResponse(String rsp, String expContent) {
+ try {
+ Assert.assertTrue(rsp, rsp.contains(expContent));
+ } catch (AssertionError t) {
+ if (rsp.contains("503")) {
+ L.log(Level.WARNING, "Service Unavailable: {0}", SERVICE_URL);
+ } else {
+ throw t;
+ }
+ }
+ }
+
+ private File prepareWsdl() {
+ String[] files = { "imported.wsdl", "original.wsdl",
"schema.xsd" };
+ File targetFolder = new File(System.getProperty("java.io.tmpdir"),
+ "WsTesterTest");
+ targetFolder.mkdirs();
+ for (String file : files) {
+ InputStream is = WsTesterTest.class.getResourceAsStream("/wsdl/"
+ + file);
+ File target = new File(targetFolder, file);
+ if (target.exists()) {
+ target.delete();
+ }
+ try {
+ OutputStream os = new BufferedOutputStream(
+ new FileOutputStream(target));
+ copy(is, os);
+ } catch (FileNotFoundException fnfe) {
+ throw new RuntimeException(fnfe);
+ }
+ }
+ return targetFolder;
+ }
+
+ private void copy(InputStream in, OutputStream out) {
+ byte[] buf = new byte[1024];
+ int len;
+ try {
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ } catch (IOException ioe) {
+ throw new RuntimeException(ioe);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException ioe2) {
+ L.log(Level.WARNING, ioe2.getMessage(), ioe2);
+ }
+ }
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException ioe2) {
+ L.log(Level.WARNING, ioe2.getMessage(), ioe2);
+ }
+ }
+ }
+ }
+
+ private void selectPort(WsTesterView wstv, String portName) {
+ SelectWSDLDialog dlg = wstv.getFromWSDL();
+ try {
+ dlg.openURL();
+ SWTBotShell sh = bot.activeShell();
+ sh.bot().text().typeText(SERVICE_URL + "?WSDL");
+ sh.bot().button("OK").click();
+ bot.sleep(1000);
+ Assert.assertEquals(SERVICE_URL + "?WSDL", dlg.getURI());
+ List<String> items = dlg.getServices();
+ L.log(Level.FINE, "Services: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("BibleWebservice"));
+ items = dlg.getPorts();
+ L.log(Level.FINE, "Ports: {0}", items);
+ Assert.assertEquals(2, items.size());
+ Assert.assertTrue(items.contains("BibleWebserviceSoap"));
+ Assert.assertTrue(items.contains("BibleWebserviceSoap12"));
+ dlg.selectPort(portName);
+ items = dlg.getOperations();
+ L.log(Level.FINE, "Operations: {0}", items);
+ Assert.assertEquals(4, items.size());
+ Assert.assertTrue(items.contains("GetBookTitles"));
+ Assert.assertTrue(items.contains("GetBibleWordsByChapterAndVerse"));
+ dlg.selectOperation("GetBibleWordsbyKeyWord");
+ dlg.ok();
+
Assert.assertEquals("http://www.webservicex.net/BibleWebservice.asmx...;,
wstv.getServiceURL());
+ } finally {
+ if (dlg.isOpen()) {
+ dlg.close();
+ }
+ } }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceWizard.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceWizard.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/WebServiceWizard.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Scale;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotHyperlinkExt;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotScaleExt;
+
+public class WebServiceWizard extends Wizard {
+
+ public enum Service_Type {
+ BOTTOM_UP, TOP_DOWN;
+
+ String getDescription() {
+ String prefix = "";
+ switch (this) {
+ case BOTTOM_UP:
+ prefix += "Bottom up";
+ break;
+ case TOP_DOWN:
+ prefix += "Top down";
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown type: " + this);
+ }
+ return prefix + " Java bean Web Service";
+ }
+ }
+
+ public enum Slider_Level {
+ TEST, START, INSTALL, DEPLOY, ASSEMBLE, DEVELOP, NO_CLIENT;
+
+ @Override
+ public String toString() {
+ return name().charAt(0) + name().substring(1).toLowerCase();
+ }
+ }
+
+ public WebServiceWizard() {
+ super();
+ }
+
+ public WebServiceWizard(Shell shell) {
+ super(shell);
+ }
+
+ public WebServiceWizard setServiceType(Service_Type type) {
+ bot().comboBoxWithLabel("Web service
type:").setSelection(type.getDescription());
+ return this;
+ }
+
+ public Service_Type getServiceType() {
+ String s = bot().comboBoxWithLabel("Web service type:").getText();
+ return s.startsWith("Bottom up") ? Service_Type.BOTTOM_UP :
Service_Type.TOP_DOWN;
+ }
+
+ public WebServiceWizard setServiceSource(String s) {
+ SWTBotCombo c = null;
+ switch (getServiceType()) {
+ case BOTTOM_UP:
+ c = bot().comboBoxWithLabel("Service implementation:");
+ break;
+ case TOP_DOWN:
+ c = bot().comboBoxWithLabel("Service definition:");
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown type: " + this);
+ }
+ c.typeText(s);
+ return this;
+ }
+
+ public WebServiceWizard setServerRuntime(String name) {
+ findLink("Server runtime:").get(0).click();
+ SWTBotShell sh = bot().activeShell();
+ SWTBotTree tree = sh.bot().treeInGroup("Server runtime:");
+ tree.expandNode("Existing Servers", name).select();
+ sh.bot().button("OK").click();
+ sleep(50);
+ return this;
+ }
+
+ public WebServiceWizard setWebServiceRuntime(String name) {
+ findLink("Web service runtime:").get(0).click();
+ SWTBotShell sh = bot().activeShell();
+ SWTBotTree tree = sh.bot().treeInGroup("Web service runtime:");
+ tree.select(name);
+ sh.bot().button("OK").click();
+ sleep(50);
+ return this;
+ }
+
+ public WebServiceWizard setServiceProject(String name) {
+ findLink("Service project:").get(0).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().comboBoxWithLabel("Service project:").setSelection(name);
+ sh.bot().button("OK").click();
+ sleep(50);
+ return this;
+ }
+
+ public WebServiceWizard setServiceEARProject(String name) {
+ findLink("Service EAR project:").get(0).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().comboBoxWithLabel("Service EAR project:").setSelection(name);
+ sh.bot().button("OK").click();
+ sleep(50);
+ return this;
+ }
+
+ public WebServiceWizard setServiceSlider(Slider_Level level) {
+ if (Slider_Level.NO_CLIENT == level) {
+ throw new UnsupportedOperationException("Unsupported level: " + level);
+ }
+ scale(0).setSelection(level.ordinal());
+ return this;
+ }
+
+ public WebServiceWizard setClientSlider(Slider_Level level) {
+ scale(1).setSelection(level.ordinal());
+ return this;
+ }
+
+ public boolean isClientEnabled() {
+ return scale(1).isEnabled();
+ }
+
+ private List<SWTBotHyperlinkExt> findLink(String text) {
+ List<? extends Hyperlink> widgets =
bot().widgets(WidgetMatcherFactory.widgetOfType(Hyperlink.class));
+ List<SWTBotHyperlinkExt> ret = new ArrayList<SWTBotHyperlinkExt>();
+ for (Hyperlink h: widgets) {
+ if (h.getText().indexOf(text) > -1) {
+ ret.add(new SWTBotHyperlinkExt(h));
+ }
+ }
+ return ret;
+ }
+
+ private SWTBotScaleExt scale(int i) {
+ List<? extends Scale> widgets =
bot().widgets(WidgetMatcherFactory.widgetOfType(Scale.class));
+ List<SWTBotScaleExt> ret = new ArrayList<SWTBotScaleExt>();
+ for (Scale s: widgets) {
+ ret.add(new SWTBotScaleExt(s));
+ }
+ return ret.get(i);
+ }
+}
Modified:
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 2010-11-19
14:32:37 UTC (rev 26767)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/uiutils/wizards/Wizard.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -11,13 +11,21 @@
package org.jboss.tools.ws.ui.bot.test.uiutils.wizards;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.VoidResult;
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;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
public class Wizard extends SWTBotShell {
+ public Wizard() {
+ this(new SWTBotExt().activeShell().widget);
+ }
+
public Wizard(Shell shell) {
super(shell);
assert getText().contains("New ");
@@ -25,10 +33,21 @@
public Wizard selectTemplate(String... item) {
assert item.length > 0;
- SWTBotTree tree = bot().tree();
+ final 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();
+ //make sure ti is visible
+ final TreeItem t = ti.widget;
+ UIThreadRunnable.syncExec(new VoidResult() {
+
+ @Override
+ public void run() {
+ tree.widget.showItem(t);
+ }
+ });
+ ti.click();
+ sleep(50);
}
sleep(100);
if (ti != null) {
Copied:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/WSClient.java
(from rev 26699,
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/utils/WSClient.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/WSClient.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -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.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.net.URL;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.ws.Dispatch;
+import javax.xml.ws.Service;
+import javax.xml.ws.Service.Mode;
+
+public class WSClient {
+
+ private static final Logger L = Logger.getLogger(WSClient.class.getName());
+ 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;
+ try {
+ SOAPMessage msg = MessageFactory.newInstance().createMessage( null, new
ByteArrayInputStream(message.getBytes()));
+ msg.saveChanges();
+ result = d.invoke(msg);
+ } catch (SOAPException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } catch (IOException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ }
+ String s = msgToString(result);
+ L.fine("SOAP Request :\n" + message);
+ L.fine("SOAP Response:\n" + s);
+ return s;
+ }
+
+ private String msgToString(SOAPMessage msg) {
+ if (msg == null) {
+ return "";
+ }
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ try {
+ msg.writeTo(out);
+ } catch (SOAPException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } catch (IOException e) {
+ L.log(Level.WARNING, e.getMessage(), e);
+ } finally {
+ try {
+ out.close();
+ } catch (IOException e) {
+ //ignore
+ L.log(Level.WARNING, e.getMessage(), e);
+ }
+ }
+ return out.toString();
+ }
+}
Copied:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/BottomUpWSTest.java
(from rev 26699,
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/BottomUpWebService.java)
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/BottomUpWSTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/BottomUpWSTest.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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.wtp;
+
+import java.text.MessageFormat;
+
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WebServiceWizard.Service_Type;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WebServiceWizard.Slider_Level;
+import org.junit.Test;
+
+
+@SWTBotTestRequires(server=@Server(),perspective="Java EE")
+public class BottomUpWSTest extends WSTestBase {
+
+ //http://localhost:8080/BottomUpWS/ClassA?wsdl
+ /*
+ <soap:Body>
+<method xmlns = "http://jbossws/">
+</method>
+</soap:Body>
+
+<soap:Body>
+<ns2:methodResponse xmlns:ns2="http://jbossws/">
+<return>1234567890</return>
+</ns2:methodResponse>
+</soap:Body>
+ */
+
+ @Override
+ protected String getWsPackage() {
+ return "jbossws." + getLevel().toString().toLowerCase();
+ }
+
+ @Override
+ protected String getWsName() {
+ return "JavaWs_" + getLevel();
+ }
+
+ protected String getWsProjectName() {
+ return "BottomUpWS-web";
+ }
+
+ @Override
+ protected String getEarProjectName() {
+ return "BottomUpWS-ear";
+ }
+
+ @Test
+ public void testDevelopService() {
+ setLevel(Slider_Level.DEVELOP);
+ bottomUpJbossWebService();
+ }
+
+ @Test
+ public void testAssembleService() {
+ setLevel(Slider_Level.ASSEMBLE);
+ bottomUpJbossWebService();
+ }
+
+ @Test
+ public void testDeployService() {
+ setLevel(Slider_Level.DEPLOY);
+ bottomUpJbossWebService();
+ }
+
+ @Test
+ public void testInstallService() {
+ setLevel(Slider_Level.INSTALL);
+ bottomUpJbossWebService();
+ }
+
+ @Test
+ public void testStartService() {
+ setLevel(Slider_Level.START);
+ bottomUpJbossWebService();
+ }
+
+ @Test
+ public void testTestService() {
+ setLevel(Slider_Level.TEST);
+ bottomUpJbossWebService();
+ }
+
+ private void bottomUpJbossWebService() {
+ String s =
readStream(BottomUpWSTest.class.getResourceAsStream("/resources/jbossws/ClassA.java.ws"));
+ String src = MessageFormat.format(s, getWsPackage(), getWsName());
+ createService(Service_Type.BOTTOM_UP, getWsPackage() + "." + getWsName(),
getLevel(), src);
+// runProject(getProjectName());
+ switch (getLevel()) {
+ case DEVELOP:
+ return;
+ case ASSEMBLE:
+ case DEPLOY:
+ runProject(getEarProjectName());
+ break;
+ }
+ assertServiceDeployed(getWSDLUrl());
+// checkService(getWSDLUrl(svcName.substring(svcName.lastIndexOf(".") + 1)),
QName service, QName port, String msg, String rsp)
+// servers.removeAllProjectsFromServer(configuredState.getServer().name);
+ }
+
+}
Copied:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/TopDownWSTest.java
(from rev 26699,
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/TopDownWebService.java)
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/TopDownWSTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/TopDownWSTest.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * 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.wtp;
+
+import java.text.MessageFormat;
+
+import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WebServiceWizard.Service_Type;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WebServiceWizard.Slider_Level;
+import org.junit.Test;
+
+@SWTBotTestRequires(server=@Server(),perspective="Java EE")
+public class TopDownWSTest extends WSTestBase {
+
+ @Override
+ protected String getEarProjectName() {
+ return "TopDownWS-ear";
+ }
+
+ @Override
+ protected String getWsPackage() {
+ return "jbossws.td." + getLevel().toString().toLowerCase();
+ }
+
+ @Override
+ protected String getWsName() {
+ return "WsdlWs" + getLevel();
+ }
+
+ @Override
+ protected String getWsProjectName() {
+ return "TopDownWS-web";
+ }
+
+ //http://localhost:8080/TopDownJbossWS/jbossws.ClassB?wsdl
+ /*
+<soap:Body>
+<method xmlns = "http://jbossws/">
+</method>
+</soap:Body>
+
+<soap:Body>
+<ns2:methodResponse xmlns:ns2="http://jbossws/">
+<return>0</return>
+</ns2:methodResponse>
+</soap:Body>
+ */
+
+ @Test
+ public void testDevelopService() {
+ setLevel(Slider_Level.DEVELOP);
+ topDownWS();
+ }
+
+ @Test
+ public void testAssembleService() {
+ setLevel(Slider_Level.ASSEMBLE);
+ topDownWS();
+ }
+
+ @Test
+ public void testDeployService() {
+ setLevel(Slider_Level.DEPLOY);
+ topDownWS();
+ }
+
+ @Test
+ public void testInstallService() {
+ setLevel(Slider_Level.INSTALL);
+ topDownWS();
+ }
+
+ @Test
+ public void testStartService() {
+ setLevel(Slider_Level.START);
+ topDownWS();
+ }
+
+ @Test
+ public void testTestService() {
+ setLevel(Slider_Level.TEST);
+ topDownWS();
+ }
+
+ private void topDownWS() {
+ String s =
readStream(TopDownWSTest.class.getResourceAsStream("/resources/jbossws/ClassB.wsdl"));
+ String[] tns = getWsPackage().split("\\.");
+ StringBuilder sb = new StringBuilder();
+ for (int i = tns.length - 1; i > 0; i--) {
+ sb.append(tns[i]);
+ sb.append(".");
+ }
+ sb.append(tns[0]);
+ String src = MessageFormat.format(s, sb.toString(), getWsName());
+ createService(Service_Type.TOP_DOWN, "/" + getWsProjectName() +
"/src/" + getWsName() + ".wsdl", getLevel(), src);
+// runProject(getProjectName());
+ assertServiceDeployed(getWSDLUrl());
+// servers.removeAllProjectsFromServer(configuredState.getServer().name);
+ }
+
+}
Copied:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/WSTestBase.java
(from rev 26699,
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/wtp/WSTestBase.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/WSTestBase.java 2010-11-19
14:40:46 UTC (rev 26768)
@@ -0,0 +1,361 @@
+/*******************************************************************************
+ * 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.wtp;
+
+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.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.MessageFormat;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+import
org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.JavaEEEnterpriseApplicationProject;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWSDL;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWebServiceClient;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServlet;
+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.jboss.tools.ws.ui.bot.test.uiutils.wizards.WebServiceWizard;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WebServiceWizard.Service_Type;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WebServiceWizard.Slider_Level;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.Wizard;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+
+(a)RunWith(SWTBotJunit4ClassRunner.class)
+public abstract class WSTestBase extends SWTTestExt {
+
+ public static final String EAR_PROJECT_NAME="EAR";
+
+ public static final String CLASS_C="ClassC";
+ public static final String BOTTOMUP_WS_CLIENT_PROJ_NAME =
"BottomUpJbossWSClient";
+ public static final String BOTTOMUP_WS_CLIENT_SERVLET_NAME =
"BottomUpJbossWStest";
+ public static final String BOTTOMUP_WS_CLIENT_SERVLET_URL =
"http://localhost:8080/"+BOTTOMUP_WS_CLIENT_PROJ_NAME+"/"+BOTTOMUP_WS_CLIENT_SERVLET_NAME;
+ public static final String
TWO_SERVICES_CLIENT_SERVLET_NAME="TwoServicesJbossWStest";
+ public static final String TWO_SERVICES_CLIENT_SERVLET_URL =
"http://localhost:8080/"+BOTTOMUP_WS_CLIENT_PROJ_NAME+"/"+TWO_SERVICES_CLIENT_SERVLET_NAME;
+ public static final String TOPDOWN_WS_CLIENT_PROJ_NAME =
"TopDownJbossWSClient";
+ public static final String TOPDOWN_WS_CLIENT_SERVLET_NAME =
"TopDownJbossWStest";
+ public static final String TOPDOWN_WS_CLIENT_SERVLET_URL =
"http://localhost:8080/"+TOPDOWN_WS_CLIENT_PROJ_NAME+"/"+TOPDOWN_WS_CLIENT_SERVLET_NAME;
+ public static final String JBOSSWS_CRED_LOGIN="admin";
+ public static final String JBOSSWS_CRED_PASS="admin";
+ public static final int CLIENT_SCALE_START=1;
+
+ 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>";
+
+ private static final Logger L = Logger.getLogger(WSTestBase.class.getName());
+ private Slider_Level level;
+
+ @Before
+ public void setup() {
+ if (getEarProjectName() != null && !projectExists(getEarProjectName())) {
+ createEARProject(getEarProjectName());
+ }
+ if (!projectExists(getWsProjectName())) {
+ createProject(getWsProjectName());
+ }
+ }
+
+ private boolean projectExists(String name) {
+ return projectExplorer.existsResource(name);
+ }
+
+ @After
+ public void cleanup() {
+ servers.removeAllProjectsFromServer();
+ }
+
+ @AfterClass
+ public static void cleanAll() {
+ projectExplorer.deleteAllProjects();
+ }
+
+ protected abstract String getWsProjectName();
+
+ protected String getEarProjectName() {
+ return null;
+ }
+
+ protected abstract String getWsPackage();
+ protected abstract String getWsName();
+
+ protected void setLevel(Slider_Level level) {
+ this.level = level;
+ }
+
+ protected Slider_Level getLevel() {
+ return level;
+ }
+
+ protected String getWSDLUrl() {
+ return "http://localhost:8080/" + getWsProjectName() + "/" +
getWsName() + "?wsdl";
+ }
+
+ protected void createClient(String projectName, String servletName,String wsdlDef, int
type) {
+ createProject(projectName);
+ SWTBot wiz = open.newObject(WebServicesWebServiceClient.LABEL);
+ wiz.comboBoxWithLabel(
+ WebServicesWebServiceClient.TEXT_SERVICE_DEFINITION).setText(
+ wsdlDef);
+ SWTBotScaleExt slider = bot.scale();
+ slider.setSelection(type);
+ selectJbossWSRuntime();
+ bot.sleep(TIME_1S); // wait for wizard to validate wsdl url and
+ // enable Finish button
+ open.finish(wiz);
+ projectExplorer.selectProject(projectName);
+ // create servlet which will invoke service
+ createInvokingServlet(servletName);
+ }
+
+ /**
+ * checks if 'Web Service Runtime' is set to 'JbossWS' and possibly sets
it correctly
+ * @param wiz wizard page of new Web Service
+ */
+ @Deprecated
+ protected void selectJbossWSRuntime() {
+ SWTBotHyperlinkExt link = bot.hyperlink(1);
+ String linkText = link.getText();
+ if (!linkText.contains("JBossWS")) {
+ link.click();
+ SWTBot dBot = bot.activeShell().bot();
+ dBot.tree().select("JBossWS");
+ open.finish(dBot,IDELabel.Button.OK);
+ }
+ }
+
+ protected void createService(Service_Type t, String source, Slider_Level level, String
code) {
+ //create ws source - java class or wsdl
+ SWTBotEditor ed = null;
+ switch (t) {
+ case BOTTOM_UP:
+ ed = createClass(getWsPackage(), getWsName());
+ break;
+ case TOP_DOWN:
+ ed = createWsdl(getWsName());
+ break;
+ }
+ assertNotNull(ed);
+ //replace default content of java class w/ code
+ SWTBotEclipseEditor st = ed.toTextEditor();
+ st.selectRange(0, 0, st.getText().length());
+ st.setText(code);
+ ed.saveAndClose();
+ //create a web service
+ new NewFileWizardAction().run().selectTemplate("Web Services", "Web
Service").next();
+ WebServiceWizard wsw = new WebServiceWizard();
+ wsw.setServiceType(t);
+ wsw.setServiceSource(source);
+ wsw.setServerRuntime(configuredState.getServer().name);
+ wsw.setWebServiceRuntime("JBossWS");
+ wsw.setServiceProject(getWsProjectName());
+ wsw.setServiceEARProject(getEarProjectName());
+ wsw.setServiceSlider(level);
+ if (wsw.isClientEnabled()) {
+ wsw.setClientSlider(Slider_Level.NO_CLIENT);
+ }
+ wsw.finish();
+ util.waitForNonIgnoredJobs();
+ bot.sleep(1000);
+ }
+
+ private SWTBotEditor createClass(String pkg, String cName) {
+ new NewFileWizardAction().run().selectTemplate("Class").next();
+ Wizard w = new Wizard();
+ w.bot().textWithLabel("Package:").setText(pkg);
+ w.bot().textWithLabel("Name:").setText(cName);
+ w.bot().textWithLabel("Source folder:").setText(getWsProjectName() +
"/src");
+ w.finish();
+ return bot.editorByTitle(cName + ".java");
+ }
+
+ private SWTBotEditor createWsdl(String s) {
+ SWTBot wiz1 = open.newObject(WebServicesWSDL.LABEL);
+ wiz1.textWithLabel(WebServicesWSDL.TEXT_FILE_NAME).setText(s + ".wsdl");
+ wiz1.textWithLabel(WebServicesWSDL.TEXT_ENTER_OR_SELECT_THE_PARENT_FOLDER)
+ .setText(getWsProjectName() + "/src");
+ wiz1.button(IDELabel.Button.NEXT).click();
+ open.finish(wiz1);
+ return bot.editorByTitle(s + ".wsdl");
+ }
+
+ protected void createInvokingServlet(String servletName) {
+ String PKG_NAME="jbossws";
+ SWTBot wiz = open.newObject(WebServlet.LABEL);
+ wiz.textWithLabel(WebServlet.TEXT_JAVA_PACKAGE).setText(
+ PKG_NAME);
+ wiz.textWithLabel(WebServlet.TEXT_CLASS_NAME).setText(
+ servletName);
+ open.finish(wiz);
+ eclipse.setClassContentFromResource(bot
+ .editorByTitle(servletName
+ + ".java"), true,
+ org.jboss.tools.ws.ui.bot.test.Activator.PLUGIN_ID,
+ PKG_NAME, servletName
+ + ".java.servlet");
+ }
+
+ protected void createProject(String name) {
+ new NewFileWizardAction().run().selectTemplate("Web", "Dynamic Web
Project").next();
+ new DynamicWebProjectWizard().setProjectName(name).finish();
+ util.waitForNonIgnoredJobs();
+ assertTrue(projectExplorer.existsResource(name));
+ projectExplorer.selectProject(name);
+ }
+
+ protected void createEARProject(String name) {
+ SWTBot wiz = open.newObject(JavaEEEnterpriseApplicationProject.LABEL);
+ wiz.textWithLabel(JavaEEEnterpriseApplicationProject.TEXT_PROJECT_NAME).setText(name);
+ // set EAR version
+ SWTBotCombo combo = wiz.comboBox(1);
+ combo.setSelection(combo.itemCount()-1);
+ wiz.button(IDELabel.Button.NEXT).click();
+ wiz.checkBox("Generate application.xml deployment descriptor").click();
+ open.finish(wiz);
+ bot.sleep(5000);
+ assertTrue(projectExplorer.existsResource(name));
+ projectExplorer.selectProject(name);
+ }
+
+ protected void assertServiceDeployed(String wsdlURL) {
+ HttpURLConnection connection = null;
+ try {
+ URL u = new URL(wsdlURL);
+ connection = (HttpURLConnection) u.openConnection();
+ assertEquals("Service was not sucessfully deployed, WSDL '" + wsdlURL +
"' was not found",
+ HttpURLConnection.HTTP_OK, connection.getResponseCode());
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ protected void assertServiceNotDeployed(String wsdlURL) {
+ HttpURLConnection connection = null;
+ try {
+ URL u = new URL(wsdlURL);
+ connection = (HttpURLConnection) u.openConnection();
+ assertEquals("Project was not sucessfully undeployed, WSDL '" + wsdlURL
+ "' is still available",
+ HttpURLConnection.HTTP_NOT_FOUND, connection.getResponseCode());
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ protected void assertServiceResponseToClient(String startServlet, String response) {
+ InputStream is = null;
+ try {
+ URL u = new URL(startServlet);
+ is = u.openStream();
+ String rsp = readStream(is);
+ assertContains(response, rsp);
+ } catch (MalformedURLException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ //ignore
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public static String getSoapRequest(String body) {
+ return MessageFormat.format(SOAP_REQUEST_TEMPLATE, body);
+ }
+
+ protected 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() : "";
+ }
+
+ protected void runProject(String project) {
+ open.viewOpen(ActionItem.View.ServerServers.LABEL);
+ projectExplorer.runOnServer(project);
+ bot.sleep(5000);
+ }
+
+
+}