Author: jjankovi
Date: 2012-03-21 09:15:04 -0400 (Wed, 21 Mar 2012)
New Revision: 39700
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/base/SolderTestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/DefaultBeansTest.java
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/ExactAnnotationTest.java
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/VetoAnnotationTest.java
Log:
Small modifications to Annotations based bot tests and SolderTestBase
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/base/SolderTestBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/base/SolderTestBase.java 2012-03-21
13:14:10 UTC (rev 39699)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/base/SolderTestBase.java 2012-03-21
13:15:04 UTC (rev 39700)
@@ -6,8 +6,13 @@
@Override
public void prepareWorkspace() {
- projectImportHelper.importTestProject("/resources/projects/" +
getProjectName(), getProjectName());
- addAndCheckLibraryInProject(getProjectName(), SeamLibraries.SOLDER);
+ importProjectWithLibrary(getProjectName(), SeamLibraries.SOLDER);
}
+ public void importProjectWithLibrary(String projectName, SeamLibraries library) {
+ projectImportHelper.importTestProject("/resources/projects/" + projectName,
projectName);
+ addAndCheckLibraryInProject(projectName, library);
+ eclipse.cleanAllProjects();
+ }
+
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/DefaultBeansTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/DefaultBeansTest.java 2012-03-21
13:14:10 UTC (rev 39699)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/DefaultBeansTest.java 2012-03-21
13:15:04 UTC (rev 39700)
@@ -38,7 +38,7 @@
"cdi.seam", className);
assertFalse(openOnUtil.openOnByOption("managerImpl", className,
CDIConstants.SHOW_ALL_ASSIGNABLE));
- openOnUtil.openOnByOption("managerImpl", className, "Open @Inject
Bean");
+ openOnUtil.openOnByOption("managerImpl", className,
CDIConstants.OPEN_INJECT_BEAN);
String destinationFile = getEd().getTitle();
assertTrue("ERROR: redirected to " + destinationFile,
destinationFile.equals("DefaultOne.java"));
@@ -68,7 +68,7 @@
assertTrue(allBeans.rowCount() == 1);
assertTrue(allBeans.getTableItem(0).getText().contains("DefaultOne"));
- openOnUtil.openOnByOption("managerImpl", className, "Open @Inject
Bean");
+ openOnUtil.openOnByOption("managerImpl", className,
CDIConstants.OPEN_INJECT_BEAN);
String destinationFile = getEd().getTitle();
assertTrue("ERROR: redirected to " + destinationFile,
destinationFile.equals("DefaultOne.java"));
@@ -98,7 +98,7 @@
assertTrue(allBeans.rowCount() == 1);
assertTrue(allBeans.getTableItem(0).getText().contains("ManagerImpl"));
- openOnUtil.openOnByOption("managerImpl", className, "Open @Inject
Bean");
+ openOnUtil.openOnByOption("managerImpl", className,
CDIConstants.OPEN_INJECT_BEAN);
String destinationFile = getEd().getTitle();
assertTrue("ERROR: redirected to " + destinationFile,
destinationFile.equals("ManagerImpl.java"));
@@ -131,7 +131,7 @@
assertTrue(allBeans.rowCount() == 1);
assertTrue(allBeans.getTableItem(0).getText().contains("ManagerImpl"));
- openOnUtil.openOnByOption("managerImpl", className, "Open @Inject
Bean");
+ openOnUtil.openOnByOption("managerImpl", className,
CDIConstants.OPEN_INJECT_BEAN);
String destinationFile = getEd().getTitle();
assertTrue("ERROR: redirected to " + destinationFile,
destinationFile.equals("ManagerImpl.java"));
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/ExactAnnotationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/ExactAnnotationTest.java 2012-03-21
13:14:10 UTC (rev 39699)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/ExactAnnotationTest.java 2012-03-21
13:15:04 UTC (rev 39700)
@@ -16,8 +16,6 @@
import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
import org.jboss.tools.cdi.seam3.bot.test.base.SolderTestBase;
import org.jboss.tools.cdi.seam3.bot.test.util.SeamLibraries;
-import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
-import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.Test;
public class ExactAnnotationTest extends SolderTestBase {
@@ -26,7 +24,6 @@
private final String EXACT_INTERFACE = "exact-interface";
private final String EXACT_BEANS = "exact-beans";
- private final String MULTIPLE_BEANS = "Multiple beans are eligible for
injection";
@Override
public String getProjectName() {
@@ -63,9 +60,7 @@
String peopleManager = "PeopleManager";
String otherManager = "OtherManager";
- projectImportHelper.importTestProject("/resources/projects/" + projectName,
- projectName);
- addAndCheckLibraryInProject(projectName, SeamLibraries.SOLDER);
+ importProjectWithLibrary(projectName, SeamLibraries.SOLDER);
setEd(packageExplorer.openFile(projectName, CDIConstants.SRC,
"cdi.seam", className).toTextEditor());
@@ -85,20 +80,18 @@
private void testExactImproperValue(String projectName) {
- SWTEclipseExt.showView(bot,ViewType.PROBLEMS);
SWTBotTreeItem[] validationProblems = quickFixHelper.getProblems(ProblemsType.WARNINGS,
projectName);
assertTrue(validationProblems.length > 0);
assertTrue(validationProblems.length == 1);
- assertContains(MULTIPLE_BEANS, validationProblems[0].getText());
+ assertContains(CDIConstants.MULTIPLE_BEANS, validationProblems[0].getText());
}
private void testExactProperValue(String projectName, String value) {
- SWTEclipseExt.showView(bot,ViewType.PROBLEMS);
SWTBotTreeItem[] validationProblems = quickFixHelper.getProblems(ProblemsType.WARNINGS,
projectName);
assertTrue(validationProblems.length == 0);
- assertTrue(openOnUtil.openOnByOption(value + ".class", className, "Open
@Inject Bean"));
+ assertTrue(openOnUtil.openOnByOption(value + ".class", className,
CDIConstants.OPEN_INJECT_BEAN));
assertTrue(getEd().getTitle().equals(value + ".java"));
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/VetoAnnotationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/VetoAnnotationTest.java 2012-03-21
13:14:10 UTC (rev 39699)
+++
trunk/cdi/tests/org.jboss.tools.cdi.seam3.bot.test/src/org/jboss/tools/cdi/seam3/bot/test/tests/VetoAnnotationTest.java 2012-03-21
13:15:04 UTC (rev 39700)
@@ -11,54 +11,163 @@
package org.jboss.tools.cdi.seam3.bot.test.tests;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDIConstants;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
import org.jboss.tools.cdi.seam3.bot.test.base.SolderTestBase;
+import org.jboss.tools.cdi.seam3.bot.test.util.SeamLibraries;
+import org.junit.Ignore;
import org.junit.Test;
public class VetoAnnotationTest extends SolderTestBase {
+ private String APPLICATION_CLASS = "Application.java";
+
@Override
public String getProjectName() {
- return "veto";
+ return "veto1";
}
@Override
public void waitForJobs() {
-
+ projectExplorer.deleteAllProjects();
}
- @Test
- public void testManagedBeans() {
+ @Override
+ public void prepareWorkspace() {
}
- @Test
- public void testDecorator() {
-
- }
@Test
- public void testInterceptor() {
+ public void testManagedBeans() {
+ String vetoBean = "Bean";
+ String otherBean = "OtherBean";
+ String projectName = "veto1";
+
+ importProjectWithLibrary(projectName, SeamLibraries.SOLDER);
+
+ setEd(packageExplorer.openFile(projectName, CDIConstants.SRC,
+ "cdi.seam", APPLICATION_CLASS).toTextEditor());
+
+ testVetoAnnotationImproperValue(projectName);
+
+ setEd(packageExplorer.openFile(projectName, CDIConstants.SRC,
+ "cdi.seam", otherBean + ".java").toTextEditor());
+ editResourceUtil.replaceInEditor("public class " + otherBean,
+ "public class " + otherBean + " extends " + vetoBean);
+
+ testVetoAnnotationProperValue(projectName, "bean", otherBean, false, null);
+
}
@Test
public void testSessionBean() {
+ String vetoBean = "Bean";
+ String otherBean = "OtherBean";
+ String projectName = "veto2";
+
+ importProjectWithLibrary(projectName, SeamLibraries.SOLDER);
+
+ setEd(packageExplorer.openFile(projectName, CDIConstants.SRC,
+ "cdi.seam", APPLICATION_CLASS).toTextEditor());
+
+ testVetoAnnotationImproperValue(projectName);
+
+ setEd(packageExplorer.openFile(projectName, CDIConstants.SRC,
+ "cdi.seam", otherBean + ".java").toTextEditor());
+ editResourceUtil.replaceInEditor("public class " + otherBean,
+ "public class " + otherBean + " extends " + vetoBean);
+
+ testVetoAnnotationProperValue(projectName, "bean", otherBean, false, null);
+
}
@Test
public void testProducerMethod() {
+ String vetoBean = "Bean";
+ String projectName = "veto3";
+
+ importProjectWithLibrary(projectName, SeamLibraries.SOLDER);
+
+ setEd(packageExplorer.openFile(projectName, CDIConstants.SRC,
+ "cdi.seam", APPLICATION_CLASS).toTextEditor());
+
+ testVetoAnnotationImproperValue(projectName);
+
+ setEd(packageExplorer.openFile(projectName, CDIConstants.SRC,
+ "cdi.seam", vetoBean + ".java").toTextEditor());
+ editResourceUtil.replaceInEditor("@Veto", "");
+ editResourceUtil.replaceInEditor("import org.jboss.seam.solder.core.Veto;",
"");
+
+ testVetoAnnotationProperValue(projectName, "manager", vetoBean,
+ true, "getManager");
+
}
@Test
public void testProducerField() {
+ String vetoBean = "Bean";
+ String projectName = "veto4";
+
+ importProjectWithLibrary(projectName, SeamLibraries.SOLDER);
+
+ setEd(packageExplorer.openFile(projectName, CDIConstants.SRC,
+ "cdi.seam", APPLICATION_CLASS).toTextEditor());
+
+ testVetoAnnotationImproperValue(projectName);
+
+ setEd(packageExplorer.openFile(projectName, CDIConstants.SRC,
+ "cdi.seam", vetoBean + ".java").toTextEditor());
+ editResourceUtil.replaceInEditor("@Veto", "");
+ editResourceUtil.replaceInEditor("import org.jboss.seam.solder.core.Veto;",
"");
+
+ testVetoAnnotationProperValue(projectName, "manager", vetoBean,
+ true, "manager");
+
}
-
+ @Ignore
@Test
public void testObserverMethods() {
+
+
}
+ /*@Ignore
+ @Test
+ public void testDecorator() {
+
+ }
+ @Ignore
+ @Test
+ public void testInterceptor() {
+
+ }*/
+ private void testVetoAnnotationImproperValue(String projectName) {
+
+ SWTBotTreeItem[] validationProblems = quickFixHelper.getProblems(
+ ProblemsType.WARNINGS, projectName);
+ assertTrue(validationProblems.length > 0);
+ assertTrue(validationProblems.length == 1);
+ assertContains(CDIConstants.NO_BEAN_IS_ELIGIBLE, validationProblems[0].getText());
+
+ }
+
+ private void testVetoAnnotationProperValue(String projectName, String openOnString,
String openedClass,
+ boolean producer, String producerMethod) {
+ SWTBotTreeItem[] validationProblems = quickFixHelper.getProblems(
+ ProblemsType.WARNINGS, projectName);
+ assertTrue(validationProblems.length == 0);
+ assertTrue(openOnUtil.openOnByOption(openOnString, APPLICATION_CLASS,
CDIConstants.OPEN_INJECT_BEAN));
+ assertTrue(getEd().getTitle().equals(openedClass + ".java"));
+ if (producer) {
+ assertTrue(getEd().getSelection().equals(producerMethod));
+ }
+ }
+
}