[jbosstools-commits] JBoss Tools SVN: r42105 - in trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test: integration and 1 other directory.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Jun 20 09:46:27 EDT 2012
Author: jjankovi
Date: 2012-06-20 09:46:27 -0400 (Wed, 20 Jun 2012)
New Revision: 42105
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/integration/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/integration/JAXRSToolingIntegrationTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/integration/SOAPWSToolingIntegrationTest.java
Log:
new tooling integration test for SOAP ws tested in WSTester
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/integration/JAXRSToolingIntegrationTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/integration/JAXRSToolingIntegrationTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/integration/JAXRSToolingIntegrationTest.java 2012-06-20 13:46:27 UTC (rev 42105)
@@ -0,0 +1,156 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2012 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.integration;
+
+import org.jboss.tools.ui.bot.ext.config.Annotations.Require;
+import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
+import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.jboss.tools.ws.ui.bot.test.rest.RESTfulTestBase;
+import org.jboss.tools.ws.ui.bot.test.uiutils.RESTFullExplorer;
+import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView;
+import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView.Request_Type;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+ at Require(server = @Server(state = ServerState.Running), perspective = "Java EE")
+public class JAXRSToolingIntegrationTest extends RESTfulTestBase {
+
+ private static String projectName = "integration1";
+ private String localhostUrl = "http://localhost:8080/";
+ private String serviceUrl = localhostUrl + projectName + "/rest/";
+
+ @BeforeClass
+ public static void prepareWS() {
+ importRestWSProject(projectName);
+ }
+
+ @Test
+ public void testGetMethod() {
+ /* get JAX-RS REST Web Services */
+ restfulWizard = new RESTFullExplorer(projectName);
+
+ /* run on server - web service tester should be shown */
+ runRestServiceOnConfiguredServer("GET");
+ assertWebServiceTesterIsActive();
+
+ /* test generated url and response after invoking */
+ WsTesterView wsTesterView = showWSTester();
+ assertEquals(serviceUrl + "get", wsTesterView.getServiceURL());
+
+ invokeMethodInWSTester(wsTesterView, Request_Type.GET);
+ assertEquals("GET method", wsTesterView.getResponseBody());
+ assertEquals("[HTTP/1.1 200 OK]", wsTesterView.getResponseHeaders()[0]);
+
+ /* minimize web service tester */
+ wsTesterView.minimize();
+ }
+
+ @Test
+ public void testPostMethod() {
+ /* get JAX-RS REST Web Services */
+ restfulWizard = new RESTFullExplorer(projectName);
+
+ /* run on server - web service tester should be shown */
+ runRestServiceOnConfiguredServer("POST");
+ assertWebServiceTesterIsActive();
+
+ /* test generated url and response after invoking */
+ WsTesterView wsTesterView = showWSTester();
+ assertEquals(serviceUrl + "post", wsTesterView.getServiceURL());
+
+ invokeMethodInWSTester(wsTesterView, Request_Type.POST);
+ assertEquals("POST method", wsTesterView.getResponseBody());
+ assertEquals("[HTTP/1.1 200 OK]", wsTesterView.getResponseHeaders()[0]);
+
+ /* minimize web service tester */
+ wsTesterView.minimize();
+ }
+
+ @Test
+ public void testPutMethod() {
+ /* get JAX-RS REST Web Services */
+ restfulWizard = new RESTFullExplorer(projectName);
+
+ /* run on server - web service tester should be shown */
+ runRestServiceOnConfiguredServer("PUT");
+ assertWebServiceTesterIsActive();
+
+ /* test generated url and response after invoking */
+ WsTesterView wsTesterView = showWSTester();
+ assertEquals(serviceUrl + "put", wsTesterView.getServiceURL());
+
+ invokeMethodInWSTester(wsTesterView, Request_Type.PUT);
+ assertEquals("PUT method", wsTesterView.getResponseBody());
+ assertEquals("[HTTP/1.1 200 OK]", wsTesterView.getResponseHeaders()[0]);
+
+ /* minimize web service tester */
+ wsTesterView.minimize();
+ }
+
+ @Test
+ public void testDeleteMethod() {
+ /* get JAX-RS REST Web Services */
+ restfulWizard = new RESTFullExplorer(projectName);
+
+ /* run on server - web service tester should be shown */
+ runRestServiceOnConfiguredServer("DELETE");
+ assertWebServiceTesterIsActive();
+
+ /* test generated url and response after invoking */
+ WsTesterView wsTesterView = showWSTester();
+ assertEquals(serviceUrl + "get", wsTesterView.getServiceURL());
+
+ invokeMethodInWSTester(wsTesterView, Request_Type.DELETE);
+ assertEquals("DELETE method", wsTesterView.getResponseBody());
+ assertEquals("[HTTP/1.1 200 OK]", wsTesterView.getResponseHeaders()[0]);
+
+ /* minimize web service tester */
+ wsTesterView.minimize();
+ }
+
+ @Test
+ public void testUnavailableServiceMethod() {
+ /* get JAX-RS REST Web Services */
+ restfulWizard = new RESTFullExplorer(projectName);
+
+ /* run on server - web service tester should be shown */
+ runRestServiceOnConfiguredServer("GET");
+ assertWebServiceTesterIsActive();
+
+ /* test generated url and response after invoking */
+ WsTesterView wsTesterView = showWSTester();
+ assertEquals(serviceUrl + "get", wsTesterView.getServiceURL());
+
+ invokeMethodInWSTester(wsTesterView, Request_Type.POST);
+ assertFalse(wsTesterView.getResponseBody().equals("GET method"));
+ assertEquals("[HTTP/1.1 405 Method Not Allowed]", wsTesterView.getResponseHeaders()[0]);
+
+ /* minimize web service tester */
+ wsTesterView.minimize();
+ }
+
+ private WsTesterView showWSTester() {
+ WsTesterView wsTesterView = new WsTesterView();
+ wsTesterView.show();
+ return wsTesterView;
+ }
+
+ private void invokeMethodInWSTester(WsTesterView wsTesterView, Request_Type type) {
+ wsTesterView.setRequestType(type);
+ wsTesterView.invoke();
+ }
+
+}
Added: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/integration/SOAPWSToolingIntegrationTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/integration/SOAPWSToolingIntegrationTest.java (rev 0)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/integration/SOAPWSToolingIntegrationTest.java 2012-06-20 13:46:27 UTC (rev 42105)
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2012 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.integration;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
+import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView;
+import org.jboss.tools.ws.ui.bot.test.widgets.WsTesterView.Request_Type;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class SOAPWSToolingIntegrationTest extends WSTestBase {
+
+ private final static String projectName = "integration2";
+ private final String[] pathToRestExplorer = {projectName, "wsdl"};
+ private final String request =
+ "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?> " + LINE_SEPARATOR +
+ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"> " + LINE_SEPARATOR +
+ "<soap:Header> " + LINE_SEPARATOR +
+ "</soap:Header>" + LINE_SEPARATOR +
+ "<soap:Body> " + LINE_SEPARATOR +
+ "<webs:sayHello xmlns:webs=\"http://webservices.samples.jboss.org/\">" + LINE_SEPARATOR +
+ "<arg0>User</arg0>" + LINE_SEPARATOR +
+ "</webs:sayHello>" + LINE_SEPARATOR +
+ "</soap:Body>" + LINE_SEPARATOR +
+ "</soap:Envelope>";
+
+ @BeforeClass
+ public static void prepareWS() {
+ importWSTestProject(projectName);
+ deploymentHelper.runProject(projectName);
+ }
+
+ @Override
+ public void setup() {
+
+ }
+
+ @Override
+ public void cleanup() {
+
+ }
+
+ @Test
+ public void testSimpleIntegration() {
+
+ WsTesterView wsTesterView = openWSDLFileInWSTester();
+ testWSDLInWSTester(wsTesterView);
+
+ }
+
+ private SWTBotTreeItem getWSDLTreeItem() {
+ return projectExplorer.selectTreeItem("HelloWorldService.wsdl",
+ pathToRestExplorer).expand();
+ }
+
+ private SWTBotTree getProjectExplorerTree() {
+ return projectExplorer.bot().tree();
+ }
+
+ private WsTesterView openWSDLFileInWSTester() {
+ SWTBotTree tree = getProjectExplorerTree();
+ ContextMenuHelper.prepareTreeItemForContextMenu(
+ tree, getWSDLTreeItem());
+ SWTBotMenu menu = new SWTBotMenu(ContextMenuHelper.
+ getContextMenu(tree, "Web Services", false));
+ menu.menu("Test in JBoss Web Service Tester").click();
+ WsTesterView tester = new WsTesterView();
+ tester.show();
+ return tester;
+ }
+
+ private void testWSDLInWSTester(WsTesterView wsTesterView) {
+ wsTesterView.setRequestType(Request_Type.JAX_WS);
+ wsTesterView.getFromWSDL().ok();
+ wsTesterView.setRequestBody(request);
+ wsTesterView.invoke();
+ bot.sleep(5000);
+ String rsp = wsTesterView.getResponseBody();
+ assertTrue(rsp.trim().length() > 0);
+ assertTrue(rsp, rsp.contains("Hello User!"));
+ }
+
+}
More information about the jbosstools-commits
mailing list