Author: jjankovi
Date: 2012-01-04 10:23:01 -0500 (Wed, 04 Jan 2012)
New Revision: 37645
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTFulAnnotations.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerSupportTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerValidationTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulServicesExplorerTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java
Removed:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTFulAnnotations.java
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/test/
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/ti/wizard/RESTFullExplorerWizard.java
Log:
RESTfulValidationTest template created + moving tests to proper location
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 2012-01-04
15:00:39 UTC (rev 37644)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/WSAllBotTests.java 2012-01-04
15:23:01 UTC (rev 37645)
@@ -11,8 +11,9 @@
package org.jboss.tools.ws.ui.bot.test;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-import org.jboss.tools.ws.ui.bot.test.rest.explorer.test.RESTfulExplorerSupportTest;
-import org.jboss.tools.ws.ui.bot.test.rest.explorer.test.RESTfulServicesExplorerTest;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulExplorerSupportTest;
+import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulServicesExplorerTest;
+import org.jboss.tools.ws.ui.bot.test.rest.validation.RESTfulValidationTest;
import org.jboss.tools.ws.ui.bot.test.sample.test.SampleRESTWebServiceTest;
import org.jboss.tools.ws.ui.bot.test.sample.test.SampleSoapWebServiceTest;
import org.jboss.tools.ws.ui.bot.test.sample.test.SimpleRESTWebServiceTest;
@@ -52,7 +53,8 @@
SimpleSoapWebServiceTest.class,
SimpleRESTWebServiceTest.class,
RESTfulExplorerSupportTest.class,
- RESTfulServicesExplorerTest.class,
+ RESTfulServicesExplorerTest.class,
+ RESTfulValidationTest.class,
BottomUpWSTest.class,
TopDownWSTest.class,
WsClientTest.class,
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTFulAnnotations.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTFulAnnotations.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTFulAnnotations.java 2012-01-04
15:23:01 UTC (rev 37645)
@@ -0,0 +1,25 @@
+package org.jboss.tools.ws.ui.bot.test.rest;
+
+public enum RESTFulAnnotations {
+
+ CONFIGURE_MENU_LABEL("Configure"),
+ REST_SUPPORT_MENU_LABEL_ADD("Add JAX-RS 1.1 support..."),
+ REST_SUPPORT_MENU_LABEL_REMOVE("Remove JAX-RS 1.1 support..."),
+ REST_EXPLORER_LABEL("JAX-RS REST Web Services"),
+ REST_EXPLORER_LABEL_BUILD("Building RESTful Web Services..."),
+ GET("GET"),
+ POST("POST"),
+ PUT("PUT"),
+ DELETE("DELETE");
+
+ private String label;
+
+ private RESTFulAnnotations(String label) {
+ this.label = label;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java 2012-01-04
15:23:01 UTC (rev 37645)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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;
+
+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 {
+
+ protected final String CONFIGURE_MENU_LABEL = "Configure";
+ protected final String REST_SUPPORT_MENU_LABEL_ADD = "Add JAX-RS 1.1
support...";
+ protected final String REST_SUPPORT_MENU_LABEL_REMOVE = "Remove JAX-RS 1.1
support...";
+ protected final String REST_EXPLORER_LABEL = "JAX-RS REST Web Services";
+ protected final String REST_EXPLORER_LABEL_BUILD = "Building RESTful Web
Services...";
+ 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()));
+ }
+
+}
Deleted:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTFulAnnotations.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTFulAnnotations.java 2012-01-04
15:00:39 UTC (rev 37644)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTFulAnnotations.java 2012-01-04
15:23:01 UTC (rev 37645)
@@ -1,25 +0,0 @@
-package org.jboss.tools.ws.ui.bot.test.rest.explorer;
-
-public enum RESTFulAnnotations {
-
- CONFIGURE_MENU_LABEL("Configure"),
- REST_SUPPORT_MENU_LABEL_ADD("Add JAX-RS 1.1 support..."),
- REST_SUPPORT_MENU_LABEL_REMOVE("Remove JAX-RS 1.1 support..."),
- REST_EXPLORER_LABEL("JAX-RS REST Web Services"),
- REST_EXPLORER_LABEL_BUILD("Building RESTful Web Services..."),
- GET("GET"),
- POST("POST"),
- PUT("PUT"),
- DELETE("DELETE");
-
- private String label;
-
- private RESTFulAnnotations(String label) {
- this.label = label;
- }
-
- public String getLabel() {
- return label;
- }
-
-}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerSupportTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerSupportTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerSupportTest.java 2012-01-04
15:23:01 UTC (rev 37645)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest.explorer;
+
+import org.jboss.tools.ws.ui.bot.test.rest.RESTfulTestBase;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test checks if context menu 'Add RESTful 1.1 Support' works properly
+ * @author jjankovi
+ *
+ */
+public class RESTfulExplorerSupportTest extends RESTfulTestBase {
+
+ protected String getWsProjectName() {
+ return "RestExplorerTest";
+ }
+
+ protected String getWsPackage() {
+ return "org.rest.explorer.validation.test";
+ }
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
+ @Before
+ public void setup() {
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ }
+
+
+ @Test
+ public void testSupportJAX_RS1_1_Explorer() {
+
+ addRestSupport(getWsProjectName());
+ assertTrue(isRestSupportEnabled(getWsProjectName()));
+
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerValidationTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerValidationTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerValidationTest.java 2012-01-04
15:23:01 UTC (rev 37645)
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * 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;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ * @author jjankovi
+ *
+ */
+public class RESTfulExplorerValidationTest extends WSTestBase {
+
+ private static final String CONFIGURE_MENU_LABEL = "Configure";
+ private static final String REST_SUPPORT_MENU_LABEL_ADD = "Add JAX-RS 1.1
support...";
+ private static final String REST_SUPPORT_MENU_LABEL_REMOVE = "Remove JAX-RS 1.1
support...";
+ private static final String REST_EXPLORER_LABEL = "JAX-RS REST Web Services";
+
+ protected String getWsProjectName() {
+ return "RestExplorerTest";
+ }
+
+ protected String getWsPackage() {
+ return "org.rest.explorer.validation.test";
+ }
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
+ @Before
+ public void setup() {
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ }
+
+
+ @Test
+ public void testSupportJAX_RS1_1_Explorer() {
+
+ addRestSupport(getWsProjectName());
+
+ projectExplorer.selectProject(getWsProjectName());
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(getWsProjectName());
+ assertTrue(NodeContextUtil.nodeContextMenu(tree, item, CONFIGURE_MENU_LABEL,
+ REST_SUPPORT_MENU_LABEL_REMOVE).isVisible());
+ assertTrue(projectExplorer.isFilePresent(getWsProjectName(), REST_EXPLORER_LABEL));
+
+ }
+
+ private void addRestSupport(String wsProjectName) {
+ projectExplorer.selectProject(wsProjectName);
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(wsProjectName);
+ item.expand();
+ NodeContextUtil.nodeContextMenu(tree, item, CONFIGURE_MENU_LABEL,
+ REST_SUPPORT_MENU_LABEL_ADD).click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulServicesExplorerTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulServicesExplorerTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulServicesExplorerTest.java 2012-01-04
15:23:01 UTC (rev 37645)
@@ -0,0 +1,287 @@
+/*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest.explorer;
+
+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.RESTFulAnnotations;
+import org.jboss.tools.ws.ui.bot.test.rest.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";
+ }
+
+ protected String getWsPackage() {
+ return "org.rest.explorer.services.test";
+ }
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
+ @Override
+ public void setup() {
+ if (!projectExists(getWsProjectName())) {
+ projectHelper.createProject(getWsProjectName());
+ }
+ if (!isRestSupportEnabled(getWsProjectName())) {
+ addRestSupport(getWsProjectName());
+ }
+ }
+
+ @Override
+ public void cleanup() {
+ if (projectExists(getWsProjectName())) {
+ removeRestSupport(getWsProjectName());
+ }
+ }
+
+ @Test
+ public void testAddingSimpleRESTMethods() {
+
+ 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() {
+
+ 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() {
+ 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() {
+ 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() {
+ 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;
+ }
+
+}
Deleted:
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 2012-01-04
15:00:39 UTC (rev 37644)
+++
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:23:01 UTC (rev 37645)
@@ -1,68 +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.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()));
- }
-
-}
Added:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java
(rev 0)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java 2012-01-04
15:23:01 UTC (rev 37645)
@@ -0,0 +1,55 @@
+ /*******************************************************************************
+ * Copyright (c) 2007-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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.ws.ui.bot.test.rest.validation;
+
+import org.jboss.tools.ws.ui.bot.test.rest.RESTfulTestBase;
+
+/**
+ * Test operates on JAX-RS validation
+ * @author jjankovi
+ *
+ */
+public class RESTfulValidationTest extends RESTfulTestBase {
+
+ protected String getWsProjectName() {
+ return "RestServicesValidation";
+ }
+
+ protected String getWsPackage() {
+ return "org.rest.validation.services.test";
+ }
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
+ public void testCorrectValueValidation() {
+ //not implemented yet
+ }
+
+ public void testBadValueValidation() {
+ //not implemented yet
+ }
+
+ public void testCorrectToBadValueValidation() {
+ //not implemented yet
+ }
+
+ public void testValidatorDisabling() {
+ //not implemented yet
+ }
+
+ public void testValidatorReenabling() {
+ //not implemented yet
+ }
+
+}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/ti/wizard/RESTFullExplorerWizard.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/ti/wizard/RESTFullExplorerWizard.java 2012-01-04
15:00:39 UTC (rev 37644)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/ti/wizard/RESTFullExplorerWizard.java 2012-01-04
15:23:01 UTC (rev 37645)
@@ -13,7 +13,7 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.SWTTestExt;
-import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTFulAnnotations;
+import org.jboss.tools.ws.ui.bot.test.rest.RESTFulAnnotations;
public class RESTFullExplorerWizard extends SWTTestExt {