Author: jjankovi
Date: 2011-12-16 06:34:14 -0500 (Fri, 16 Dec 2011)
New Revision: 37393
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/DeploymentHelper.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ProjectHelper.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/WebServiceClientHelper.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/BottomUpWSTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/TopDownWSTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/WebServiceTestBase.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPCompAllTests.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPFromJavaTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPFromWSDLTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wsclient/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wsclient/WSClient.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wsclient/WsClientTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wstester/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wstester/WsTesterTest.java
Removed:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/
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/utils/WSClient.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wtp/
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/EAPCompAllTests.launch
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JBossWSProjectFacetBotTest.java
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/sample/SampleRESTWebServiceTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleSoapWebServiceTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleWSBase.java
Log:
Huge decomposition of all web services bot tests
Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/EAPCompAllTests.launch
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/EAPCompAllTests.launch 2011-12-16
08:34:19 UTC (rev 37392)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/EAPCompAllTests.launch 2011-12-16
11:34:14 UTC (rev 37393)
@@ -14,7 +14,7 @@
<booleanAttribute key="includeOptional" value="true"/>
<stringAttribute key="location"
value="${workspace_loc}/../junit-workspace"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry
value="/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/eap/EAPCompAllTests.java"/>
+<listEntry
value="/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPCompAllTests.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
@@ -26,7 +26,7 @@
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR"
value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME"
value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND"
value="org.eclipse.jdt.junit.loader.junit4"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.jboss.tools.ws.ui.bot.test.eap.EAPCompAllTests"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.jboss.tools.ws.ui.bot.test.webservice.eap.EAPCompAllTests"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl}
-consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="org.jboss.tools.ws.ui.bot.test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER"
value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
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 2011-12-16 08:34:19
UTC (rev 37392)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF 2011-12-16 11:34:14
UTC (rev 37393)
@@ -35,4 +35,4 @@
org.jboss.tools.ui.bot.ext,
org.osgi.framework,
org.jboss.tools.ws.ui.bot.test.uiutils.wizards",
- org.jboss.tools.ws.ui.bot.test.eap
+ org.jboss.tools.ws.ui.bot.test.webservice.eap
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JBossWSProjectFacetBotTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JBossWSProjectFacetBotTest.java 2011-12-16
08:34:19 UTC (rev 37392)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JBossWSProjectFacetBotTest.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -1,3 +1,13 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-2009 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.ws.ui.bot.test;
import java.io.IOException;
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 2011-12-16
08:34:19 UTC (rev 37392)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -11,14 +11,14 @@
package org.jboss.tools.ws.ui.bot.test;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-import org.jboss.tools.ws.ui.bot.test.eap.EAPFromJavaTest;
-import org.jboss.tools.ws.ui.bot.test.eap.EAPFromWSDLTest;
-import org.jboss.tools.ws.ui.bot.test.jbt.WsTesterTest;
import org.jboss.tools.ws.ui.bot.test.sample.SampleRESTWebServiceTest;
import org.jboss.tools.ws.ui.bot.test.sample.SampleSoapWebServiceTest;
-import org.jboss.tools.ws.ui.bot.test.wtp.BottomUpWSTest;
-import org.jboss.tools.ws.ui.bot.test.wtp.TopDownWSTest;
-import org.jboss.tools.ws.ui.bot.test.wtp.WsClientTest;
+import org.jboss.tools.ws.ui.bot.test.webservice.BottomUpWSTest;
+import org.jboss.tools.ws.ui.bot.test.webservice.TopDownWSTest;
+import org.jboss.tools.ws.ui.bot.test.webservice.eap.EAPFromJavaTest;
+import org.jboss.tools.ws.ui.bot.test.webservice.eap.EAPFromWSDLTest;
+import org.jboss.tools.ws.ui.bot.test.wsclient.WsClientTest;
+import org.jboss.tools.ws.ui.bot.test.wstester.WsTesterTest;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test;
+
+import java.text.MessageFormat;
+import java.util.logging.Logger;
+
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WsWizardBase.Slider_Level;
+import org.jboss.tools.ws.ui.bot.test.utils.DeploymentHelper;
+import org.jboss.tools.ws.ui.bot.test.utils.ProjectHelper;
+import org.jboss.tools.ws.ui.bot.test.utils.ResourceHelper;
+import org.jboss.tools.ws.ui.bot.test.utils.WebServiceClientHelper;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+@Require(server=@Server(),perspective="Java EE")
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ WSAllBotTests.class })
+public class WSTestBase extends SWTTestExt {
+
+ private Slider_Level level;
+
+ 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>";
+
+ protected static final Logger LOGGER = Logger
+ .getLogger(WSTestBase.class.getName());
+
+ protected static ResourceHelper resourceHelper = new ResourceHelper();
+ protected static ProjectHelper projectHelper = new ProjectHelper();
+ protected static DeploymentHelper deploymentHelper = new DeploymentHelper();
+ protected static WebServiceClientHelper clientHelper = new WebServiceClientHelper();
+
+ @Before
+ public void setup() {
+ if (getEarProjectName() != null && !projectExists(getEarProjectName())) {
+ projectHelper.createEARProject(getEarProjectName());
+ }
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ }
+
+ protected boolean projectExists(String name) {
+ return projectExplorer.existsResource(name);
+ }
+
+ @After
+ public void cleanup() {
+ servers.removeAllProjectsFromServer();
+ }
+
+ @AfterClass
+ public static void cleanAll() {
+ LOGGER.info("cleanAll");
+ projectExplorer.deleteAllProjects();
+ }
+
+ protected Slider_Level getLevel() {
+ return level;
+ }
+
+ protected void setLevel(Slider_Level level) {
+ this.level = level;
+ }
+
+ protected String getWsProjectName() {
+ return null;
+ }
+
+ protected String getEarProjectName() {
+ return null;
+ }
+
+ protected String getWsPackage() {
+ return null;
+ }
+
+ protected String getWsName() {
+ return null;
+ }
+
+ public static String getSoapRequest(String body) {
+ return MessageFormat.format(SOAP_REQUEST_TEMPLATE, body);
+ }
+
+}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleRESTWebServiceTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleRESTWebServiceTest.java 2011-12-16
08:34:19 UTC (rev 37392)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleRESTWebServiceTest.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -20,8 +20,14 @@
import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ws.ui.bot.test.uiutils.actions.TreeItemAction;
import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.SampleWSWizard.Type;
+import org.junit.Ignore;
import org.junit.Test;
+/**
+ *
+ * @author jjankovi
+ *
+ */
public class SampleRESTWebServiceTest extends SampleWSBase {
private final String REST_WS_NODE = "JAX-RS REST Web Services";
@@ -46,7 +52,7 @@
createSampleRESTWS(getWsProjectName(), "RESTSample",
"rest.sample", "Sample", "RESTApp");
checkRESTService(getWsProjectName(), "RESTSample",
"rest.sample", "Sample", "Hello World!",
"RESTApp");
}
-
+ @Ignore //not implemented yet
@Test
public void testSimpleRestWS() {
@@ -69,7 +75,7 @@
private void createSampleRESTWS(String project, String name, String pkg, String cls,
String appCls) {
SWTBotEditor ed = createSampleService(Type.REST, project, name, pkg, cls, appCls);
- copyResourceToClass(ed, SampleRESTWebServiceTest.class.
+ resourceHelper.copyResourceToClass(ed, SampleRESTWebServiceTest.class.
getResourceAsStream("/resources/jbossws/Rest.java.ws"),false);
}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleSoapWebServiceTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleSoapWebServiceTest.java 2011-12-16
08:34:19 UTC (rev 37392)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleSoapWebServiceTest.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -11,8 +11,14 @@
package org.jboss.tools.ws.ui.bot.test.sample;
import org.eclipse.core.resources.IFile;
+import org.junit.Ignore;
import org.junit.Test;
+/**
+ *
+ * @author jjankovi
+ *
+ */
public class SampleSoapWebServiceTest extends SampleWSBase {
@Override
@@ -33,10 +39,9 @@
createSampleSOAPWS(getWsProjectName(), "GreetService",
"greeter", "Greeter");
checkSOAPService(getWsProjectName(), "GreetService",
"greeter", "Greeter", "Tester");
}
-
+ @Ignore //not implemented yet
@Test
public void testSimpleSoapWS() {
}
-
}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleWSBase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleWSBase.java 2011-12-16
08:34:19 UTC (rev 37392)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/sample/SampleWSBase.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -16,7 +16,6 @@
import java.net.URL;
import java.text.MessageFormat;
import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.xml.namespace.QName;
@@ -26,50 +25,29 @@
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.RequirementAwareSuite;
-import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
-import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
-import org.jboss.tools.ws.ui.bot.test.WSAllBotTests;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
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.jboss.tools.ws.ui.bot.test.wsclient.WSClient;
import org.junit.AfterClass;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-@Require(server=@Server(),perspective="Java EE")
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ WSAllBotTests.class })
+/**
+ *
+ * @author jjankovi
+ *
+ */
public class SampleWSBase extends WSTestBase {
protected static final String SOAP_REQUEST = getSoapRequest("<ns1:sayHello
xmlns:ns1=\"http://{0}/\"><arg0>{1}</arg0></ns1:sayHello>");
protected static final String SERVER_URL = "localhost:8080";
- protected static final Logger L =
Logger.getLogger(SampleSoapWebServiceTest.class.getName());
@AfterClass
public static void clean() {
servers.removeAllProjectsFromServer();
- //projectExplorer.deleteAllProjects();
}
- @Override
- protected String getWsProjectName() {
- return null;
- }
-
- @Override
- protected String getWsPackage() {
- return null;
- }
-
- @Override
- protected String getWsName() {
- return null;
- }
-
protected void createDD(String project) {
SWTBotTree tree = projectExplorer.bot().tree();
SWTBotTreeItem ti = tree.expandNode(project);
@@ -107,7 +85,7 @@
assertEquals(svcClass + ".java", ed.getTitle());
String code = ed.toTextEditor().getText();
assertContains("package " + svcPkg + ";", code);
- String dd = readFile(getDD(project));
+ String dd = resourceHelper.readFile(getDD(project));
switch (type) {
case REST:
assertContains("@Path(\"/" + svcName +
"\")", code);
@@ -120,17 +98,17 @@
assertContains("<servlet-name>" + svcName +
"</servlet-name>", dd);
break;
}
- runProject(project);
+ deploymentHelper.runProject(project);
switch (type) {
case REST:
try {
URL u = new URL("http://" + SERVER_URL + "/" +
project + "/" + svcName);
- String s = readStream(u.openConnection().getInputStream());
+ String s =
resourceHelper.readStream(u.openConnection().getInputStream());
assertEquals(msgContent, s);
} catch (MalformedURLException e) {
- L.log(Level.WARNING, e.getMessage(), e);
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
} catch (IOException e) {
- L.log(Level.WARNING, e.getMessage(), e);
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
}
break;
case SOAP:
@@ -140,7 +118,7 @@
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);
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
}
break;
}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/DeploymentHelper.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/DeploymentHelper.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/DeploymentHelper.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * 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.IOException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Scanner;
+import java.util.logging.Logger;
+
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class DeploymentHelper extends SWTTestExt {
+
+ private final Logger LOGGER = Logger
+ .getLogger(DeploymentHelper.class.getName());
+
+ /**
+ *
+ * @param project
+ */
+ public void runProject(String project) {
+ open.viewOpen(ActionItem.View.ServerServers.LABEL);
+ projectExplorer.runOnServer(project);
+ }
+
+ /**
+ *
+ * @param wsdlURL
+ */
+ public void assertServiceDeployed(String wsdlURL) {
+ assertServiceDeployed(wsdlURL, 5000);
+ }
+
+ /**
+ *
+ * @param wsdlURL
+ * @param timeout
+ */
+ public void assertServiceDeployed(String wsdlURL, long timeout) {
+ long t = System.currentTimeMillis();
+ int rsp = -1;
+ while (t + timeout > System.currentTimeMillis()) {
+ HttpURLConnection connection = null;
+ try {
+ URL u = new URL(wsdlURL);
+ connection = (HttpURLConnection) u.openConnection();
+ rsp = connection.getResponseCode();
+ if (rsp == HttpURLConnection.HTTP_OK) {
+ break;
+ } else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ LOGGER.info("retrying...");
+ }
+ } catch (MalformedURLException e1) {
+ throw new RuntimeException(e1);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+ LOGGER.info("done after: " + (System.currentTimeMillis() - t) +
"ms.");
+ assertEquals("Service was not sucessfully deployed, WSDL '" + wsdlURL
+ + "' was not found", HttpURLConnection.HTTP_OK, rsp);
+ }
+
+ /**
+ *
+ * @param wsdlURL
+ */
+ public 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) {
+ throw new RuntimeException(e1);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+
+ /**
+ *
+ * @param startServlet
+ * @param response
+ */
+ public void assertServiceResponseToClient(String startServlet,
+ String response) {
+ assertContains(response, getPage(startServlet, 15000));
+ }
+
+ /**
+ *
+ * @param url
+ * @param timeout
+ * @return
+ */
+ public String getPage(String url, long timeout) {
+ long t = System.currentTimeMillis();
+ int rsp = -1;
+ String page = null;
+ while (t + timeout > System.currentTimeMillis()) {
+ HttpURLConnection connection = null;
+ try {
+ URL u = new URL(url);
+ connection = (HttpURLConnection) u.openConnection();
+ rsp = connection.getResponseCode();
+ if (rsp == HttpURLConnection.HTTP_OK) {
+ page = new Scanner(connection.getInputStream())
+ .useDelimiter("\\A").next();
+ break;
+ } else {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ // ignore
+ }
+ LOGGER.info("retrying...");
+ }
+ } catch (MalformedURLException e1) {
+ throw new RuntimeException(e1);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (connection != null) {
+ connection.disconnect();
+ }
+ }
+ }
+ LOGGER.info("done after: " + (System.currentTimeMillis() - t) +
"ms.");
+ assertEquals("cannot connect to '" + url + "'",
+ HttpURLConnection.HTTP_OK, rsp);
+ return page;
+ }
+
+ /**
+ *
+ * @param projectName
+ * @param wsName
+ * @return
+ */
+ public String getWSDLUrl(String projectName, String wsName) {
+ return "http://localhost:8080/" + projectName + "/"
+ + wsName + "?wsdl";
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ProjectHelper.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ProjectHelper.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ProjectHelper.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 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 org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+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.NewObject.JavaEEEnterpriseApplicationProject;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWSDL;
+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.Wizard;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class ProjectHelper extends SWTTestExt {
+
+ /**
+ *
+ * @param projectName
+ * @param pkg
+ * @param cName
+ * @return
+ */
+ public SWTBotEditor createClass(String projectName, String pkg, String cName) {
+ new NewFileWizardAction().run().selectTemplate("Java",
"Class").next();
+ Wizard w = new Wizard();
+ w.bot().textWithLabel("Package:").setText(pkg);
+ w.bot().textWithLabel("Name:").setText(cName);
+ w.bot().textWithLabel("Source folder:")
+ .setText(projectName + "/src");
+ w.finish();
+ bot.sleep(4500);
+ return bot.editorByTitle(cName + ".java");
+ }
+
+ /**
+ *
+ * @param projectName
+ * @param s
+ * @return
+ */
+ public SWTBotEditor createWsdl(String projectName, 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(projectName + "/src");
+ wiz1.button(IDELabel.Button.NEXT).click();
+ open.finish(wiz1);
+ return bot.editorByTitle(s + ".wsdl");
+ }
+
+ /**
+ *
+ * @param name
+ */
+ public 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);
+ }
+
+ /**
+ *
+ * @param name
+ */
+ public 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);
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,84 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 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.IOException;
+import java.io.InputStream;
+import java.util.Scanner;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class ResourceHelper {
+
+ /**
+ *
+ * @param is
+ * @return
+ */
+ public String readStream(InputStream is) {
+ // we don't care about performance in tests too much, so this should be
+ // OK
+ return new Scanner(is).useDelimiter("\\A").next();
+ }
+
+ /**
+ *
+ * @param f
+ * @return
+ */
+ public String readFile(IFile f) {
+ String content = null;
+ InputStream is = null;
+ try {
+ is = f.getContents();
+ content = readStream(is);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ throw new RuntimeException(e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+ return content;
+ }
+
+ /**
+ *
+ * @param classEdit
+ * @param resource
+ * @param closeEdit
+ */
+ public void copyResourceToClass(SWTBotEditor classEdit,
+ InputStream resource, boolean closeEdit) {
+ SWTBotEclipseEditor st = classEdit.toTextEditor();
+ st.selectRange(0, 0, st.getText().length());
+ String code = readStream(resource);
+ st.setText(code);
+ classEdit.save();
+ if (closeEdit) classEdit.close();
+ }
+
+
+}
Deleted:
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/utils/WSClient.java 2011-12-16
08:34:19 UTC (rev 37392)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/WSClient.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -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.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();
- }
-}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/WebServiceClientHelper.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/WebServiceClientHelper.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/WebServiceClientHelper.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,56 @@
+package org.jboss.tools.ws.ui.bot.test.utils;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+import org.jboss.tools.ws.ui.bot.test.uiutils.actions.NewFileWizardAction;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WebServiceClientWizard;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WsWizardBase.Slider_Level;
+import org.junit.Assert;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class WebServiceClientHelper extends SWTTestExt {
+
+ /**
+ *
+ * @param wsdl
+ * @param targetProject
+ * @param level
+ * @param pkg
+ */
+ public void createClient(String wsdl, String targetProject,
+ Slider_Level level, String pkg) {
+ new NewFileWizardAction().run()
+ .selectTemplate("Web Services", "Web Service Client").next();
+ WebServiceClientWizard w = new WebServiceClientWizard();
+ w.setSource(wsdl);
+ util.waitForNonIgnoredJobs();
+ bot.sleep(1000);
+ w.setSlider(level, 0);
+ w.setServerRuntime(configuredState.getServer().name);
+ w.setWebServiceRuntime("JBossWS");
+ w.setClientProject(targetProject);
+ if (pkg != null && !"".equals(pkg.trim())) {
+ w.next();
+ w.setPackageName(pkg);
+ }
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ bot.sleep(1000);
+
+ // let's fail if there's some error in the wizard,
+ // and close error dialog and the wizard so other tests
+ // can continue
+ if (bot.activeShell().getText().contains("Error")) {
+ SWTBotShell sh = bot.activeShell();
+ String msg = sh.bot().text().getText();
+ sh.bot().button(0).click();
+ w.cancel();
+ Assert.fail(msg);
+ }
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/BottomUpWSTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/BottomUpWSTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/BottomUpWSTest.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 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.webservice;
+
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WsWizardBase.Slider_Level;
+import org.junit.Test;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class BottomUpWSTest extends WebServiceTestBase {
+
+ //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 testDeployService() {
+ setLevel(Slider_Level.DEPLOY);
+ bottomUpJbossWebService();
+ }
+
+ @Test
+ public void testAssembleService() {
+ setLevel(Slider_Level.ASSEMBLE);
+ bottomUpJbossWebService();
+ }
+
+ @Test
+ public void testDevelopService() {
+ setLevel(Slider_Level.DEVELOP);
+ 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();
+ }
+
+ protected void bottomUpJbossWebService() {
+ bottomUpJbossWebService(BottomUpWSTest.class.getResourceAsStream("/resources/jbossws/ClassA.java.ws"));
+ switch (getLevel()) {
+ case DEVELOP:
+ case ASSEMBLE:
+ case DEPLOY:
+ deploymentHelper.runProject(getEarProjectName());
+ break;
+ }
+ deploymentHelper.assertServiceDeployed(deploymentHelper.getWSDLUrl(getWsProjectName(),
getWsName()), 10000);
+// checkService(getWSDLUrl(svcName.substring(svcName.lastIndexOf(".") + 1)),
QName service, QName port, String msg, String rsp)
+// servers.removeAllProjectsFromServer(configuredState.getServer().name);
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/TopDownWSTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/TopDownWSTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/TopDownWSTest.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 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.webservice;
+
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WsWizardBase.Slider_Level;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class TopDownWSTest extends WebServiceTestBase {
+
+ @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 testDeployService() {
+ setLevel(Slider_Level.DEPLOY);
+ topDownWS();
+ }
+
+ @Test
+ public void testDevelopService() {
+ setLevel(Slider_Level.DEVELOP);
+ topDownWS();
+ }
+ @Ignore
+ @Test
+ public void testAssembleService() {
+ setLevel(Slider_Level.ASSEMBLE);
+ 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();
+ }
+
+ @Test
+ public void testDefaultPkg() {
+ setLevel(Slider_Level.ASSEMBLE);
+ topDownWS(null);
+ }
+
+ private void topDownWS() {
+ topDownWS("ws." + getWsName().toLowerCase());
+ }
+
+ protected void topDownWS(String pkg) {
+ topDownWS(TopDownWSTest.class.getResourceAsStream("/resources/jbossws/ClassB.wsdl"),
pkg);
+ switch (getLevel()) {
+ case DEVELOP:
+ case ASSEMBLE:
+ case DEPLOY:
+ deploymentHelper.runProject(getEarProjectName());
+ break;
+ }
+ deploymentHelper.assertServiceDeployed(deploymentHelper.getWSDLUrl(getWsProjectName(),
getWsName()), 10000);
+ servers.removeAllProjectsFromServer(configuredState.getServer().name);
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/WebServiceTestBase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/WebServiceTestBase.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/WebServiceTestBase.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,140 @@
+/*******************************************************************************
+ * 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.webservice;
+
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.logging.Level;
+
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
+import org.jboss.tools.ws.ui.bot.test.uiutils.actions.NewFileWizardAction;
+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.WsWizardBase.Slider_Level;
+import org.junit.Assert;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class WebServiceTestBase extends WSTestBase {
+
+ /**
+ *
+ * @param javasrc
+ */
+ protected void bottomUpJbossWebService(InputStream javasrc) {
+ String s = resourceHelper.readStream(javasrc);
+ String src = MessageFormat.format(s, getWsPackage(), getWsName());
+ createService(Service_Type.BOTTOM_UP, getWsPackage() + "."
+ + getWsName(), getLevel(), null, src);
+ }
+
+ /**
+ *
+ * @param input
+ * @param pkg
+ */
+ protected void topDownWS(InputStream input, String pkg) {
+ String s = resourceHelper.readStream(input);
+ 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(), pkg, src);
+ }
+
+ /**
+ *
+ * @param t
+ * @param source
+ * @param level
+ * @param pkg
+ * @param code
+ */
+ private void createService(Service_Type t, String source,
+ Slider_Level level, String pkg, String code) {
+ // create ws source - java class or wsdl
+ SWTBotEditor ed = null;
+ switch (t) {
+ case BOTTOM_UP:
+ ed = projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ break;
+ case TOP_DOWN:
+ ed = projectHelper.createWsdl(getWsProjectName(),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();
+ // refresh workspace - workaround for JBIDE-6731
+ try {
+ ResourcesPlugin
+ .getWorkspace()
+ .getRoot()
+ .refreshLocal(IWorkspaceRoot.DEPTH_INFINITE,
+ new NullProgressMonitor());
+ } catch (CoreException e) {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ bot.sleep(500);
+ // create a web service
+ new NewFileWizardAction().run()
+ .selectTemplate("Web Services", "Web Service").next();
+ WebServiceWizard wsw = new WebServiceWizard();
+ wsw.setServiceType(t);
+ wsw.setSource(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);
+ }
+ if (pkg != null && pkg.trim().length() > 0) {
+ wsw.next();
+ wsw.setPackageName(pkg);
+ }
+ wsw.finish();
+ util.waitForNonIgnoredJobs();
+ bot.sleep(2*TIME_1S);
+
+ // let's fail if there's some error in the wizard,
+ // and close error dialog and the wizard so other tests
+ // can continue
+ if (bot.activeShell().getText().contains("Error")) {
+ SWTBotShell sh = bot.activeShell();
+ String msg = sh.bot().text().getText();
+ sh.bot().button(0).click();
+ wsw.cancel();
+ Assert.fail(msg);
+ }
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPCompAllTests.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPCompAllTests.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPCompAllTests.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.webservice.eap;
+
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Documentation/description is available at <a
href="https://docspace.corp.redhat.com/docs/DOC-43675">Docsp...
+ *
+ * @author jlukas, jjankovi
+ * @see <a
href="https://docspace.corp.redhat.com/docs/DOC-43675">DOC-4...
+ */
+@SuiteClasses({
+ EAPFromJavaTest.class,
+ EAPFromWSDLTest.class
+})
+(a)RunWith(RequirementAwareSuite.class)
+public class EAPCompAllTests {
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPFromJavaTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPFromJavaTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPFromJavaTest.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,158 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.webservice.eap;
+
+import java.util.logging.Level;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.jboss.tools.ws.ui.bot.test.WSAllBotTests;
+import org.jboss.tools.ws.ui.bot.test.uiutils.actions.NewFileWizardAction;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.Wizard;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WsWizardBase.Slider_Level;
+import org.jboss.tools.ws.ui.bot.test.webservice.WebServiceTestBase;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+@SuiteClasses({ WSAllBotTests.class, EAPCompAllTests.class })
+public class EAPFromJavaTest extends WebServiceTestBase {
+
+ private static boolean servicePassed = false;
+
+ @Before
+ @Override
+ public void setup() {
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ if (!projectExists(getWsClientProjectName())) {
+ projectHelper.createProject(getWsClientProjectName());
+ }
+ }
+
+ @After
+ @Override
+ public void cleanup() {
+ //do nothing here
+ //we don't want to undeploy our app yet
+ }
+
+ @AfterClass
+ public static void removeAllProjects() {
+ servers.removeAllProjectsFromServer();
+ }
+
+ @Override
+ protected String getWsProjectName() {
+ return "TestWSProject";
+ }
+
+ @Override
+ protected String getEarProjectName() {
+ return getWsProjectName() + "EAR";
+ }
+
+ protected String getWsClientProjectName() {
+ return "TestWSClientProject";
+ }
+
+ @Override
+ protected String getWsPackage() {
+ return "test.ws";
+ }
+
+ @Override
+ protected String getWsName() {
+ return "Echo";
+ }
+
+ @Override
+ protected Slider_Level getLevel() {
+ return Slider_Level.DEPLOY;
+ }
+
+ @Test
+ public void testService() {
+ //create a class representing some complex type
+ SWTBotEclipseEditor st = projectHelper.createClass(getWsProjectName(),
"test", "Person").toTextEditor();
+ st.selectRange(0, 0, st.getText().length());
+
st.setText(resourceHelper.readStream(EAPFromJavaTest.class.getResourceAsStream("/resources/jbossws/Person.java.ws")));
+ st.saveAndClose();
+ //refresh workspace - workaround??? for JBIDE-6731
+ try {
+
ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IWorkspaceRoot.DEPTH_INFINITE, new
NullProgressMonitor());
+ } catch (CoreException e) {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ bot.sleep(TIME_500MS);
+
bottomUpJbossWebService(EAPFromJavaTest.class.getResourceAsStream("/resources/jbossws/Echo.java.ws"));
+ IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(getWsProjectName());
+ IFile f = project.getFile("WebContent/WEB-INF/web.xml");
+ String content = resourceHelper.readFile(f);
+ Assert.assertNotNull(content);
+
Assert.assertTrue(content.contains("<servlet-class>test.ws.Echo</servlet-class>"));
+
Assert.assertTrue(content.contains("<url-pattern>/Echo</url-pattern>"));
+ deploymentHelper.runProject(getEarProjectName());
+
deploymentHelper.assertServiceDeployed(deploymentHelper.getWSDLUrl(getWsProjectName(),
getWsName()), 10000);
+ servicePassed = true;
+ }
+
+ @Test
+ public void testClient() {
+ Assert.assertTrue("service must exist", servicePassed);
+ clientHelper.createClient(deploymentHelper.getWSDLUrl(getWsProjectName(),
getWsName()),
+ getWsClientProjectName(), getLevel(), "");
+ IProject p =
ResourcesPlugin.getWorkspace().getRoot().getProject(getWsClientProjectName());
+ String pkg = "test/ws";
+ String cls = "src/" + pkg + "/EchoService.java";
+ Assert.assertTrue(p.getFile(cls).exists());
+ cls = "src/" + pkg + "/clientsample/ClientSample.java";
+ Assert.assertTrue(p.getFile(cls).exists());
+ //create JSP
+ new NewFileWizardAction().run().selectTemplate("Web", "JSP
File").next();
+ Wizard w = new Wizard();
+ w.bot().textWithLabel("File name:").setText("index");
+ w.bot().textWithLabel("Enter or select the parent
folder:").setText(getWsClientProjectName() + "/WebContent");
+ w.finish();
+ bot.sleep(TIME_5S);
+ /**
+ * Workaround for 4.x branch
+ *
+ * bot.activeShell().bot().button("Skip").click();
+ * bot.sleep(TIME_5S);
+ */
+ SWTBotEclipseEditor st =
bot.editorByTitle("index.jsp").toTextEditor();
+ st.selectRange(0, 0, st.getText().length());
+
st.setText(resourceHelper.readStream(EAPFromJavaTest.class.getResourceAsStream("/resources/jbossws/index.jsp.ws")));
+ st.saveAndClose();
+ bot.sleep(TIME_1S*2);
+ deploymentHelper.runProject(getWsClientProjectName());
+ String pageContent = deploymentHelper.getPage("http://localhost:8080/"
+ getWsClientProjectName() + "/index.jsp", 15000);
+ LOGGER.info(pageContent);
+ Assert.assertTrue(pageContent.contains("BartSimpson(age: 12)"));
+ Assert.assertTrue(pageContent.contains("Homer(age: 44)"));
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPFromWSDLTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPFromWSDLTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/webservice/eap/EAPFromWSDLTest.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,267 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.webservice.eap;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.logging.Level;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ws.ui.bot.test.WSAllBotTests;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WsWizardBase.Slider_Level;
+import org.jboss.tools.ws.ui.bot.test.webservice.TopDownWSTest;
+import org.jboss.tools.ws.ui.bot.test.webservice.WebServiceTestBase;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+@SuiteClasses({ WSAllBotTests.class, EAPCompAllTests.class })
+public class EAPFromWSDLTest extends WebServiceTestBase {
+
+ private static boolean servicePassed = false;
+
+ @Before
+ @Override
+ public void setup() {
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ if (!projectExists(getWsClientProjectName())) {
+ projectHelper.createProject(getWsClientProjectName());
+ }
+ }
+
+ @After
+ @Override
+ public void cleanup() {
+ LOGGER.info("overridden");
+ }
+
+ @AfterClass
+ public static void x() {
+ LOGGER.info("x");
+ servers.removeAllProjectsFromServer();
+ }
+
+ @Override
+ protected String getWsProjectName() {
+ return "AreaWSProject";
+ }
+
+ @Override
+ protected String getEarProjectName() {
+ return getWsProjectName() + "EAR";
+ }
+
+ protected String getWsClientProjectName() {
+ return "AreaWSClientProject";
+ }
+
+ protected String getClientEarProjectName() {
+ return getWsClientProjectName() + "EAR";
+ }
+
+ @Override
+ protected String getWsPackage() {
+ return "org.jboss.ws";
+ }
+
+ @Override
+ protected String getWsName() {
+ return "AreaService";
+ }
+
+ @Override
+ protected Slider_Level getLevel() {
+ return Slider_Level.DEPLOY;
+ }
+
+ @Test
+ public void testService() {
+ topDownWS(TopDownWSTest.class.getResourceAsStream("/resources/jbossws/AreaService.wsdl"),
+ getWsPackage());
+
+ IProject project = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(getWsProjectName());
+ IFile f = project.getFile("src/" + getWsPackage().replace(".",
"/")
+ + "/AreaServiceImpl.java");
+ /*
+ * workaround when package is not typed
+ */
+ if (f == null) {
+ f = project.getFile("src/" + "org.tempuri.areaservice"
+ + "/AreaServiceImpl.java");
+ }
+ String content = resourceHelper.readFile(f);
+ Assert.assertNotNull(content);
+ Assert.assertTrue(content
+ .contains("public class AreaServiceImpl implements AreaService {"));
+ Assert.assertTrue(content
+ .contains("public float calculateRectArea(Dimensions parameters)"));
+ replaceContent(f, "/resources/jbossws/AreaWS.java.ws");
+
+ f = project.getFile("WebContent/WEB-INF/web.xml");
+ content = resourceHelper.readFile(f);
+ Assert.assertNotNull(content);
+ Assert.assertTrue(content
+ .contains("<servlet-class>org.jboss.ws.AreaServiceImpl</servlet-class>"));
+ Assert.assertTrue(content
+ .contains("<url-pattern>/AreaService</url-pattern>"));
+ deploymentHelper.runProject(getEarProjectName());
+ deploymentHelper.assertServiceDeployed(deploymentHelper.getWSDLUrl(getWsProjectName(),
getWsName()), 10000);
+ servicePassed = true;
+ }
+
+ @Test
+ public void testClient() {
+ Assert.assertTrue("service must exist", servicePassed);
+ clientHelper.createClient(deploymentHelper.getWSDLUrl(getWsProjectName(), getWsName()),
+ getWsClientProjectName(), Slider_Level.DEVELOP, "org.jboss.wsclient");
+ IProject p = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(getWsClientProjectName());
+ String pkg = "org/jboss/wsclient";
+ String cls = "src/" + pkg + "/AreaService.java";
+ Assert.assertTrue(p.getFile(cls).exists());
+ cls = "src/" + pkg + "/clientsample/ClientSample.java";
+ IFile f = p.getFile(cls);
+ Assert.assertTrue(f.exists());
+ replaceContent(f, "/resources/jbossws/clientsample.java.ws");
+
+ /*
+ * workaround for
https://issues.jboss.org/browse/JBIDE-9817
+ */
+ projectExplorer.selectProject(getWsClientProjectName());
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(getWsClientProjectName());
+ item.expand();
+ removeRuntimeLibrary(tree, item, bot, util);
+
+ eclipse.runJavaApplication(getWsClientProjectName(),
+ "org.jboss.wsclient.clientsample.ClientSample", null);
+ util.waitForNonIgnoredJobs();
+ bot.sleep(15 * TIME_1S);
+ String output = console.getConsoleText();
+ LOGGER.info(output);
+ Assert.assertTrue(output, output.contains("Server said: 37.5"));
+ Assert.assertTrue(output.contains("Server said: 3512.3699"));
+ }
+
+ private void replaceContent(IFile f, String content) {
+ try {
+ f.delete(true, new NullProgressMonitor());
+ } catch (CoreException ce) {
+ LOGGER.log(Level.WARNING, ce.getMessage(), ce);
+ }
+ InputStream is = null;
+ try {
+ is = EAPFromWSDLTest.class.getResourceAsStream(content);
+ f.create(is, true, new NullProgressMonitor());
+ } catch (CoreException ce) {
+ LOGGER.log(Level.WARNING, ce.getMessage(), ce);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ // ignore
+ }
+ }
+ }
+ try {
+ ResourcesPlugin
+ .getWorkspace()
+ .getRoot()
+ .refreshLocal(IWorkspaceRoot.DEPTH_INFINITE,
+ new NullProgressMonitor());
+ } catch (CoreException e) {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ }
+ util.waitForNonIgnoredJobs();
+ bot.sleep(TIME_1S);
+ }
+
+ private void removeRuntimeLibrary(final SWTBotTree tree,
+ SWTBotTreeItem item, SWTBotExt bot, SWTUtilExt util) {
+ nodeContextMenu(tree, item, "Build Path", "Configure Build
Path...")
+ .click();
+ bot.activeShell().activate();
+ bot.tabItem("Libraries").activate();
+ assertTrue(!bot.button("Remove").isEnabled());
+ try {
+ findSelectEnterpriseRuntimeLibrary(bot);
+ assertTrue(bot.button("Remove").isEnabled());
+ bot.button("Remove").click();
+ bot.button("OK").click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ } catch (Exception e) {
+ e.printStackTrace();
+ bot.button("Cancel").click();
+ }
+
+ }
+
+ private void findSelectEnterpriseRuntimeLibrary(SWTBotExt bot)
+ throws Exception {
+ SWTBotTree libraryTree = bot.tree(1);
+ boolean libraryFound = false;
+ for (SWTBotTreeItem libraryItem : libraryTree.getAllItems()) {
+ if (libraryItem.getText().contains(
+ "JBoss Enterprise Application Platform")) {
+ libraryTree.select(libraryItem);
+ libraryFound = true;
+ break;
+ }
+ }
+ if (!libraryFound)
+ throw new RuntimeException("No runtime library has been found");
+ }
+
+ private SWTBotMenu nodeContextMenu(final SWTBotTree tree,
+ SWTBotTreeItem item, final String... menu) {
+ assert menu.length > 0;
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
+ return UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
+
+ public SWTBotMenu run() {
+ SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
+ tree, menu[0], false));
+ for (int i = 1; i < menu.length; i++) {
+ m = m.menu(menu[i]);
+ }
+ return m;
+ }
+ });
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wsclient/WSClient.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wsclient/WSClient.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wsclient/WSClient.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -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.wsclient;
+
+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();
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wsclient/WsClientTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wsclient/WsClientTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wsclient/WsClientTest.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.wsclient;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
+import org.jboss.tools.ws.ui.bot.test.uiutils.wizards.WsWizardBase.Slider_Level;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class WsClientTest extends WSTestBase {
+
+ @Override
+ protected String getWsProjectName() {
+ return "client";
+ }
+
+ @Override
+ protected String getWsPackage() {
+ return "client." + getLevel().toString().toLowerCase();
+ }
+
+ @Test
+ public void testDeployClient() {
+ setLevel(Slider_Level.DEPLOY);
+ clientTest(getWsPackage());
+ }
+
+ @Test
+ public void testAssembleClient() {
+ setLevel(Slider_Level.ASSEMBLE);
+ clientTest(getWsPackage());
+ }
+
+ @Test
+ public void testDevelopClient() {
+ setLevel(Slider_Level.DEVELOP);
+ clientTest(getWsPackage());
+ }
+
+ @Test
+ public void testInstallClient() {
+ setLevel(Slider_Level.INSTALL);
+ clientTest(getWsPackage());
+ }
+
+ @Test
+ public void testStartClient() {
+ setLevel(Slider_Level.START);
+ clientTest(getWsPackage());
+ }
+
+ @Test
+ public void testTestClient() {
+ setLevel(Slider_Level.TEST);
+ clientTest(getWsPackage());
+ }
+
+ @Test
+ public void testDefaultPkg() {
+ setLevel(Slider_Level.ASSEMBLE);
+ clientTest(null);
+ }
+
+ private void clientTest(String targetPkg) {
+ clientHelper.createClient("http://footballpool.dataaccess.eu/data/info.wso?WSDL",
getWsProjectName(), getLevel(), targetPkg);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(getWsProjectName());
+ String pkg = (targetPkg != null && !"".equals(targetPkg.trim())) ?
getWsPackage() : "eu.dataaccess.footballpool";
+ String cls = "src/" + pkg.replace('.', '/') +
"/Info.java";
+ Assert.assertTrue(p.getFile(cls).exists());
+ cls = "src/" + pkg.replace('.', '/') +
"/clientsample/ClientSample.java";
+ Assert.assertTrue(p.getFile(cls).exists());
+ }
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wstester/WsTesterTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wstester/WsTesterTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/wstester/WsTesterTest.java 2011-12-16
11:34:14 UTC (rev 37393)
@@ -0,0 +1,397 @@
+/*******************************************************************************
+ * 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.wstester;
+
+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 org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
+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.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests for Web Service Tester
+ *
+ * @author jlukas
+ */
+public class WsTesterTest extends WSTestBase {
+
+ private static final String SERVICE_URL =
"http://www.webservicex.net/BibleWebservice.asmx";
+
+ @Override
+ public void setup() {
+ // do nothing
+ }
+
+ @Override
+ public void cleanup() {
+ // do nothing
+ }
+
+ @AfterClass
+ public static void cleanAll() {
+ // do nothing
+ }
+
+ /**
+ * 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();
+ LOGGER.log(Level.FINE, "Services: {0}", items);
+ Assert.assertEquals(2, items.size());
+ Assert.assertTrue(items.contains("EchoService"));
+ items = dlg.getPorts();
+ LOGGER.log(Level.FINE, "Ports: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("EchoPort"));
+ items = dlg.getOperations();
+ LOGGER.log(Level.FINE, "Operations: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("echo"));
+ dlg.ok();
+ LOGGER.log(Level.INFO, "Request: {0}", wstv.getRequestBody());
+ Assert.assertTrue(wstv.getRequestBody().contains(
+ "<tns:echo
xmlns:tns=\"http://test.jboss.org/ns\">"));
+
+ dlg = wstv.getFromWSDL();
+ dlg.setURI(uri);
+ bot.sleep(1000);
+ items = dlg.getServices();
+ LOGGER.log(Level.FINE, "Services: {0}", items);
+ Assert.assertEquals(2, items.size());
+ Assert.assertTrue(items.contains("gsearch_rss"));
+ dlg.selectService("gsearch_rss");
+ items = dlg.getPorts();
+ LOGGER.log(Level.FINE, "Ports: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("gsearch_rssSoap"));
+ items = dlg.getOperations();
+ LOGGER.log(Level.FINE, "Operations: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("GetSearchResults"));
+ dlg.ok();
+ LOGGER.log(Level.INFO, "Request: {0}", wstv.getRequestBody());
+ Assert.assertTrue(wstv.getRequestBody().contains(
+ "<tns:GetSearchResults
xmlns:tns=\"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();
+ bot.sleep(5000);
+ String rsp = wstv.getResponseBody();
+ LOGGER.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();
+ LOGGER.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();
+ LOGGER.log(Level.FINE, "REST response: {0}", rsp);
+ LOGGER.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();
+ LOGGER.log(Level.FINE, "REST response: {0}", rsp);
+ LOGGER.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();
+ LOGGER.log(Level.FINE, "REST response: {0}", rsp);
+ LOGGER.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) {
+ LOGGER.log(Level.WARNING, e.getMessage(), e);
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ LOGGER.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")) {
+ LOGGER.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) {
+ LOGGER.log(Level.WARNING, ioe2.getMessage(), ioe2);
+ }
+ }
+ if (out != null) {
+ try {
+ out.close();
+ } catch (IOException ioe2) {
+ LOGGER.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();
+ LOGGER.log(Level.FINE, "Services: {0}", items);
+ Assert.assertEquals(1, items.size());
+ Assert.assertTrue(items.contains("BibleWebservice"));
+ items = dlg.getPorts();
+ LOGGER.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();
+ LOGGER.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();
+ }
+ }
+ }
+}