Author: jjankovi
Date: 2011-08-16 08:42:16 -0400 (Tue, 16 Aug 2011)
New Revision: 33970
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/BrokenFarm.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/Dog.java.cdi
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/fix/CDIQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
Log:
Added new quick fix test and util methods
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/BrokenFarm.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/BrokenFarm.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/BrokenFarm.java.cdi 2011-08-16
12:42:16 UTC (rev 33970)
@@ -0,0 +1,9 @@
+package org.cdi.test;
+
+import javax.inject.Inject;
+
+public class BrokenFarm {
+ @SuppressWarnings("unused")
+ @Inject private Animal animal;
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/Dog.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/Dog.java.cdi
(rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/Dog.java.cdi 2011-08-16
12:42:16 UTC (rev 33970)
@@ -0,0 +1,9 @@
+package org.cdi.test;
+
+public class Dog extends Animal {
+
+ public Dog() {
+
+ }
+
+}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-08-16
11:51:32 UTC (rev 33969)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-08-16
12:42:16 UTC (rev 33970)
@@ -40,9 +40,10 @@
*/
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({
- CdiATWizardTest.class,
- BeansEditorTest.class,
- CDIQuickFixTest.class
+ //CdiATWizardTest.class,
+ CDIQuickFixTest.class,
+ //BeansEditorTest.class
+
})
public class CDIAllBotTests {
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/fix/CDIQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/fix/CDIQuickFixTest.java 2011-08-16
11:51:32 UTC (rev 33969)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/fix/CDIQuickFixTest.java 2011-08-16
12:42:16 UTC (rev 33970)
@@ -4,14 +4,12 @@
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-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.cdi.bot.test.CDIAllBotTests;
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.NewCDIFileWizard;
import org.jboss.tools.cdi.bot.test.uiutils.actions.NewFileWizardAction;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
import org.jboss.tools.cdi.bot.test.uiutils.wizards.DynamicWebProjectWizard;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
@@ -19,6 +17,7 @@
import org.jboss.tools.ui.bot.ext.config.Annotations.SWTBotTestRequires;
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
+import org.jboss.tools.ui.bot.ext.entity.JavaClassEntity;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.jboss.tools.ui.bot.ext.view.ProblemsView;
import org.junit.Before;
@@ -40,59 +39,142 @@
private static final Logger LOGGER = Logger.getLogger(CDIQuickFixTest.class.getName());
private static final String PROJECT_NAME = "CDIProject";
private static final String PACKAGE_NAME = "org.cdi.test";
- private static final String BEAN_NAME = "B1";
-
@Before
public void setUp() {
eclipse.showView(ViewType.PROJECT_EXPLORER);
}
-
+
@Test
- public void testSerializableQF() {
- new NewFileWizardAction().run()
- .selectTemplate("Web", "Dynamic Web Project").next();
- new DynamicWebProjectWizard().setProjectName(PROJECT_NAME).finish();
- util.waitForNonIgnoredJobs();
- SWTBot v = eclipse.showView(ViewType.PROJECT_EXPLORER);
- SWTBotTree tree = v.tree();
- tree.setFocus();
- assertTrue("Project " + PROJECT_NAME + " was not created
properly.",
- SWTEclipseExt.treeContainsItemWithLabel(tree, PROJECT_NAME));
- SWTBotTreeItem item = tree.getTreeItem(PROJECT_NAME);
- item.expand();
-
- CDIUtil.addCDISupport(tree, item, bot, util);
-
- new NewCDIFileWizard(CDIWizardType.BEAN).run().setPackage(PACKAGE_NAME)
- .setName(BEAN_NAME).finish();
+ public void testSerializableQF() {
+ createAndCheckCDIProject();
+ CDIUtil.bean(PACKAGE_NAME, "B1", true, false, false, false, null, null,
+ null, null).finish();
util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = bot.activeEditor();
+ assertTrue(("B1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ LOGGER.fine(code);
+ assertTrue(code.contains("package " + PACKAGE_NAME + ";"));
+ assertTrue(code.contains("public class B1 {"));
- SWTBotEditor ed = bot.editorByTitle(BEAN_NAME + ".java");
- assertNotNull("Bean: " + BEAN_NAME + " was not created properly.",
ed);
+ CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
+ .getResourceAsStream("/resources/cdi/B1.java.cdi"), false);
+ assertContains("@SessionScoped", ed.toTextEditor().getText());
+ SWTEclipseExt.showView(bot, ViewType.PROBLEMS);
+ bot.sleep(3 * TIME_1S);
+ SWTBotTreeItem[] warningTrees = ProblemsView.
+ getFilteredWarningsTreeItems(bot, "Managed bean B1 which", "/"
+ + PROJECT_NAME, "B1.java", "CDI Problem");
+ assertTrue("Warnings node should contain only one record instead of "
+ + warningTrees.length + " records.", warningTrees.length == 1);
+ CDIUtil.resolveQuickFix(bot.tree(), warningTrees[0], bot, util);
+ SWTBotEclipseEditor eclEditor = ed.toTextEditor();
+ assertTrue("Quick fix does not resolve issue properly.", eclEditor
+ .getText().contains("import java.io.Serializable;"));
+ warningTrees = ProblemsView.getFilteredWarningsTreeItems(bot,
+ "Managed bean B1 which", "/" + PROJECT_NAME,
"B1.java",
+ "CDI Problem");
+ assertTrue("Warnings should not contain resolved problem.",
+ warningTrees.length == 0);
+ }
+
+ @Test
+ public void testMultipleBeansQF() {
+ CDIUtil.bean(PACKAGE_NAME, "Animal", true, false, false, false, null,
+ null, null, null).finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = bot.activeEditor();
+ assertTrue(("Animal.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ assertTrue(code.contains("package " + PACKAGE_NAME + ";"));
+ assertTrue(code.contains("public class Animal {"));
+
+ CDIUtil.bean(PACKAGE_NAME, "Dog", true, false, false, false, null,
+ null, null, null).finish();
+ util.waitForNonIgnoredJobs();
+ ed = bot.activeEditor();
CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/" + BEAN_NAME +
".java.cdi"), false);
- assertContains("(a)SessionScoped",ed.toTextEditor().getText());
-
+ .getResourceAsStream("/resources/cdi/Dog.java.cdi"), false);
+ assertTrue(("Dog.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ LOGGER.fine(code);
+ assertTrue(code.contains("package " + PACKAGE_NAME + ";"));
+ assertTrue(code.contains("public class Dog extends Animal {"));
+
+ CDIUtil.qualifier(PACKAGE_NAME, "Q1", false, false).finish();
+ util.waitForNonIgnoredJobs();
+ ed = bot.activeEditor();
+ assertTrue(("Q1.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ LOGGER.fine(code);
+
+ JavaClassEntity brokenFarm = new JavaClassEntity();
+ brokenFarm.setClassName("BrokenFarm");
+ brokenFarm.setPackageName(PACKAGE_NAME);
+ eclipse.createJavaClass(brokenFarm);
+ ed = bot.activeEditor();
+ CDIUtil.copyResourceToClass(ed, CDIQuickFixTest.class
+ .getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"),
+ false);
+ assertTrue(("BrokenFarm.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ LOGGER.fine(code);
+ assertTrue(code.contains("package " + PACKAGE_NAME + ";"));
+ assertTrue(code.contains("public class BrokenFarm {"));
+ assertTrue(code.contains("@Inject private Animal animal;"));
+
SWTEclipseExt.showView(bot, ViewType.PROBLEMS);
bot.sleep(3 * TIME_1S);
+ SWTBotTreeItem[] warningTrees = ProblemsView
+ .getFilteredWarningsTreeItems(bot, "Multiple beans are eligible",
"/"
+ + PROJECT_NAME, "BrokenFarm.java", "CDI Problem");
+ assertTrue("Warnings node should contain only one record instead of "
+ + warningTrees.length + " records.", warningTrees.length == 1);
+ CDIUtil.resolveQuickFix(bot.tree(), warningTrees[0], bot, util);
+ assertFalse("No qualifier has been chosen, Add button should not be active",
+ bot.button("Add >").isEnabled());
+ assertFalse("No qualifier has been chosen, Finish button should not be
active",
+ bot.button("Finish").isEnabled());
+ SWTBotTable table = bot.table(0);
+ table.click(table.indexOf("Q1 - " + PACKAGE_NAME), 0);
+ assertTrue("Qualifier has been chosen, Add button should be active",
+ bot.button("Add >").isEnabled());
+ assertFalse("No qualifier has been chosen, Finish button should not be
active",
+ bot.button("Finish").isEnabled());
+ bot.clickButton("Add >");
+ assertTrue("Qualifier has been chosen, Finish button should be active",
+ bot.button("Finish").isEnabled());
+ bot.clickButton("Finish");
- SWTBotTreeItem[] warningTrees = ProblemsView.getFilteredWarningsTreeItems(bot,
"Managed bean B1 which",
- "/" + PROJECT_NAME , BEAN_NAME + ".java", "CDI
Problem");
-
- assertNotNull("Warnings node should contain the expected problem.",
warningTrees);
- assertTrue("Warnings node should contain only one record instead of " +
warningTrees.length + " records.",
- warningTrees.length == 1);
-
- CDIUtil.resolveQuickFix(bot.tree(), warningTrees[0], bot, util);
-
- SWTBotEclipseEditor eclEditor = ed.toTextEditor();
- assertTrue("Quick fix does not resolve issue properly.",
- eclEditor.getText().contains("import java.io.Serializable;"));
- warningTrees = ProblemsView.getFilteredWarningsTreeItems(bot, "Managed bean B1
which",
- "/" + PROJECT_NAME , BEAN_NAME + ".java", "CDI
Problem");
- assertTrue("Warnings should not contain resolved problem.",
warningTrees.length == 0);
- }
+ bot.sleep(2*TIME_1S);
+ util.waitForNonIgnoredJobs();
+ code = ed.toTextEditor().getText();
+ assertTrue(code.contains("@Inject @Q1 private Animal animal;"));
+ code = bot.editorByTitle("Dog.java").toTextEditor().getText();
+ assertTrue(code.contains("@Q1"));
+ warningTrees = ProblemsView
+ .getFilteredWarningsTreeItems(bot, "Multiple beans are eligible",
"/"
+ + PROJECT_NAME, "BrokenFarm.java", "CDI Problem");
+ assertTrue("Warnings node should not contain resolved problem.",
warningTrees.length == 0);
+ }
+
+ private void createAndCheckCDIProject() {
+ createCDIProject();
+ SWTBotTree tree = bot.tree();
+ assertTrue("Project " + PROJECT_NAME + " was not created
properly.",
+ SWTEclipseExt.treeContainsItemWithLabel(tree, PROJECT_NAME));
+ SWTBotTreeItem item = tree.getTreeItem(PROJECT_NAME);
+ item.expand();
+ CDIUtil.addCDISupport(tree, item, bot, util);
+ }
+
+ private void createCDIProject() {
+ new NewFileWizardAction().run()
+ .selectTemplate("Web", "Dynamic Web Project").next();
+ new DynamicWebProjectWizard().setProjectName(PROJECT_NAME).finish();
+ util.waitForNonIgnoredJobs();
+ }
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-08-16
11:51:32 UTC (rev 33969)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-08-16
12:42:16 UTC (rev 33970)
@@ -10,6 +10,8 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.SWTUtilExt;
import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
@@ -18,17 +20,15 @@
public static void addCDISupport(final SWTBotTree tree, SWTBotTreeItem item, SWTBotExt
bot, SWTUtilExt util) {
- nodeContextMenu(tree, item, "Configure",
- "Add CDI (Context and Dependency Injection) support...")
- .click();
+ nodeContextMenu(tree, item,
+ "Configure","Add CDI (Context and Dependency Injection)
support...").click();
bot.activeShell().bot().button("OK").click();
bot.sleep(2000);
util.waitForNonIgnoredJobs();
}
public static void resolveQuickFix(final SWTBotTree tree, SWTBotTreeItem item, SWTBotExt
bot, SWTUtilExt util) {
- nodeContextMenu(bot.tree(), item, "Quick Fix")
- .click();
+ nodeContextMenu(bot.tree(), item, "Quick Fix").click();
bot.activeShell().bot().button("Finish").click();
bot.sleep(2000);
util.waitForNonIgnoredJobs();
@@ -61,10 +61,108 @@
});
}
+ public static CDIWizard qualifier(String pkg, String name, boolean inherited,
+ boolean comments) {
+ return create(CDIWizardType.QUALIFIER, pkg, name, inherited, comments);
+ }
+
+
+ public static CDIWizard scope(String pkg, String name, boolean inherited,
+ boolean comments, boolean normalScope, boolean passivating) {
+ CDIWizard w = create(CDIWizardType.SCOPE, pkg, name, inherited,
+ comments);
+ w = w.setNormalScope(normalScope);
+ return normalScope ? w.setPassivating(passivating) : w;
+ }
+
+
+ public static CDIWizard binding(String pkg, String name, String target,
+ boolean inherited, boolean comments) {
+ CDIWizard w = create(CDIWizardType.INTERCEPTOR_BINDING, pkg, name,
+ inherited, comments);
+ return target != null ? w.setTarget(target) : w;
+ }
+
+
+ public static CDIWizard stereotype(String pkg, String name, String scope,
+ String target, boolean inherited, boolean named,
+ boolean alternative, boolean comments) {
+ CDIWizard w = create(CDIWizardType.STEREOTYPE, pkg, name, inherited,
+ comments).setAlternative(alternative).setNamed(named);
+ if (scope != null) {
+ w = w.setScope(scope);
+ }
+ return target != null ? w.setTarget(target) : w;
+ }
+
+
+ public static CDIWizard decorator(String pkg, String name, String intf, String
fieldName,
+ boolean isPublic, boolean isAbstract, boolean isFinal, boolean comments) {
+ CDIWizard w = create(CDIWizardType.DECORATOR, pkg, name, comments);
+ w =
w.addInterface(intf).setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract);
+ return fieldName != null ? w.setFieldName(fieldName) : w;
+ }
+
+
+ public static CDIWizard interceptor(String pkg, String name, String ibinding,
+ String superclass, String method, boolean comments) {
+ CDIWizard w = create(CDIWizardType.INTERCEPTOR, pkg, name, comments);
+ if (superclass != null) {
+ w = w.setSuperclass(superclass);
+ }
+ if (method != null) {
+ w = w.setMethodName(method);
+ }
+ return w.addIBinding(ibinding);
+ }
+
+
+ public static CDIWizard bean(String pkg, String name, boolean isPublic, boolean
isAbstract,
+ boolean isFinal, boolean comments, String named,
+ String interfaces, String scope, String qualifier) {
+ CDIWizard w = create(CDIWizardType.BEAN, pkg, name, comments);
+ if (named != null) {
+ w.setNamed(true);
+ if (!"".equals(named.trim())) {
+ w.setNamedName(named);
+ }
+ }
+ w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract);
+ if (interfaces != null && !"".equals(interfaces.trim())) {
+ w.addInterface(interfaces);
+ }
+ if (scope != null && !"".equals(scope.trim())) {
+ w.setScope(scope);
+ }
+ if (qualifier != null && !"".equals(qualifier.trim())) {
+ w.addQualifier(qualifier);
+ }
+ return w;
+ }
+
+ public static CDIWizard annLiteral(String pkg, String name, boolean isPublic, boolean
isAbstract,
+ boolean isFinal, boolean comments, String qualifier) {
+ assert qualifier != null && !"".equals(qualifier.trim()) :
"Qualifier has to be set";
+ CDIWizard w = create(CDIWizardType.ANNOTATION_LITERAL, pkg, name, comments);
+ return
w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract).addQualifier(qualifier);
+ }
+
+ private static CDIWizard create(CDIWizardType type, String pkg, String name,
+ boolean inherited, boolean comments) {
+ return create(type, pkg, name, comments).setInherited(inherited);
+ }
+
+ private static CDIWizard create(CDIWizardType type, String pkg, String name, boolean
comments) {
+ CDIWizard p = new NewCDIFileWizard(type).run();
+ return p.setPackage(pkg).setName(name).setGenerateComments(comments);
+ }
+
private static String readStream(InputStream is) {
// we don't care about performance in tests too much, so this should be
// OK
return new Scanner(is).useDelimiter("\\A").next();
}
+
+
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2011-08-16
11:51:32 UTC (rev 33969)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2011-08-16
12:42:16 UTC (rev 33970)
@@ -66,7 +66,7 @@
@Test
public void testQualifier() {
- qualifier("cdi", "Q1", false, false).finish();
+ CDIUtil.qualifier("cdi", "Q1", false, false).finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Q1.java").equals(ed.getTitle()));
@@ -78,7 +78,7 @@
assertFalse(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
- qualifier("cdi", "Q2", true, true).finish();
+ CDIUtil.qualifier("cdi", "Q2", true, true).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Q2.java").equals(ed.getTitle()));
@@ -93,7 +93,7 @@
@Test
public void testScope() {
- scope("cdi", "Scope1", true, false, true, false).finish();
+ CDIUtil.scope("cdi", "Scope1", true, false, true, false).finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Scope1.java").equals(ed.getTitle()));
@@ -107,7 +107,7 @@
assertTrue(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
- scope("cdi", "Scope2", false, true, true, true).finish();
+ CDIUtil.scope("cdi", "Scope2", false, true, true, true).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Scope2.java").equals(ed.getTitle()));
@@ -120,7 +120,7 @@
assertFalse(code.contains("@Inherited"));
assertTrue(code.startsWith("/**"));
- scope("cdi", "Scope3", false, true, false, false).finish();
+ CDIUtil.scope("cdi", "Scope3", false, true, false,
false).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("Scope3.java").equals(ed.getTitle()));
@@ -136,7 +136,7 @@
@Test
public void testIBinding() {
- CDIWizard w = binding("cdi", "B1", null, true, false);
+ CDIWizard w = CDIUtil.binding("cdi", "B1", null, true, false);
assertEquals(2, w.getTargets().size());
w.finish();
util.waitForNonIgnoredJobs();
@@ -150,7 +150,7 @@
assertTrue(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
- binding("cdi", "B2", "TYPE", false, true).finish();
+ CDIUtil.binding("cdi", "B2", "TYPE", false,
true).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("B2.java").equals(ed.getTitle()));
@@ -162,7 +162,7 @@
assertFalse(code.contains("@Inherited"));
assertTrue(code.startsWith("/**"));
- binding("cdi", "B3", "TYPE", false, true).finish();
+ CDIUtil.binding("cdi", "B3", "TYPE", false,
true).finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
assertTrue(("B3.java").equals(ed.getTitle()));
@@ -174,7 +174,7 @@
assertFalse(code.contains("@Inherited"));
assertTrue(code.startsWith("/**"));
- w = binding("cdi", "B4", "TYPE", true, false);
+ w = CDIUtil.binding("cdi", "B4", "TYPE", true, false);
w.addIBinding("cdi.B2");
w.finish();
util.waitForNonIgnoredJobs();
@@ -192,7 +192,7 @@
@Test
public void testStereotype() {
- CDIWizard w = stereotype("cdi", "S1", null, null, false, false,
false,
+ CDIWizard w = CDIUtil.stereotype("cdi", "S1", null, null, false,
false, false,
false);
assertEquals(9, w.getScopes().size());
assertEquals(5, w.getTargets().size());
@@ -210,7 +210,7 @@
assertFalse(code.contains("@Inherited"));
assertFalse(code.startsWith("/**"));
- stereotype("cdi", "S2", "@Scope3", "FIELD",
true, true, true, true)
+ CDIUtil.stereotype("cdi", "S2", "@Scope3",
"FIELD", true, true, true, true)
.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
@@ -226,7 +226,7 @@
assertTrue(code.contains("@Target({ FIELD })"));
assertTrue(code.startsWith("/**"));
- w = stereotype("cdi", "S3", null, null, false, false, true,
false);
+ w = CDIUtil.stereotype("cdi", "S3", null, null, false, false, true,
false);
w.addIBinding("cdi.B1");
w.addStereotype("cdi.S1");
w.finish();
@@ -249,7 +249,7 @@
@Test
public void testDecorator() {
- CDIWizard w = decorator("cdi", "",
"java.lang.Comparable", null, true, true, false, false);
+ CDIWizard w = CDIUtil.decorator("cdi", "",
"java.lang.Comparable", null, true, true, false, false);
w.finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new
SWTWorkbenchBot().editorByTitle("ComparableDecorator.java");
@@ -265,7 +265,7 @@
assertFalse(code.contains("final"));
assertFalse(code.startsWith("/**"));
- w = decorator("cdi", "", "java.util.Map",
"field", false, false, true, true);
+ w = CDIUtil.decorator("cdi", "", "java.util.Map",
"field", false, false, true, true);
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().editorByTitle("MapDecorator.java");
@@ -284,7 +284,7 @@
@Test
public void testInterceptor() {
- CDIWizard w = interceptor("cdi", "I1", "B2", null, null,
false);
+ CDIWizard w = CDIUtil.interceptor("cdi", "I1", "B2",
null, null, false);
w.finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new SWTWorkbenchBot().editorByTitle("I1.java");
@@ -298,7 +298,7 @@
assertFalse(code.contains("final"));
assertFalse(code.startsWith("/**"));
- w = interceptor("cdi", "I2", "B4",
"java.util.Date", "sample", true);
+ w = CDIUtil.interceptor("cdi", "I2", "B4",
"java.util.Date", "sample", true);
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().editorByTitle("I2.java");
@@ -329,7 +329,7 @@
@Test
public void testBean() {
- CDIWizard w = bean("cdi", "Bean1", true, true, false, false, null,
null, null, null);
+ CDIWizard w = CDIUtil.bean("cdi", "Bean1", true, true, false,
false, null, null, null, null);
w.finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
@@ -342,7 +342,7 @@
assertFalse(code.contains("final"));
assertFalse(code.startsWith("/**"));
- w = bean("cdi", "Bean2", false, false, true, true, "",
null, "@Dependent", null);
+ w = CDIUtil.bean("cdi", "Bean2", false, false, true, true,
"", null, "@Dependent", null);
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
@@ -356,7 +356,7 @@
assertTrue(code.contains("final class Bean2 {"));
assertTrue(code.startsWith("/**"));
- w = bean("cdi", "Bean3", true, false, false, true,
"TestedBean", null, "@Scope2", "Q1");
+ w = CDIUtil.bean("cdi", "Bean3", true, false, false, true,
"TestedBean", null, "@Scope2", "Q1");
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
@@ -374,7 +374,7 @@
@Test
public void testAnnLiteral() {
- CDIWizard w = annLiteral("cdi", "AnnL1", true, false, true, false,
"cdi.Q1");
+ CDIWizard w = CDIUtil.annLiteral("cdi", "AnnL1", true, false, true,
false, "cdi.Q1");
w.finish();
util.waitForNonIgnoredJobs();
SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
@@ -387,7 +387,7 @@
assertFalse(code.contains("abstract"));
assertFalse(code.startsWith("/**"));
- w = annLiteral("cdi", "AnnL2", false, true, false, true,
"Q2");
+ w = CDIUtil.annLiteral("cdi", "AnnL2", false, true, false, true,
"Q2");
w.finish();
util.waitForNonIgnoredJobs();
ed = new SWTWorkbenchBot().activeEditor();
@@ -401,103 +401,4 @@
assertTrue(code.contains("abstract"));
assertTrue(code.startsWith("/**"));
}
-
-
-
- private CDIWizard qualifier(String pkg, String name, boolean inherited,
- boolean comments) {
- return create(CDIWizardType.QUALIFIER, pkg, name, inherited, comments);
- }
-
-
- private CDIWizard scope(String pkg, String name, boolean inherited,
- boolean comments, boolean normalScope, boolean passivating) {
- CDIWizard w = create(CDIWizardType.SCOPE, pkg, name, inherited,
- comments);
- w = w.setNormalScope(normalScope);
- return normalScope ? w.setPassivating(passivating) : w;
- }
-
-
- private CDIWizard binding(String pkg, String name, String target,
- boolean inherited, boolean comments) {
- CDIWizard w = create(CDIWizardType.INTERCEPTOR_BINDING, pkg, name,
- inherited, comments);
- return target != null ? w.setTarget(target) : w;
- }
-
-
- private CDIWizard stereotype(String pkg, String name, String scope,
- String target, boolean inherited, boolean named,
- boolean alternative, boolean comments) {
- CDIWizard w = create(CDIWizardType.STEREOTYPE, pkg, name, inherited,
- comments).setAlternative(alternative).setNamed(named);
- if (scope != null) {
- w = w.setScope(scope);
- }
- return target != null ? w.setTarget(target) : w;
- }
-
-
- private CDIWizard decorator(String pkg, String name, String intf, String fieldName,
- boolean isPublic, boolean isAbstract, boolean isFinal, boolean comments) {
- CDIWizard w = create(CDIWizardType.DECORATOR, pkg, name, comments);
- w =
w.addInterface(intf).setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract);
- return fieldName != null ? w.setFieldName(fieldName) : w;
- }
-
-
- private CDIWizard interceptor(String pkg, String name, String ibinding,
- String superclass, String method, boolean comments) {
- CDIWizard w = create(CDIWizardType.INTERCEPTOR, pkg, name, comments);
- if (superclass != null) {
- w = w.setSuperclass(superclass);
- }
- if (method != null) {
- w = w.setMethodName(method);
- }
- return w.addIBinding(ibinding);
- }
-
-
- private CDIWizard bean(String pkg, String name, boolean isPublic, boolean isAbstract,
- boolean isFinal, boolean comments, String named,
- String interfaces, String scope, String qualifier) {
- CDIWizard w = create(CDIWizardType.BEAN, pkg, name, comments);
- if (named != null) {
- w.setNamed(true);
- if (!"".equals(named.trim())) {
- w.setNamedName(named);
- }
- }
- w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract);
- if (interfaces != null && !"".equals(interfaces.trim())) {
- w.addInterface(interfaces);
- }
- if (scope != null && !"".equals(scope.trim())) {
- w.setScope(scope);
- }
- if (qualifier != null && !"".equals(qualifier.trim())) {
- w.addQualifier(qualifier);
- }
- return w;
- }
-
- private CDIWizard annLiteral(String pkg, String name, boolean isPublic, boolean
isAbstract,
- boolean isFinal, boolean comments, String qualifier) {
- assert qualifier != null && !"".equals(qualifier.trim()) :
"Qualifier has to be set";
- CDIWizard w = create(CDIWizardType.ANNOTATION_LITERAL, pkg, name, comments);
- return
w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract).addQualifier(qualifier);
- }
-
- private CDIWizard create(CDIWizardType type, String pkg, String name,
- boolean inherited, boolean comments) {
- return create(type, pkg, name, comments).setInherited(inherited);
- }
-
- private CDIWizard create(CDIWizardType type, String pkg, String name, boolean comments)
{
- CDIWizard p = new NewCDIFileWizard(type).run();
- return p.setPackage(pkg).setName(name).setGenerateComments(comments);
- }
-
}