Author: jjankovi
Date: 2012-04-17 09:45:41 -0400 (Tue, 17 Apr 2012)
New Revision: 40244
Modified:
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/completion/RESTfulCompletionTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulSupportTest.java
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/ti/wizard/RESTFullExplorerWizard.java
Log:
huge refactoring of rest bot tests
Modified:
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 2012-04-17
13:44:25 UTC (rev 40243)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java 2012-04-17
13:45:41 UTC (rev 40244)
@@ -11,23 +11,10 @@
package org.jboss.tools.ws.ui.bot.test.rest;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-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.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.jboss.tools.ui.bot.ext.Timing;
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.TestConfigurator;
-import org.jboss.tools.ui.bot.ext.gen.IPreference;
-import org.jboss.tools.ui.bot.ext.helper.BuildPathHelper;
-import org.jboss.tools.ui.bot.ext.view.ProblemsView;
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
@@ -38,16 +25,13 @@
@Require(server = @Server(), perspective = "Java EE")
public class RESTfulTestBase extends WSTestBase {
- protected final String PATH_PARAM_VALID_ERROR = "Invalid @PathParam value";
- protected final String VALIDATION_PREFERENCE = "Validation";
- protected final String ENABLE_ALL = "Enable All";
- protected final String JAX_RS_VALIDATOR = "JAX-RS Metamodel Validator";
+ protected final RESTfulHelper restfulHelper = new RESTfulHelper();
+
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...";
- protected final String VALIDATION_SETTINGS_CHANGED = "Validation Settings
Changed";
protected final String BASIC_WS_RESOURCE =
"/resources/restful/BasicRestfulWS.java.ws";
@@ -57,164 +41,42 @@
protected final String SIMPLE_REST_WS_RESOURCE =
"/resources/restful/SimpleRestWS.java.ws";
- private enum ConfigureOption {
- ADD, REMOVE;
+ protected String getWsPackage() {
+ return "org.rest.test";
}
-
+
+ protected String getWsName() {
+ return "RestService";
+ }
+
@Override
public void setup() {
+ prepareRestProject();
+ }
+
+ protected void prepareRestProject() {
+
if (!projectExists(getWsProjectName())) {
- projectHelper.createProject(getWsProjectName());
- if (!isRestSupportEnabled(getWsProjectName())) {
+
+ //importing project without targeted runtime set
+ importWSTestProject("/resources/projects/" +
+ getWsProjectName(), getWsProjectName());
+ //set target runtime - TO DO
+ projectHelper.addDefaultRuntimeIntoProject(getWsProjectName());
+
+ projectExplorer.selectProject(getWsProjectName());
+ eclipse.cleanAllProjects();
+ bot.sleep(Timing.time3S());
+
+ if (!restfulHelper.isRestSupportEnabled(getWsProjectName())) {
// workaround for EAP 5.1
if (configuredState.getServer().type.equals("EAP") &&
configuredState.getServer().version.equals("5.1")) {
- addRestEasyLibs(getWsProjectName());
+ restfulHelper.addRestEasyLibs(getWsProjectName());
}
- addRestSupport(getWsProjectName());
+ restfulHelper.addRestSupport(getWsProjectName());
}
}
-
- if (!projectExplorer.isFilePresent(getWsProjectName(), "Java Resources",
- "src", getWsPackage(), getWsName() + ".java")) {
- projectHelper.createClass(getWsProjectName(), getWsPackage(), getWsName());
- }
}
- protected SWTBotTreeItem[] getRESTValidationErrors(String wsProjectName) {
- return ProblemsView.getFilteredErrorsTreeItems(bot,
- PATH_PARAM_VALID_ERROR, "/" + wsProjectName, null, null);
- }
-
- protected void enableRESTValidation() {
- modifyRESTValidation(ConfigureOption.ADD);
- }
-
- protected void disableRESTValidation() {
- modifyRESTValidation(ConfigureOption.REMOVE);
- }
-
- /**
- * DO IT BETTER!!!!!!!!!!!!!!!!!!
- */
- protected void modifyRESTValidation(ConfigureOption option) {
-
- SWTBot validationBot = openPreferencePage(VALIDATION_PREFERENCE,
- new ArrayList<String>());
-
- validationBot.button(ENABLE_ALL).click();
-
- if (option == ConfigureOption.REMOVE) {
-
- SWTBotTable validatorTable = validationBot.table();
- int restValidationRow = -1;
- for (int row = 0; row < validatorTable.rowCount(); row++) {
- if (validatorTable.getTableItem(row).getText()
- .equals(JAX_RS_VALIDATOR)) {
- restValidationRow = row;
- break;
- }
- }
-
- assertTrue(restValidationRow >= 0);
-
- validatorTable.click(restValidationRow, 1);
- validatorTable.click(restValidationRow, 2);
- }
-
- validationBot.button("OK").click();
- if (bot.activeShell().getText().equals(VALIDATION_SETTINGS_CHANGED)) {
- bot.activeShell().bot().button("Yes").click();
- }
-
- bot.sleep(Timing.time3S());
- util.waitForNonIgnoredJobs();
-
- }
-
- protected void addRestSupport(String wsProjectName) {
- configureRestSupport(wsProjectName, ConfigureOption.ADD);
- }
-
- protected void removeRestSupport(String wsProjectName) {
- configureRestSupport(wsProjectName, ConfigureOption.REMOVE);
- }
-
- protected boolean isRestSupportEnabled(String wsProjectName) {
- return (projectExplorer.isFilePresent(wsProjectName,
- RESTFulAnnotations.REST_EXPLORER_LABEL.getLabel()) || projectExplorer
- .isFilePresent(wsProjectName,
- RESTFulAnnotations.REST_EXPLORER_LABEL_BUILD.getLabel()));
- }
-
-
- @SuppressWarnings("static-access")
- private List<String> addRestEasyLibs(String wsProjectName) {
-
- List<File> restLibsPaths = getPathForRestLibs();
-
- List<String> variables = new ArrayList<String>();
-
- BuildPathHelper buildPathHelper = new BuildPathHelper();
-
- for (File f : restLibsPaths) {
- variables.add(buildPathHelper.addExternalJar(f.getPath(), getWsProjectName(), true));
- }
-
- return variables;
-
- }
-
- private List<File> getPathForRestLibs() {
-
- assertTrue(TestConfigurator.currentConfig.getServer().type.equals("EAP"));
-
- String runtimeHome = TestConfigurator.currentConfig.getServer().runtimeHome;
-
- // index of last occurence of "/" in EAP runtime path:
jboss-eap-5.1/jboss-as
- int indexOfAS = runtimeHome.lastIndexOf("/");
-
- // jboss-eap-5.1/jboss-as --> jboss-eap-5.1
- String eapDirHome = runtimeHome.substring(0, indexOfAS);
-
- String restEasyDirPath = eapDirHome + "/" + "resteasy";
- File restEasyDir = new File(restEasyDirPath);
-
- String[] restEasyLibs = {"jaxrs-api.jar"};
-
- return resourceHelper.searchAllFiles(restEasyDir, restEasyLibs);
- }
-
- 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.waitForAll();
-
- }
-
- private SWTBot openPreferencePage(final String name,
- final List<String> groupPath) {
- return open.preferenceOpen(new IPreference() {
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public List<String> getGroupPath() {
- return groupPath;
- }
- });
- }
-
}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/completion/RESTfulCompletionTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/completion/RESTfulCompletionTest.java 2012-04-17
13:44:25 UTC (rev 40243)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/completion/RESTfulCompletionTest.java 2012-04-17
13:45:41 UTC (rev 40244)
@@ -16,7 +16,8 @@
import org.jboss.tools.ui.bot.ext.helper.ContentAssistHelper;
import org.jboss.tools.ws.ui.bot.test.rest.RESTfulTestBase;
-import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulExplorerTest;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -26,10 +27,6 @@
*/
public class RESTfulCompletionTest extends RESTfulTestBase{
- private final String GET_METHOD_PATH = "/{userId}";
-
- private final String EMPTY_PATH_PARAM = "";
-
private final String CORRECT_PATH_PARAM = "userId";
private final String INCORRECT_PATH_PARAM = "someId";
@@ -40,25 +37,24 @@
private final List<String> EXP_EMPTY_COMPLETION_RESULT = Arrays.asList("No
Default Proposals");
- protected String getWsProjectName() {
- return "RestServicesCompletion";
+ @Before
+ public void setup() {
+
}
- protected String getWsPackage() {
- return "org.rest.services.completion.test";
+ @After
+ public void cleanup() {
+ projectExplorer.deleteAllProjects();
}
-
- protected String getWsName() {
- return "RestService";
- }
@Test
public void testWithEmptyPrefix() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, EMPTY_PATH_PARAM);
+ setWsProjectName("restCompletion1");
+ prepareRestProject();
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
ContentAssistHelper.checkContentAssistContent(bot,
getWsName() + ".java", PATH_PARAM_NAVIGATION,
PATH_PARAM_NAVIGATION.length() + 1,
0, EXP_NON_EMPTY_COMPLETION_RESULT);
@@ -68,10 +64,11 @@
@Test
public void testWithValidPrefixAtTheEnd() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, CORRECT_PATH_PARAM);
+ setWsProjectName("restCompletion2");
+ prepareRestProject();
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
ContentAssistHelper.checkContentAssistContent(bot,
getWsName() + ".java", PATH_PARAM_NAVIGATION,
PATH_PARAM_NAVIGATION.length() +
CORRECT_PATH_PARAM.length() + 1,
@@ -82,10 +79,11 @@
@Test
public void testWithValidPrefixInTheBeginning() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, CORRECT_PATH_PARAM);
+ setWsProjectName("restCompletion2");
+ prepareRestProject();
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
ContentAssistHelper.checkContentAssistContent(bot,
getWsName() + ".java", PATH_PARAM_NAVIGATION,
PATH_PARAM_NAVIGATION.length() + 1,
0, EXP_NON_EMPTY_COMPLETION_RESULT);
@@ -95,10 +93,11 @@
@Test
public void testWithInvalidPrefixAtTheEnd() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, INCORRECT_PATH_PARAM);
+ setWsProjectName("restCompletion3");
+ prepareRestProject();
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
ContentAssistHelper.checkContentAssistContent(bot,
getWsName() + ".java", PATH_PARAM_NAVIGATION,
PATH_PARAM_NAVIGATION.length() +
INCORRECT_PATH_PARAM.length() + 1,
@@ -109,10 +108,11 @@
@Test
public void testWithInvalidPrefixInTheBeginning() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, INCORRECT_PATH_PARAM);
+ setWsProjectName("restCompletion3");
+ prepareRestProject();
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
ContentAssistHelper.checkContentAssistContent(bot,
getWsName() + ".java", PATH_PARAM_NAVIGATION,
PATH_PARAM_NAVIGATION.length() + 1,
0, EXP_NON_EMPTY_COMPLETION_RESULT);
@@ -122,10 +122,11 @@
@Test
public void testWithAllInvalidParamSelection() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, INCORRECT_PATH_PARAM);
+ setWsProjectName("restCompletion3");
+ prepareRestProject();
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
ContentAssistHelper.checkContentAssistContent(bot,
getWsName() + ".java", PATH_PARAM_NAVIGATION,
PATH_PARAM_NAVIGATION.length() + 1,
INCORRECT_PATH_PARAM.length(), EXP_NON_EMPTY_COMPLETION_RESULT);
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerTest.java 2012-04-17
13:44:25 UTC (rev 40243)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulExplorerTest.java 2012-04-17
13:45:41 UTC (rev 40244)
@@ -16,6 +16,8 @@
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.After;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -27,28 +29,26 @@
public class RESTfulExplorerTest extends RESTfulTestBase {
private RESTFullExplorerWizard restfulWizard = null;
+
+ private String restBasicProjectName = "restBasic";
+ private String restAdvancedProjectName = "restAdvanced";
- protected String getWsProjectName() {
- return "RestServicesExplorer";
+ @Before
+ public void setup() {
+
}
- protected String getWsPackage() {
- return "org.rest.explorer.services.test";
+ @After
+ public void cleanup() {
+ projectExplorer.deleteAllProjects();
}
-
- protected String getWsName() {
- return "RestService";
- }
@Test
public void testAddingSimpleRESTMethods() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.
- getResourceAsStream(BASIC_WS_RESOURCE),
- false, getWsPackage(), getWsName());
+ setWsProjectName(restBasicProjectName);
+ prepareRestProject();
- bot.sleep(Timing.time2S());
restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
@@ -67,14 +67,11 @@
@Test
public void testAddingAdvancedRESTMethods() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.
- getResourceAsStream(ADVANCED_WS_RESOURCE),
- false, getWsPackage(), getWsName());
+ setWsProjectName(restAdvancedProjectName);
+ prepareRestProject();
- bot.sleep(Timing.time2S());
restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
- SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+ SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
assertTrue(restServices.length + " RESTful services was found instead of
4.",
restServices.length == 4);
@@ -109,18 +106,17 @@
@Test
public void testEditingSimpleRESTMethods() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.
- getResourceAsStream(BASIC_WS_RESOURCE),
- false, getWsPackage(), getWsName());
+ setWsProjectName(restBasicProjectName);
+ prepareRestProject();
- bot.sleep(Timing.time2S());
restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
assertTrue("All RESTful services (GET, DELETE, POST, PUT) should be present but
they are not",
allRestServicesArePresent(restServices));
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "@DELETE",
"@GET");
bot.sleep(Timing.time2S());
@@ -141,12 +137,9 @@
@Test
public void testEditingAdvancedRESTMethods() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.
- getResourceAsStream(ADVANCED_WS_RESOURCE),
- false, getWsPackage(), getWsName());
+ setWsProjectName(restAdvancedProjectName);
+ prepareRestProject();
- bot.sleep(Timing.time2S());
restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
@@ -159,6 +152,8 @@
}
}
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(),
"/delete/{id}", "delete/edited/{id}");
resourceHelper.replaceInEditor(bot.activeEditor().toTextEditor(), "@DELETE",
"@DELETE" + LINE_SEPARATOR +
"@Produces(\"text/plain\")");
@@ -178,18 +173,17 @@
@Test
public void testDeletingRESTMethods() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.
- getResourceAsStream(BASIC_WS_RESOURCE),
- false, getWsPackage(), getWsName());
+ setWsProjectName(restBasicProjectName);
+ prepareRestProject();
- bot.sleep(Timing.time2S());
restfulWizard = new RESTFullExplorerWizard(getWsProjectName());
SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
assertTrue(restServices.length + " RESTful services was found instead of 4.",
restServices.length == 4);
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
RESTfulExplorerTest.class.
getResourceAsStream(EMPTY_WS_RESOURCE),
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulSupportTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulSupportTest.java 2012-04-17
13:44:25 UTC (rev 40243)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/explorer/RESTfulSupportTest.java 2012-04-17
13:45:41 UTC (rev 40244)
@@ -26,14 +26,6 @@
return "RestExplorerTest";
}
- protected String getWsPackage() {
- return "org.rest.explorer.validation.test";
- }
-
- protected String getWsName() {
- return "RestService";
- }
-
@Before
public void setup() {
if (!projectExists(getWsProjectName())) {
@@ -45,8 +37,8 @@
@Test
public void test_JAXRS_ExplorerSupport() {
- addRestSupport(getWsProjectName());
- assertTrue(isRestSupportEnabled(getWsProjectName()));
+ restfulHelper.addRestSupport(getWsProjectName());
+ assertTrue(restfulHelper.isRestSupportEnabled(getWsProjectName()));
}
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-04-17
13:44:25 UTC (rev 40243)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java 2012-04-17
13:45:41 UTC (rev 40244)
@@ -13,6 +13,8 @@
import org.jboss.tools.ws.ui.bot.test.rest.RESTfulTestBase;
import org.jboss.tools.ws.ui.bot.test.rest.explorer.RESTfulExplorerTest;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Test;
/**
@@ -26,84 +28,81 @@
private final String CORRECT_PATH_PARAM = "id";
private final String BAD_PATH_PARAM = "customerId";
- protected String getWsProjectName() {
- return "RestServicesValidation";
+ @Before
+ public void setup() {
+
}
- protected String getWsPackage() {
- return "org.rest.validation.services.test";
+ @After
+ public void cleanup() {
+ projectExplorer.deleteAllProjects();
}
-
- protected String getWsName() {
- return "RestService";
- }
@Test
public void testCorrectValueValidation() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, CORRECT_PATH_PARAM);
+ setWsProjectName("restValidation1");
+ prepareRestProject();
- assertTrue(getRESTValidationErrors(getWsProjectName()).length == 0);
+ assertTrue(restfulHelper.getRESTValidationErrors(getWsProjectName()).length == 0);
}
@Test
public void testBadValueValidation() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, BAD_PATH_PARAM);
+ setWsProjectName("restValidation2");
+ prepareRestProject();
- assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
- getRESTValidationErrors(getWsProjectName()).length == 1);
+ assertTrue("" +
restfulHelper.getRESTValidationErrors(getWsProjectName()).length,
+ restfulHelper.getRESTValidationErrors(getWsProjectName()).length == 1);
}
@Test
public void testCorrectToBadValueValidation() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, CORRECT_PATH_PARAM);
+ setWsProjectName("restValidation1");
+ prepareRestProject();
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
false, getWsPackage(), getWsName(), GET_METHOD_PATH, BAD_PATH_PARAM);
- assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
- getRESTValidationErrors(getWsProjectName()).length == 1);
+ assertTrue("" +
restfulHelper.getRESTValidationErrors(getWsProjectName()).length,
+ restfulHelper.getRESTValidationErrors(getWsProjectName()).length == 1);
}
@Test
public void testBadToCorrectValueValidation() {
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, BAD_PATH_PARAM);
+ setWsProjectName("restValidation2");
+ prepareRestProject();
+ packageExplorer.openFile(getWsProjectName(), "src",
+ getWsPackage(), getWsName() + ".java").toTextEditor();
resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
false, getWsPackage(), getWsName(), GET_METHOD_PATH, CORRECT_PATH_PARAM);
- assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
- getRESTValidationErrors(getWsProjectName()).length == 0);
+ assertTrue("" +
restfulHelper.getRESTValidationErrors(getWsProjectName()).length,
+ restfulHelper.getRESTValidationErrors(getWsProjectName()).length == 0);
}
@Test
public void testJAX_RS_Validator() {
- disableRESTValidation();
+ restfulHelper.disableRESTValidation();
- resourceHelper.copyResourceToClass(bot.editorByTitle(getWsName() + ".java"),
- RESTfulExplorerTest.class.getResourceAsStream(SIMPLE_REST_WS_RESOURCE),
- false, getWsPackage(), getWsName(), GET_METHOD_PATH, BAD_PATH_PARAM);
+ setWsProjectName("restValidation2");
+ prepareRestProject();
- assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
- getRESTValidationErrors(getWsProjectName()).length == 0);
+ assertTrue("" +
restfulHelper.getRESTValidationErrors(getWsProjectName()).length,
+ restfulHelper.getRESTValidationErrors(getWsProjectName()).length == 0);
- enableRESTValidation();
+ restfulHelper.enableRESTValidation();
- assertTrue("" + getRESTValidationErrors(getWsProjectName()).length,
- getRESTValidationErrors(getWsProjectName()).length == 1);
+ assertTrue("" +
restfulHelper.getRESTValidationErrors(getWsProjectName()).length,
+ restfulHelper. getRESTValidationErrors(getWsProjectName()).length == 1);
}
}
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-04-17
13:44:25 UTC (rev 40243)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/ti/wizard/RESTFullExplorerWizard.java 2012-04-17
13:45:41 UTC (rev 40244)
@@ -21,7 +21,8 @@
public RESTFullExplorerWizard(String wsProjectName) {
String[] pathToRestExplorer = {wsProjectName};
- restFulExplorer =
projectExplorer.selectTreeItem(RESTFulAnnotations.REST_EXPLORER_LABEL.getLabel(),
+ restFulExplorer = projectExplorer.selectTreeItem(
+ RESTFulAnnotations.REST_EXPLORER_LABEL.getLabel(),
pathToRestExplorer).expand();
}