Author: jjankovi
Date: 2012-10-16 11:11:31 -0400 (Tue, 16 Oct 2012)
New Revision: 44529
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/annotation/HTTPMethodAnnotationQuickFixTest.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulHelper.java
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/JaxRsValidatorTest.java
Log:
new test implemented
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/annotation/HTTPMethodAnnotationQuickFixTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/annotation/HTTPMethodAnnotationQuickFixTest.java 2012-10-16
15:10:56 UTC (rev 44528)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/annotation/HTTPMethodAnnotationQuickFixTest.java 2012-10-16
15:11:31 UTC (rev 44529)
@@ -6,6 +6,7 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
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.Annotations.ServerState;
@@ -24,13 +25,8 @@
public class HTTPMethodAnnotationQuickFixTest extends WSTestBase {
@Override
- protected String getWsProjectName() {
- return "httpAnnot";
- }
-
- @Override
public void setup() {
- importWSTestProject(getWsProjectName());
+
}
@Override
@@ -39,21 +35,53 @@
}
@Test
- public void testQuickFixes() {
+ public void testHTTPMethodWithoutParameters() {
+ /* import the project */
+ String wsProjectName = "httpAnnot1";
+ importWSTestProject(wsProjectName);
- /* workaround for JBIDE-12690
- jbide12680Workaround(getWsProjectName(), "src", "test",
"MyAnnot.java"); */
+ /* workaround for JBIDE-12690 */
+ jbide12680Workaround(wsProjectName, "src", "test",
"MyAnnot.java");
+ /* assert that there is one Java problem */
+ assertThat(errorsByType("Java Problem").length, equalTo(1));
+
+ /* get quickfix bot for HttpMethod annotation */
+ QuickFixBot qBot = quickFixBot("@HttpMethod");
+
+ /* check that there are quick fixes for both required annotations */
+ qBot.checkQuickFix("Add missing attributes", true);
+ bot.activeEditor().save();
+
+ /* assert that there is one JAX-RS errors - empty value */
+ assertThat(errorsByType("JAX-RS Problem").length, equalTo(1));
+ }
+
+ @Test
+ public void testTargetRetentionQuickFixes() {
+
+ /* import the project */
+ String wsProjectName = "httpAnnot2";
+ importWSTestProject(wsProjectName);
+
+ /* workaround for JBIDE-12690 */
+ jbide12680Workaround(wsProjectName, "src", "test",
"MyAnnot.java");
+
/* assert that there are two JAX-RS errors */
assertThat(errorsByType("JAX-RS Problem").length, equalTo(2));
/* get quickfix bot for MyAnnot annotation */
- QuickFixBot bot = quickFixBot();
+ QuickFixBot qBot = quickFixBot("MyAnnot");
/* check that there are quick fixes for both required annotations */
- bot.checkQuickFix("Add @Target annotation on type MyAnnot", false);
- bot.checkQuickFix("Add @Retention annotation on type MyAnnot", false);
+ qBot.checkQuickFix("Add @Target annotation on type MyAnnot", true);
+ /* there is need to wait a while until validation starts to work */
+ bot.sleep(Timing.time2S());
+ qBot.checkQuickFix("Add @Retention annotation on type MyAnnot", true);
+ bot.sleep(Timing.time2S());
+ /* assert that there are no JAX-RS errors */
+ assertThat(errorsByType("JAX-RS Problem").length, equalTo(0));
}
private void jbide12680Workaround(String projectName, String... path) {
@@ -63,12 +91,12 @@
eclipseEditor.save();
}
- private QuickFixBot quickFixBot() {
+ private QuickFixBot quickFixBot(String underlinedText) {
SWTBotEditorExt editor = new SWTBotEditorExt(bot.activeEditor().getReference(), bot);
SWTBotEclipseEditor eclipseEditor = editor.toTextEditor();
int lineIndex = 0;
for (String line : eclipseEditor.getLines()) {
- if (line.contains("@Http")) {
+ if (line.contains(underlinedText)) {
break;
}
lineIndex++;
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulHelper.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulHelper.java 2012-10-16
15:10:56 UTC (rev 44528)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulHelper.java 2012-10-16
15:11:31 UTC (rev 44529)
@@ -44,7 +44,7 @@
private static final ResourceHelper resourceHelper = new ResourceHelper();
private static final String PATH_PARAM_VALID_ERROR = "@PathParam value";
- private static final String VALIDATION_SETTINGS_CHANGED = "Validation Settings
Changed";
+ private static final String VALIDATOR_SETTINGS_CHANGED = "Validator Settings
Changed";
private enum ConfigureOption {
ENABLE, DISABLE;
@@ -84,7 +84,7 @@
validationBot.checkBox(0).deselect();
}
validationBot.button(IDELabel.Button.OK).click();
- if (bot.activeShell().getText().equals(VALIDATION_SETTINGS_CHANGED)) {
+ if (bot.activeShell().getText().equals(VALIDATOR_SETTINGS_CHANGED)) {
bot.activeShell().bot().button(IDELabel.Button.YES).click();
}
Modified:
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/JaxRsValidatorTest.java
===================================================================
---
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/JaxRsValidatorTest.java 2012-10-16
15:10:56 UTC (rev 44528)
+++
trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/JaxRsValidatorTest.java 2012-10-16
15:11:31 UTC (rev 44529)
@@ -56,6 +56,9 @@
/* test count of validation errors */
assertCountOfPathAnnotationValidationErrors(getWsProjectName(), 0);
+
+ /* enable restful validation - to have proper test environment*/
+ restfulHelper.enableRESTValidation();
}
private SWTBot openJaxRsValidator() {
Show replies by date