Author: jjankovi
Date: 2012-01-25 06:06:59 -0500 (Wed, 25 Jan 2012)
New Revision: 38163
Removed:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulValidationTest.java
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java
Log:
Completion of RESTFulValidationTest + moving it to different folder
Deleted:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulValidationTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulValidationTest.java 2012-01-25
11:05:15 UTC (rev 38162)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulValidationTest.java 2012-01-25
11:06:59 UTC (rev 38163)
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * 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 RESTfulValidationTest 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();
- }
-
-}
Modified:
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 2012-01-25
11:05:15 UTC (rev 38162)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java 2012-01-25
11:06:59 UTC (rev 38163)
@@ -13,7 +13,7 @@
import org.jboss.tools.ws.ui.bot.test.rest.RESTfulTestBase;
import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulExplorerTest;
-import org.junit.Ignore;
+import org.junit.Test;
/**
* Test operates on JAX-RS validation
@@ -22,6 +22,10 @@
*/
public class RESTfulValidationTest extends RESTfulTestBase {
+ private final String GET_METHOD_PATH = "/{id}";
+ private final String CORRECT_PATH_PARAM = "id";
+ private final String BAD_PATH_PARAM = "customerId";
+
protected String getWsProjectName() {
return "RestServicesValidation";
}
@@ -37,49 +41,86 @@
@Override
public void setup() {
if (!projectExists(getWsProjectName())) {
- projectHelper.createProject(getWsProjectName());
+ projectHelper.createProject(getWsProjectName());
+ addRestSupport(getWsProjectName());
}
if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources",
"src", getWsPackage(), getWsName() + ".java")) {
projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
}
}
- @Ignore
+
+ @Test
public void testCorrectValueValidation() {
resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
RESTfulExplorerTest.class.
getResourceAsStream("/resources/restful/CorrectRestWS.java.ws"),
- false, getWsPackage(), getWsName());
+ false, getWsPackage(), getWsName(), GET_METHOD_PATH, CORRECT_PATH_PARAM);
- assertTrue(getRESTValidationErrorsAfterCleanBuild(getWsProjectName()).length == 0);
-
+ assertTrue(getRESTValidationErrors(getWsProjectName()).length == 0);
}
- @Ignore
+
+ @Test
public void testBadValueValidation() {
resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
RESTfulExplorerTest.class.
getResourceAsStream("/resources/restful/BadRestWS.java.ws"),
- false, getWsPackage(), getWsName());
+ false, getWsPackage(), getWsName(), GET_METHOD_PATH, BAD_PATH_PARAM);
- assertTrue("" +
getRESTValidationErrorsAfterCleanBuild(getWsProjectName()).length,
- getRESTValidationErrorsAfterCleanBuild(getWsProjectName()).length == 1);
+ assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
+ getRESTValidationErrors(getWsProjectName()).length == 1);
}
- @Ignore
+
+ @Test
public void testCorrectToBadValueValidation() {
- //not implemented yet
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulExplorerTest.class.
+ getResourceAsStream("/resources/restful/CorrectRestWS.java.ws"),
+ false, getWsPackage(), getWsName(), GET_METHOD_PATH, CORRECT_PATH_PARAM);
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulExplorerTest.class.
+ getResourceAsStream("/resources/restful/BadRestWS.java.ws"),
+ false, getWsPackage(), getWsName(), GET_METHOD_PATH, BAD_PATH_PARAM);
+
+ assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
+ getRESTValidationErrors(getWsProjectName()).length == 1);
}
- @Ignore
+
+ @Test
public void testBadToCorrectValueValidation() {
- //not implemented yet
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulExplorerTest.class.
+ getResourceAsStream("/resources/restful/BadRestWS.java.ws"),
+ false, getWsPackage(), getWsName(), GET_METHOD_PATH, BAD_PATH_PARAM);
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulExplorerTest.class.
+ getResourceAsStream("/resources/restful/CorrectRestWS.java.ws"),
+ false, getWsPackage(), getWsName(), GET_METHOD_PATH, CORRECT_PATH_PARAM);
+
+ assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
+ getRESTValidationErrors(getWsProjectName()).length == 0);
}
- @Ignore
- public void testValidatorDisabling() {
- //not implemented yet
+
+ @Test
+ public void testJAX_RS_Validator() {
+
+ disableRESTValidation();
+
+ resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
+ RESTfulExplorerTest.class.
+ getResourceAsStream("/resources/restful/BadRestWS.java.ws"),
+ false, getWsPackage(), getWsName(), GET_METHOD_PATH, BAD_PATH_PARAM);
+
+ assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
+ getRESTValidationErrors(getWsProjectName()).length == 0);
+
+ enableRESTValidation();
+
+ assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
+ getRESTValidationErrors(getWsProjectName()).length == 1);
}
- @Ignore
- public void testValidatorReenabling() {
- //not implemented yet
- }
}