[jbosstools-commits] JBoss Tools SVN: r41775 - in trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest: validation and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Thu Jun 7 11:39:37 EDT 2012


Author: jjankovi
Date: 2012-06-07 11:39:35 -0400 (Thu, 07 Jun 2012)
New Revision: 41775

Modified:
   trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/DefaultValueAnnotationSupportTest.java
   trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/MatrixAnnotationSupportTest.java
   trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/PathAnnotationSupportTest.java
   trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/QueryAnnotationSupportTest.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/RESTfulTestBase.java
   trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/ApplicationPathAnnotationTest.java
   trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java
Log:
refactoring of ws bot tests

Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/DefaultValueAnnotationSupportTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/DefaultValueAnnotationSupportTest.java	2012-06-07 15:38:28 UTC (rev 41774)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/DefaultValueAnnotationSupportTest.java	2012-06-07 15:39:35 UTC (rev 41775)
@@ -12,7 +12,6 @@
 package org.jboss.tools.ws.ui.bot.test.rest;
 
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.ws.ui.bot.test.ti.wizard.RESTFullExplorerWizard;
 import org.junit.Test;
 
 public class DefaultValueAnnotationSupportTest extends RESTfulTestBase {
@@ -32,9 +31,8 @@
 		/* prepare project */
 		importRestWSProject("default1");
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("default1");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("default1");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);
@@ -50,9 +48,8 @@
 		/* prepare project */
 		importRestWSProject("default2");
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("default2");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("default2");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);
@@ -67,9 +64,8 @@
 		/* prepare project */
 		importRestWSProject("default3");
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("default3");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("default3");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);

Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/MatrixAnnotationSupportTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/MatrixAnnotationSupportTest.java	2012-06-07 15:38:28 UTC (rev 41774)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/MatrixAnnotationSupportTest.java	2012-06-07 15:39:35 UTC (rev 41775)
@@ -13,7 +13,6 @@
 
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ws.ui.bot.test.ti.wizard.RESTFullExplorerWizard;
 import org.junit.Test;
 
 public class MatrixAnnotationSupportTest extends RESTfulTestBase {
@@ -42,9 +41,8 @@
 		/* prepare project */
 		importRestWSProject("matrix1");
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("matrix1");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("matrix1");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);	
@@ -64,9 +62,8 @@
 				matrixParam1, matrixParamNew, true);
 		bot.sleep(Timing.time2S());
 
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("matrix1");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("matrix1");
 
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);	
@@ -85,9 +82,8 @@
 				matrixParamType1, matrixParamTypeNew, true);
 		bot.sleep(Timing.time2S());
 
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("matrix1");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("matrix1");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);	

Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/PathAnnotationSupportTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/PathAnnotationSupportTest.java	2012-06-07 15:38:28 UTC (rev 41774)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/PathAnnotationSupportTest.java	2012-06-07 15:39:35 UTC (rev 41775)
@@ -14,7 +14,6 @@
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ws.ui.bot.test.ti.wizard.RESTFullExplorerWizard;
 import org.junit.After;
 import org.junit.Test;
 
@@ -37,9 +36,8 @@
 		/* import project */
 		importRestWSProject("restBasic");
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("restBasic");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("restBasic");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 4);		
@@ -53,9 +51,8 @@
 		/* import project */
 		importRestWSProject("restAdvanced");
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("restAdvanced");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices(); 
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("restAdvanced");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 4);		
@@ -74,9 +71,8 @@
 				"org.rest.test", "RestService.java").toTextEditor(), "@DELETE", "@GET", true);
 		bot.sleep(Timing.time2S());
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("restBasic");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices(); 
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("restBasic"); 
 		
 		/* test JAX-RS REST explorer */
 		assertNotAllRESTServicesInExplorer(restServices);
@@ -99,9 +95,8 @@
 				+ LINE_SEPARATOR + "@Produces(\"text/plain\")", true);
 		bot.sleep(Timing.time2S());
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("restAdvanced");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices(); 
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("restAdvanced");
 		
 		/* test JAX-RS REST explorer */
 		testEditedDeleteRestWebResource(restServices);
@@ -117,12 +112,11 @@
 				"org.rest.test", "RestService");
 		bot.sleep(Timing.time2S());
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("restBasic");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices(); 
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("restBasic");  
 		
 		/* none of REST web services found */
-		assertNoRESTServicesInExplorerFound(restServices);
+		assertCountOfRESTServices(restServices, 0);
 	}
 
 	private void testEditedDeleteRestWebResource(

Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/QueryAnnotationSupportTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/QueryAnnotationSupportTest.java	2012-06-07 15:38:28 UTC (rev 41774)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/QueryAnnotationSupportTest.java	2012-06-07 15:39:35 UTC (rev 41775)
@@ -13,7 +13,6 @@
 
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
 import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ws.ui.bot.test.ti.wizard.RESTFullExplorerWizard;
 import org.junit.Test;
 
 public class QueryAnnotationSupportTest extends RESTfulTestBase {
@@ -39,9 +38,8 @@
 		/* prepare project */
 		importRestWSProject("query1");
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("query1");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("query1"); 
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);	
@@ -51,9 +49,8 @@
 		/* prepare project*/
 		importRestWSProject("query2");
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("query2");
-		restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		restServices = restfulServicesForProject("query2");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);	
@@ -74,9 +71,8 @@
 				queryParam1, queryParam1New, true);
 		bot.sleep(Timing.time2S());
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("query2");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("query2");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);
@@ -99,9 +95,8 @@
 				queryType1, queryTypeNew, true);
 		bot.sleep(Timing.time2S());
 		
-		/* get JAX-RS REST explorer for the project */
-		restfulWizard = new RESTFullExplorerWizard("query2");
-		SWTBotTreeItem[] restServices = restfulWizard.getAllRestServices();
+		/* get RESTful services from JAX-RS REST explorer for the project */
+		SWTBotTreeItem[] restServices = restfulServicesForProject("query2");
 		
 		/* test JAX-RS REST explorer */
 		assertCountOfRESTServices(restServices, 1);

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-06-07 15:38:28 UTC (rev 41774)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulHelper.java	2012-06-07 15:39:35 UTC (rev 41775)
@@ -53,10 +53,18 @@
 		ADD, REMOVE;
 	}
 	
-	public SWTBotTreeItem[] getRESTValidationErrors(String wsProjectName) {
+	private SWTBotTreeItem[] getRESTValidationErrors(String wsProjectName, String description) {
 		return ProblemsView.getFilteredErrorsTreeItems(bot,
-				PATH_PARAM_VALID_ERROR, "/" + wsProjectName, null, null);
+				description, "/" + wsProjectName, null, null);
 	}
+	
+	public SWTBotTreeItem[] getPathAnnotationValidationErrors(String wsProjectName) {
+		return getRESTValidationErrors(wsProjectName, PATH_PARAM_VALID_ERROR);
+	}
+	
+	public SWTBotTreeItem[] getApplicationAnnotationValidationErrors(String wsProjectName) {
+		return getRESTValidationErrors(wsProjectName, null);
+	}
 
 	public void enableRESTValidation() {
 		modifyRESTValidation(ConfigureOption.ADD);

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-06-07 15:38:28 UTC (rev 41774)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/RESTfulTestBase.java	2012-06-07 15:39:35 UTC (rev 41775)
@@ -95,13 +95,6 @@
 				allRestServicesArePresent(restServices));
 	}
 
-	protected void assertNoRESTServicesInExplorerFound(
-			SWTBotTreeItem[] restServices) {
-		assertTrue(restServices.length
-				+ " RESTful services was found instead of 0.",
-				restServices.length == 0);
-	}
-
 	protected void assertPathOfAllRESTWebServices(
 			SWTBotTreeItem[] restServices, String path) {
 		for (SWTBotTreeItem restService : restServices) {
@@ -144,13 +137,28 @@
 		assertEquals("Failure when comparing paths = ", expectedPath, path);
 	}
 
-	protected void assertCoundOfValidationErrors(String projectName,
+	protected void assertCountOfPathAnnotationValidationErrors(String projectName,
 			int expectedCount) {
-		int foundErrors = restfulHelper.getRESTValidationErrors(projectName).length;
-		assertTrue("There should be " + expectedCount
-				+ " validation error. Found: " + foundErrors,
-				foundErrors == expectedCount);
+		int foundErrors = restfulHelper.getPathAnnotationValidationErrors(projectName).length;
+		assertCountOfValidationError(expectedCount, foundErrors);
 	}
+	
+	protected void assertCountOfApplicationAnnotationValidationErrors(String projectName,
+			int expectedCount) {
+		int foundErrors = restfulHelper.getPathAnnotationValidationErrors(projectName).length;
+		assertCountOfValidationError(expectedCount, foundErrors);
+	}
+	
+	private void assertCountOfValidationError(int expectedCount, int foundCount) {
+		assertTrue("Expected count of validation errors: " + expectedCount
+				+ ". Count of found validation errors: " + foundCount,
+				foundCount == expectedCount);
+	}
+	
+	protected SWTBotTreeItem[] restfulServicesForProject(String projectName) {
+		restfulWizard = new RESTFullExplorerWizard(projectName);
+		return restfulWizard.getAllRestServices();
+	}
 
 	protected SWTBotEditor editorForClass(String projectName, String... path) {
 		return packageExplorer.openFile(projectName, path);

Modified: trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/ApplicationPathAnnotationTest.java
===================================================================
--- trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/ApplicationPathAnnotationTest.java	2012-06-07 15:38:28 UTC (rev 41774)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/ApplicationPathAnnotationTest.java	2012-06-07 15:39:35 UTC (rev 41775)
@@ -16,12 +16,13 @@
 import org.junit.Before;
 import org.junit.Test;
 
+/**
+ * 
+ * @author jjankovi
+ *
+ */
 public class ApplicationPathAnnotationTest extends RESTfulTestBase {
 
-	@Override
-	public String getWsProjectName() {
-		return "restApplication1";
-	}
 	
 	@Before
 	public void setup() {		
@@ -34,13 +35,23 @@
 	}
 	
 	@Test
-	public void testMultipleAppClasses() {
+	public void testMultipleApplicationClasses() {
 		
+		/* prepare project */
+		importRestWSProject("app1");
+		
+		/* test validation error */
+		assertCountOfApplicationAnnotationValidationErrors("app1", 1);
 	}
 	
 	@Test
-	public void testWebXmlApplicationOption() {
+	public void testWebXmlAndApplicationClass() {
 		
+		/* prepare project */
+		importRestWSProject("app2");
+		
+		/* test validation error */
+		assertCountOfApplicationAnnotationValidationErrors("app2", 1);
 	}
 	
 }

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-06-07 15:38:28 UTC (rev 41774)
+++ trunk/ws/tests/org.jboss.tools.ws.ui.bot.test/src/org/jboss/tools/ws/ui/bot/test/rest/validation/RESTfulValidationTest.java	2012-06-07 15:39:35 UTC (rev 41775)
@@ -46,7 +46,7 @@
 				GET_METHOD_PATH, CORRECT_PATH_PARAM);
 		
 		/* test count of validation errors */
-		assertCoundOfValidationErrors(getWsProjectName(), 0);
+		assertCountOfPathAnnotationValidationErrors(getWsProjectName(), 0);
 	}
 	
 	
@@ -62,7 +62,7 @@
 				GET_METHOD_PATH, BAD_PATH_PARAM);
 		
 		/* test count of validation errors */
-		assertCoundOfValidationErrors(getWsProjectName(), 1);
+		assertCountOfPathAnnotationValidationErrors(getWsProjectName(), 1);
 	}
 	
 	@Test
@@ -79,7 +79,7 @@
 				GET_METHOD_PATH, BAD_PATH_PARAM);
 		
 		/* test count of validation errors */
-		assertCoundOfValidationErrors(getWsProjectName(), 1);
+		assertCountOfPathAnnotationValidationErrors(getWsProjectName(), 1);
 	}
 	
 	@Test
@@ -96,7 +96,7 @@
 				GET_METHOD_PATH, CORRECT_PATH_PARAM);
 		
 		/* test count of validation errors */
-		assertCoundOfValidationErrors(getWsProjectName(), 0);
+		assertCountOfPathAnnotationValidationErrors(getWsProjectName(), 0);
 	}
 	
 	@Test
@@ -113,13 +113,13 @@
 				GET_METHOD_PATH, BAD_PATH_PARAM);
 		
 		/* test count of validation errors */
-		assertCoundOfValidationErrors(getWsProjectName(), 0);
+		assertCountOfPathAnnotationValidationErrors(getWsProjectName(), 0);
 		
 		/* enable restful validation */
 		restfulHelper.enableRESTValidation();
 		
 		/* test count of validation errors */
-		assertCoundOfValidationErrors(getWsProjectName(), 1);
+		assertCountOfPathAnnotationValidationErrors(getWsProjectName(), 1);
 	}
 
 }



More information about the jbosstools-commits mailing list