Author: jjankovi
Date: 2012-01-04 10:00:39 -0500 (Wed, 04 Jan 2012)
New Revision: 37644
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java
Removed:
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/WSWizardTest.java
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/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/rest/explorer/test/RESTfulExplorerSupportTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulServicesExplorerTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java
Log:
RESTFulServicesExplorerTest completion
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 2012-01-04 14:57:09
UTC (rev 37643)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/META-INF/MANIFEST.MF 2012-01-04 15:00:39
UTC (rev 37644)
@@ -19,7 +19,6 @@
org.junit4;bundle-version="4.5.0",
org.jboss.tools.ws.ui;bundle-version="1.1.0",
org.eclipse.core.resources,
- org.jboss.tools.tests,
org.eclipse.wst.common.project.facet.core,
org.hamcrest;bundle-version="1.1.0"
Bundle-ActivationPolicy: lazy
Deleted:
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 2012-01-04
14:57:09 UTC (rev 37643)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/JBossWSProjectFacetBotTest.java 2012-01-04
15:00:39 UTC (rev 37644)
@@ -1,106 +0,0 @@
- /*******************************************************************************
- * 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;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.WebServicesWSDL;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-
-public class JBossWSProjectFacetBotTest extends WSWizardTest {
-
- public void testNewWizard() throws IOException, CoreException {
- bot.menu("File").menu("New").menu("Project...").click();
- bot.shell("New Project").activate();
- SWTBotTree tree = bot.tree();
- tree.expandNode("Web").expandNode("Dynamic Web Project").select();
- assertTrue(bot.button("Next >").isEnabled());
- bot.button("Next >").click();
- bot.shell("New Dynamic Web Project").activate();
- assertFalse(bot.button("Finish").isEnabled());
-
- bot.textWithLabel("Project name:").setText("B");
- assertTrue(bot.button("Finish").isEnabled());
- bot.comboBoxInGroup("Dynamic web module
version").setSelection("2.5");
- bot.comboBoxInGroup("Configuration").setSelection(
- "JBossWS Web Service Project v3.0");
- assertFalse(bot.button("Finish").isEnabled());
- bot.button("Next >").click();
- bot.button("Next >").click();
- bot.button("Next >").click();
- bot.radio(0).click();
- bot.sleep(2000);
- assertTrue(bot.button("Finish").isEnabled());
- open.finish(bot);
- project = ResourcesPlugin.getWorkspace().getRoot().getProject("B");
- assertNotNull(project);
- IFacetedProject fproj = ProjectFacetsManager.create(project);
- assertNotNull(fproj
- .getProjectFacetVersion((IProjectFacet) ProjectFacetsManager
- .getProjectFacet("jbossws.core")));
- tryJBIDE6250();
- }
-
- private void tryJBIDE6250() {
- setDefaultWSRuntime();
-
- SWTBot wiz = open.newObject(WebServicesWSDL.LABEL);
- wiz.textWithLabel(WebServicesWSDL.TEXT_FILE_NAME).setText(
- "ClassB" + ".wsdl");
- wiz.textWithLabel(
- WebServicesWSDL.TEXT_ENTER_OR_SELECT_THE_PARENT_FOLDER)
- .setText("B");
- wiz.button(IDELabel.Button.NEXT).click();
- open.finish(wiz);
- eclipse.setClassContentFromResource(bot.editorByTitle("ClassB"
- + ".wsdl"), true,
- org.jboss.tools.ws.ui.bot.test.Activator.PLUGIN_ID,
- "jbossws", "ClassB" + ".wsdl");
-
- bot.sleep(1000);
- bot.menu("File").menu("New").menu("Other...").click();
- bot.shell("New").activate();
-
- SWTBotTree tree = bot.tree();
- SWTBotTreeItem item = tree.getTreeItem("Web Services");
- tree.select(item);
- item.expand();
- try {
- item.getNode("Web Service").select();
- } catch (Exception e) {
- item.collapse();
- item.expand();
- item.getNode("Web Service").select();
- }
- bot.sleep(1000);
- assertTrue(bot.button("Next >").isEnabled());
- bot.button("Next >").click();
- bot.shell("Web Service").activate();
- bot.comboBoxWithLabel("Web service type:").setSelection(1);
- bot.comboBoxWithLabel("Service definition:").setText(
- "/B/ClassB.wsdl");
- while (!bot.button("Next >").isEnabled()) {
- bot.sleep(1000);
- }
- selectProject();
- bot.button("Next >").click();
- bot.sleep(1000);
- assertTrue(bot.checkBox(0).isChecked());
- }
-}
Modified:
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 2012-01-04
14:57:09 UTC (rev 37643)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSTestBase.java 2012-01-04
15:00:39 UTC (rev 37644)
@@ -49,6 +49,8 @@
protected static final Logger LOGGER = Logger
.getLogger(WSTestBase.class.getName());
+ protected final String LINE_SEPARATOR = System.getProperty("line.separator");
+
protected static final ResourceHelper resourceHelper = new ResourceHelper();
protected static final ProjectHelper projectHelper = new ProjectHelper();
protected static final DeploymentHelper deploymentHelper = new DeploymentHelper();
Deleted:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSWizardTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSWizardTest.java 2012-01-04
14:57:09 UTC (rev 37643)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSWizardTest.java 2012-01-04
15:00:39 UTC (rev 37644)
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * 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.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.jboss.tools.test.util.TestProjectProvider;
-import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
-import org.jboss.tools.ui.bot.ext.SWTOpenExt;
-import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ui.bot.ext.parts.SWTBotHyperlinkExt;
-
-public class WSWizardTest extends TestCase{
- protected static SWTBotExt bot = new SWTBotExt();
- public static final SWTOpenExt open = new SWTOpenExt(bot);
- public static final SWTEclipseExt eclipse = new SWTEclipseExt(bot);
- public static final String JBOSSWS_HOME_DEFAULT =
"D:/softinstall/jboss-5.1.0.GA";
- public static final String JBOSSWS_42_HOME =
"jbosstools.test.jboss.home.5.1";
- public static final String JBOSS_AS_42_HOME = System.getProperty(
- JBOSSWS_42_HOME, JBOSSWS_HOME_DEFAULT);
- IProject project;
-
- protected void setUp() throws Exception {
- bot.viewByTitle("Welcome").close();
- bot.perspectiveByLabel("Java EE").activate();
- createServerRuntime();
- }
- protected void tearDown() throws Exception {
- bot = null;
- }
-
- public void createServerRuntime() {
- if (!isServerRuntimeDefined(bot, "AS4.2Runtime")) {
- bot.menu("File").menu("New").menu("Other...").click();
- bot.shell("New").activate();
- SWTBotTree tree = bot.tree();
- bot.sleep(Timing.time1S());
- tree.expandNode("Server").select("Server");
- bot.button("Next >").click();
- SWTBotTree tree2 = bot.tree();
- tree2.expandNode("JBoss Community").select("JBoss AS 5.1");
- bot.textWithLabel("Server name:").setText("AS4.2Server");
- bot.button("Next >").click();
- bot.textWithLabel("Name").setText("AS4.2Runtime");
- bot.textWithLabel("Home Directory").setText(JBOSS_AS_42_HOME);
- bot.button("Finish").click();
- bot.sleep(Timing.time2S());
- }
- }
-
- public static boolean isServerRuntimeDefined(SWTWorkbenchBot bot,
- String runtimeName) {
-
- boolean serverRuntimeNotDefined = true;
-
- bot.menu("Window").menu("Preferences").click();
- bot.shell("Preferences").activate();
- bot.tree().expandNode("Server").select("Runtime Environments");
-
- SWTBotTable tbRuntimeEnvironments = bot.table();
- int numRows = tbRuntimeEnvironments.rowCount();
- if (numRows > 0) {
- int currentRow = 0;
- while (serverRuntimeNotDefined && currentRow < numRows) {
- if (tbRuntimeEnvironments.cell(currentRow, 0).equalsIgnoreCase(
- runtimeName)) {
- serverRuntimeNotDefined = false;
- } else {
- currentRow++;
- }
- }
- }
-
- bot.button("OK").click();
-
- return !serverRuntimeNotDefined;
-
- }
-
-
- public IProject importProject() throws CoreException, IOException,
InvocationTargetException, InterruptedException {
- TestProjectProvider provider = new
TestProjectProvider("org.jboss.tools.ws.ui.bot.test", "/projects/" +
"A",
- "A", true);
- IProject prj = provider.getProject();
- return prj;
- }
-
- public void selectProject() {
- SWTBotHyperlinkExt link = bot.hyperlink(2);
- if(!"Service project: B".equals(link.getText())){
- link.click();
-
- SWTBot dBot = bot.activeShell().bot();
- dBot.comboBoxWithLabel("Service project:").setText("B");
- dBot.button("OK").click();
- dBot.sleep(Timing.time1S());
- }
- }
- public void setDefaultWSRuntime(){
- bot.menu("Window").menu("Preferences").click();
- bot.shell("Preferences").activate();
- SWTBotTree tree = bot.tree();
- tree.expandNode("Web Services").expandNode("Server and
Runtime").select();
- bot.comboBoxWithLabel("Web service
runtime:").setSelection("JBossWS");
- bot.button("OK").click();
- bot.sleep(Timing.time2S());
- }
-}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulTestBase.java 2012-01-04
15:00:39 UTC (rev 37644)
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.rest.explorer;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ws.ui.bot.test.WSTestBase;
+import org.jboss.tools.ws.ui.bot.test.utils.NodeContextUtil;
+
+/**
+ * Test base for bot tests using RESTFul support
+ * @author jjankovi
+ *
+ */
+public class RESTfulTestBase extends WSTestBase {
+
+ private enum ConfigureOption {
+ ADD, REMOVE;
+ }
+
+ /**
+ *
+ * @param wsProjectName
+ */
+ protected void addRestSupport(String wsProjectName) {
+ configureRestSupport(wsProjectName, ConfigureOption.ADD);
+ }
+
+ protected void removeRestSupport(String wsProjectName) {
+ configureRestSupport(wsProjectName, ConfigureOption.REMOVE);
+ }
+
+ private void configureRestSupport(String wsProjectName, ConfigureOption option) {
+ projectExplorer.selectProject(wsProjectName);
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(wsProjectName);
+ item.expand();
+ NodeContextUtil.nodeContextMenu(tree, item,
RESTFulAnnotations.CONFIGURE_MENU_LABEL.getLabel(),
+ option==ConfigureOption.ADD?
+ RESTFulAnnotations.REST_SUPPORT_MENU_LABEL_ADD.getLabel():
+ RESTFulAnnotations.REST_SUPPORT_MENU_LABEL_REMOVE.getLabel()).click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+ /**
+ *
+ * @param wsProjectName
+ * @return
+ */
+ protected boolean isRestSupportEnabled(String wsProjectName) {
+ return (projectExplorer.isFilePresent(wsProjectName,
+ RESTFulAnnotations.REST_EXPLORER_LABEL.getLabel()) ||
+ projectExplorer.isFilePresent(wsProjectName,
+ RESTFulAnnotations.REST_EXPLORER_LABEL_BUILD.getLabel()));
+ }
+
+}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerSupportTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerSupportTest.java 2012-01-04
14:57:09 UTC (rev 37643)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulExplorerSupportTest.java 2012-01-04
15:00:39 UTC (rev 37644)
@@ -11,6 +11,7 @@
package org.jboss.tools.ws.ui.bot.test.rest.explorer.test;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulTestBase;
import org.junit.Before;
import org.junit.Test;
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulServicesExplorerTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulServicesExplorerTest.java 2012-01-04
14:57:09 UTC (rev 37643)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/test/RESTfulServicesExplorerTest.java 2012-01-04
15:00:39 UTC (rev 37644)
@@ -11,17 +11,24 @@
package org.jboss.tools.ws.ui.bot.test.rest.explorer.test;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTFulAnnotations;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulTestBase;
+import org.jboss.tools.ws.ui.bot.test.ti.wizard.RESTFullExplorerWizard;
import org.junit.Test;
-
-
/**
* Test operates on exploring RESTFul services in RESTful explorer
+ *
+ * TO DO: I have to add rest libraries for EAP 5.1
* @author jjankovi
*
*/
public class RESTfulServicesExplorerTest extends RESTfulTestBase {
+ private RESTFullExplorerWizard restfulWizard = null;
+
protected String getWsProjectName() {
return "RestServicesExplorer";
}
@@ -37,42 +44,244 @@
@Override
public void setup() {
if (!projectExists(getWsProjectName())) {
- projectHelper.createProject(getWsProjectName());
+ projectHelper.createProject(getWsProjectName());
+ }
+ if (!isRestSupportEnabled(getWsProjectName())) {
addRestSupport(getWsProjectName());
}
}
@Override
public void cleanup() {
- if (projectExists(getWsProjectName())) {
- removeRestSupport(getWsProjectName());
- projectExplorer.deleteAllProjects();
+ if (projectExists(getWsProjectName())) {
+ removeRestSupport(getWsProjectName());
}
}
@Test
public void testAddingSimpleRESTMethods() {
- //only get, post, put, delete
+
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources",
"src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/BasicRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 4);
+ assertTrue(areAllRestServicesPresent(restServices));
+
+ for (SWTBotTreeItem restService : restServices) {
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("*/*"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
}
@Test
public void testAddingAdvancedRESTMethods() {
- //with additional path param
+
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources",
"src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+
getResourceAsStream("/resources/restful/AdvancedRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 4);
+ assertTrue(areAllRestServicesPresent(restServices));
+
+ for (SWTBotTreeItem restService : restServices) {
+ if
(restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.GET.getLabel()))
{
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("*/*"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("text/plain"));
+ }
+ if
(restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.PUT.getLabel()))
{
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/put/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("text/plain"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ if
(restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.POST.getLabel()))
{
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/post/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("text/plain"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("text/plain"));
+ }
+ if
(restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel()))
{
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/delete/{id}"));
+ assertTrue(restfulWizard.getConsumesInfo(restService).equals("*/*"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ }
+
}
@Test
public void testEditingSimpleRESTMethods() {
- //only get, post, put, delete
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources",
"src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/BasicRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(areAllRestServicesPresent(restServices));
+
+ resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "@DELETE",
"@GET");
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ restServices = restfulWizard.getAllRestServices();
+
+ assertFalse(areAllRestServicesPresent(restServices));
+
+ for (SWTBotTreeItem restService : restServices) {
+ if
(restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel()))
{
+ fail("There should not be DELETE RESTful services");
+ }
+ }
+
}
@Test
public void testEditingAdvancedRESTMethods() {
- ////with additional path param
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources",
"src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/AdvancedRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ for (SWTBotTreeItem restService : restServices) {
+ if
(restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel()))
{
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/delete/{id}"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("*/*"));
+ }
+ }
+
+ resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(),
"/delete/{id}", "delete/edited/{id}");
+ resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "@DELETE",
+ "@DELETE" + LINE_SEPARATOR +
"@Produces(\"text/plain\")");
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ restServices = restfulWizard.getAllRestServices();
+
+ for (SWTBotTreeItem restService : restServices) {
+ if
(restfulWizard.getRestServiceName(restService).equals(RESTFulAnnotations.DELETE.getLabel()))
{
+ assertTrue(restfulWizard.getPathForRestFulService(restService).equals("/rest/delete/edited/{id}"));
+ assertTrue(restfulWizard.getProducesInfo(restService).equals("text/plain"));
+ }
+ }
}
@Test
public void testDeletingRESTMethods() {
- //deleting all rest methods
+ if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources",
"src", getWsPackage(), getWsName() + ".java")) {
+ projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
+ }
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/BasicRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 4);
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulServicesExplorerTest.class.
+ getResourceAsStream("/resources/restful/EmptyRestfulWS.java.ws"),
+ false, getWsPackage(), getWsName());
+
+ /**
+ * workaround
+ */
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
+ restServices = restfulWizard.getAllRestServices();
+
+ assertTrue(restServices.length == 0);
+
}
+ private boolean areAllRestServicesPresent(SWTBotTreeItem[] restServices) {
+
+ String[] restMethods = {RESTFulAnnotations.GET.getLabel(),
RESTFulAnnotations.POST.getLabel(),
+ RESTFulAnnotations.POST.getLabel(), RESTFulAnnotations.DELETE.getLabel()};
+ for (String restMethod : restMethods) {
+ boolean serviceFound = false;
+ for (SWTBotTreeItem restService : restServices) {
+ if (restfulWizard.getRestServiceName(restService).equals(restMethod)) {
+ serviceFound = true;
+ break;
+ }
+ }
+ if (!serviceFound) return false;
+ }
+ return true;
+ }
+
}
Modified:
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 2012-01-04
14:57:09 UTC (rev 37643)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/utils/ResourceHelper.java 2012-01-04
15:00:39 UTC (rev 37644)
@@ -13,6 +13,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.text.MessageFormat;
import java.util.Scanner;
import org.eclipse.core.resources.IFile;
@@ -60,6 +61,18 @@
}
/**
+ * Method replaces string "target" by string "replacement.
+ * @param target
+ * @param replacement
+ */
+ public void replaceInEditor(SWTBotEclipseEditor ed, String target, String replacement)
{
+ ed.selectRange(0, 0, ed.getText().length());
+ ed.setText(ed.getText().replace(target,replacement));
+ ed.save();
+ }
+
+
+ /**
* Method copies resource to class opened in SWTBotEditor
* @param classEdit
* @param resource
@@ -75,5 +88,21 @@
if (closeEdit) classEdit.close();
}
+ /**
+ * Method copies resource to class opened in SWTBotEditor with entered parameters
+ * @param classEdit
+ * @param resource
+ * @param closeEdit
+ * @param param
+ */
+ public void copyResourceToClass(SWTBotEditor classEdit,
+ InputStream resource, boolean closeEdit, Object... param) {
+ String s = readStream(resource);
+ String code = MessageFormat.format(s, param);
+ classEdit.toTextEditor().selectRange(0, 0,
classEdit.toTextEditor().getText().length());
+ classEdit.toTextEditor().setText(code);
+ classEdit.save();
+ if (closeEdit) classEdit.close();
+ }
}