Author: jjankovi
Date: 2011-10-24 11:37:18 -0400 (Mon, 24 Oct 2011)
New Revision: 35945
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java
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/CDIPerspectiveTest.java
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B1.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B2.java.cdi
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/DisposerProducerBean.java.cdi
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/InterDecor.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean2.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean3.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean4.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean2.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean3.java.cdi
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/CDISmokeBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/editor/BeansEditor.java
Log:
CDIPerspectiveTest added + huge refactoring all cdi bot tests
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B1.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B1.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B1.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.enterprise.context.SessionScoped;
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B2.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B2.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B2.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import java.net.URL;
Modified: 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 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/BrokenFarm.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.inject.Inject;
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/DisposerProducerBean.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/DisposerProducerBean.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/DisposerProducerBean.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.enterprise.inject.Disposes;
import javax.enterprise.inject.Produces;
Modified: 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 2011-10-24
15:28:50 UTC (rev 35944)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/Dog.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
public class Dog extends Animal {
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/InterDecor.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/InterDecor.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/InterDecor.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.enterprise.inject.Disposes;
public class InterDecor {
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
public class MyBean {
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean2.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean2.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean2.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.ejb.Singleton;
import javax.interceptor.AroundInvoke;
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean3.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean3.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean3.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.enterprise.event.Event;
import javax.inject.Inject;
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean4.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean4.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/MyBean4.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.enterprise.event.Observes;
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.enterprise.inject.Specializes;
import javax.interceptor.Interceptor;
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean2.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean2.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean2.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.decorator.Decorator;
import javax.decorator.Delegate;
import javax.enterprise.inject.Produces;
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean3.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean3.java.cdi 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/TestBean3.java.cdi 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,4 +1,4 @@
-package org.cdi.test;
+package cdi;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
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-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -11,12 +11,14 @@
package org.jboss.tools.cdi.bot.test;
import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
+import org.jboss.tools.cdi.bot.test.openon.CDIFindObserverForEventTest;
import org.jboss.tools.cdi.bot.test.openon.CDIOpenOnTest;
import org.jboss.tools.cdi.bot.test.quickfix.CDIQuickFixTest;
import org.jboss.tools.cdi.bot.test.seam3.CDISeam3Test;
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
-import org.jboss.tools.cdi.bot.test.wizard.CdiATWizardTest;
+import org.jboss.tools.cdi.bot.test.wizard.CDIATWizardTest;
+import org.jboss.tools.cdi.bot.test.wizard.CDIPerspectiveTest;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.BeforeClass;
@@ -45,18 +47,20 @@
* @author Jaroslav Jankovic
*/
@RunWith(RequirementAwareSuite.class)
-@SuiteClasses({
- CdiATWizardTest.class,
+@SuiteClasses({
+ CDIPerspectiveTest.class,
+ CDIATWizardTest.class,
BeansEditorTest.class,
CDIQuickFixTest.class,
CDIOpenOnTest.class,
+ CDIFindObserverForEventTest.class,
CDISeam3Test.class
})
-public class CDIAllBotTests extends CDIBase{
+public class CDIAllBotTests extends CDIBase {
/*
* init method "setup()" shows a project explorer view as default,
- * disable folding (due to easier source code editing)
+ * disable folding ( to easier source code editing)
*/
@BeforeClass
public static void setUpSuite() {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -12,7 +12,8 @@
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
-import org.jboss.tools.cdi.bot.test.wizard.CdiATWizardTest;
+import org.jboss.tools.cdi.bot.test.wizard.CDIATWizardTest;
+import org.jboss.tools.cdi.bot.test.wizard.CDIPerspectiveTest;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.BeforeClass;
@@ -41,7 +42,8 @@
*/
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({
- CdiATWizardTest.class,
+ CDIPerspectiveTest.class,
+ CDIATWizardTest.class,
})
public class CDISmokeBotTests extends CDIBase {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -28,6 +28,7 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.SWTBot;
import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
import org.jboss.tools.cdi.bot.test.uiutils.editor.BeansEditor;
@@ -36,6 +37,7 @@
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;
+import org.jboss.tools.ui.bot.ext.types.EntityType;
import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
import org.junit.After;
import org.junit.AfterClass;
@@ -51,6 +53,11 @@
import org.xml.sax.SAXException;
/**
+ * prerequisite - CDIAtWizardTest
+ *
+ *
+ * TO DO - copy resources into right location - PACKAGE_NAME
+ *
* @author Lukas Jungmann
* @author jjankovi
*/
@@ -61,16 +68,21 @@
private static final String descPath = "WebContent/WEB-INF/beans.xml";
private static final String project = "CDIProject";
- private static final String PACKAGE_NAME = "org.cdi.test";
+ private static final String PACKAGE_NAME = "cdi";
private static final Logger LOGGER = Logger.getLogger(BeansEditorTest.class.getName());
@BeforeClass
public static void prepare() {
+ if (!projectExists(project)) {
+ createAndCheckCDIProject(bot, util, projectExplorer, project);
+ createPackage(PACKAGE_NAME);
+ }
+
copyResource("resources/beans.xml", descPath);
copyResource("resources/Foo.jav_", "src/" + PACKAGE_NAME +
"/Foo.java");
- copyResource("resources/Bar.jav_", "src/" + PACKAGE_NAME +
"/Bar.java");
+ copyResource("resources/Bar.jav_", "src/" + PACKAGE_NAME +
"/Bar.java");
}
-
+
@AfterClass
public static void clean() {
removeObjectInProjectExplorer(PACKAGE_NAME, project + "/Java
Resources/src");
@@ -86,6 +98,13 @@
public void waitForJobs() {
util.waitForNonIgnoredJobs();
}
+
+ @Test
+ public void testClasses() {
+ addItem(Item.CLASS, PACKAGE_NAME + ".Foo");
+ addItem(Item.CLASS, PACKAGE_NAME + ".Bar");
+ removeItem(Item.CLASS, PACKAGE_NAME + ".Foo");
+ }
@Test
public void testInterceptors() {
@@ -94,21 +113,16 @@
addItem(Item.INTERCEPTOR, PACKAGE_NAME + ".I2");
}
+
@Test
public void testDecorators() {
addItem(Item.DECORATOR, PACKAGE_NAME + ".MapDecorator");
addItem(Item.DECORATOR, PACKAGE_NAME + ".ComparableDecorator");
removeItem(Item.DECORATOR, PACKAGE_NAME + ".ComparableDecorator");
}
+
@Test
- public void testClasses() {
- addItem(Item.CLASS, PACKAGE_NAME + ".Foo");
- addItem(Item.CLASS, PACKAGE_NAME + ".Bar");
- removeItem(Item.CLASS, PACKAGE_NAME + ".Foo");
- }
-
- @Test
public void testStereotypes() {
addItem(Item.STEREOTYPE, PACKAGE_NAME + ".S2");
addItem(Item.STEREOTYPE, PACKAGE_NAME + ".S3");
@@ -233,6 +247,16 @@
return false;
}
+ private static void createPackage(String packageName) {
+ projectExplorer.selectProject(project);
+ eclipse.createNew(EntityType.JAVA_PACKAGE);
+ SWTBot packageDialogBot = bot.activeShell().bot();
+ packageDialogBot.textWithLabel("Name:").typeText(packageName);
+ packageDialogBot.button("Finish").click();
+ util.waitForNonIgnoredJobs();
+ LOGGER.info("Package " + PACKAGE_NAME + " created");
+ }
+
private static void copyResource(String src, String target) {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProjects()[0];
IFile f = project.getFile(target);
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.openon;
+
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
+import org.jboss.tools.cdi.bot.test.quickfix.CDIQuickFixTest;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+* Test operates on CDI perspective
+*
+* @author Jaroslav Jankovic
+*/
+
+@Require(clearProjects = false, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class CDIFindObserverForEventTest extends CDIBase {
+
+ private static final Logger LOGGER =
Logger.getLogger(CDIFindObserverForEventTest.class.getName());
+ private static final String PROJECT_NAME = "CDIProject";
+ private static final String PACKAGE_NAME = "cdi";
+
+
+ @BeforeClass
+ public static void checkAndCreateProject() {
+ if (!projectExists(PROJECT_NAME)) {
+ createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
+ }
+ }
+
+ @After
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
+ }
+
+ //not implemented yet
+ @Test
+ public void testSimpleObserverFinding() {
+
+ }
+ //not implemented yet
+ @Test
+ public void testComplexObserverFinding() {
+
+ }
+
+}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -22,6 +22,7 @@
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
import org.junit.After;
import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -47,11 +48,13 @@
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";
-
- @After
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
+ private static final String PACKAGE_NAME = "cdi";
+
+ @BeforeClass
+ public static void checkAndCreateProject() {
+ if (!projectExists(PROJECT_NAME)) {
+ createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
+ }
}
@AfterClass
@@ -59,14 +62,11 @@
removeObjectInProjectExplorer("beans.xml", PROJECT_NAME +
"/WebContent/WEB-INF");
}
- @Test
- public void testCheckProjectExists() {
- if (!projectExists(PROJECT_NAME)) {
- createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
- }
- assertTrue(projectExists(PROJECT_NAME));
+ @After
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
}
-
+
@Test
public void testBeanInjectOpenOn() {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -23,6 +23,7 @@
import org.jboss.tools.ui.bot.ext.view.ProblemsView;
import org.junit.After;
import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -39,10 +40,23 @@
public class CDIQuickFixTest extends CDIBase {
private static final String PROJECT_NAME = "CDIProject";
- private static final String PACKAGE_NAME = "org.cdi.test";
+ private static final String PACKAGE_NAME = "cdi";
private static SWTBotTreeItem[] problemsTrees;
private static final String LINE_SEPARATOR =
System.getProperty("line.separator");
+
+ @BeforeClass
+ public static void checkAndCreateProject() {
+ if (!projectExists(PROJECT_NAME)) {
+ createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
+ }
+ }
+
+ @AfterClass
+ public static void clean() {
+ removeObjectInProjectExplorer(PACKAGE_NAME, PROJECT_NAME + "/Java
Resources/src");
+ }
+
/*
* check problems (warnings and errors in Problems View)
*/
@@ -52,20 +66,8 @@
util.waitForNonIgnoredJobs();
}
- @AfterClass
- public static void clean() {
- removeObjectInProjectExplorer(PACKAGE_NAME, PROJECT_NAME + "/Java
Resources/src");
- }
@Test
- public void testCheckProjectExists() {
- if (!projectExists(PROJECT_NAME)) {
- createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
- }
- assertTrue(projectExists(PROJECT_NAME));
- }
-
- @Test
public void testSerializableQF() {
@@ -89,6 +91,7 @@
* CDI Quick Fix test operates over validation
* concerning about Stereoscope component
*/
+
@Test
public void testStereoscopeQF() {
String className = "S1";
@@ -111,6 +114,7 @@
* CDI Quick Fix test operates over validation
* concerning about Qualifier component
*/
+
@Test
public void testQualifiersQF() {
String className = "Q2";
@@ -131,6 +135,7 @@
* CDI Quick Fix test operates over validation
* concerning about Scope component
*/
+
@Test
public void testScopeQF() {
String className = "Scope1";
@@ -172,6 +177,7 @@
* CDI Quick Fix test operates over validation
* concerning about Interceptors/Interceptor Binding/Decorator component
*/
+
@Test
public void testInterDecorQF() {
String className = "InterDecor";
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -24,6 +24,7 @@
import org.jboss.tools.ui.bot.ext.config.Annotations.Server;
import org.jboss.tools.ui.bot.ext.config.Annotations.ServerState;
import org.junit.After;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -42,21 +43,27 @@
private static final Logger LOGGER = Logger.getLogger(CDISeam3Test.class.getName());
private static final String PROJECT_NAME = "CDIProject";
private static final String PACKAGE_NAME = "org.cdi.test";
- private static final String GENERIC_PACKAGE_NAME = "org.cdi.generic";
+ private static final String GENERIC_PACKAGE_NAME = "cdi";
+
+ @BeforeClass
+ public static void checkAndCreateProject() {
+ if (!projectExists(PROJECT_NAME)) {
+ createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
+ }
+ addLibrary("seam-solder.jar");
+ checkLibrary("seam-solder.jar");
+ }
+
@After
public void waitForJobs() {
util.waitForNonIgnoredJobs();
}
+
@Test
- public void testCreateProjectWithSeamLibraries() {
- if (!projectExists(PROJECT_NAME)) {
- createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
- }
- assertTrue(projectExists(PROJECT_NAME));
- addLibrary("seam-solder.jar");
- checkLibrary("seam-solder.jar");
+ public void testCreateProjectWithSeamLibraries() {
+
}
/*
@@ -123,7 +130,7 @@
*/
}
- private void addLibrary(String libraryName) {
+ private static void addLibrary(String libraryName) {
try {
addLibraryIntoProject(PROJECT_NAME, libraryName);
LOGGER.info("Library: \"" + libraryName + "\" copied");
@@ -134,7 +141,7 @@
}
}
- private void checkLibrary(String libraryName) {
+ private static void checkLibrary(String libraryName) {
isLibraryInProjectClassPath(PROJECT_NAME, libraryName);
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -132,7 +132,7 @@
}
- public void createAndCheckCDIProject(SWTBotExt bot, SWTUtilExt util,
+ public static void createAndCheckCDIProject(SWTBotExt bot, SWTUtilExt util,
ProjectExplorer projectExplorer, String projectName) {
createCDIProject(util, projectName);
projectExplorer.selectProject(projectName);
@@ -142,20 +142,20 @@
addCDISupport(tree, item, bot, util);
}
- public void createCDIProject(SWTUtilExt util, String projectName) {
+ public static void createCDIProject(SWTUtilExt util, String projectName) {
new NewFileWizardAction().run()
.selectTemplate("Web", "Dynamic Web Project").next();
new DynamicWebProjectWizard().setProjectName(projectName).finish();
- util.waitForNonIgnoredJobs();
+ util.waitForNonIgnoredJobs();
}
- public void addCDISupport(final SWTBotTree tree, SWTBotTreeItem item,
+ public static void addCDISupport(final SWTBotTree tree, SWTBotTreeItem item,
SWTBotExt bot, SWTUtilExt util) {
CDIUtil.nodeContextMenu(tree, item, "Configure",
"Add CDI (Context and Dependency Injection) support...")
.click();
bot.activeShell().bot().button("OK").click();
- bot.sleep(Timing.time2S());
+ bot.sleep(Timing.time2S());
util.waitForNonIgnoredJobs();
}
@@ -168,9 +168,9 @@
openOnString, offset, openOnString.length() - offset));
if (chosenOption != null) {
SWTBotMenu navigateMenu = bot.menu("Navigate");
- bot.sleep(TIME_500MS);
+ bot.sleep(Timing.time500MS());
navigateMenu.menu("Open Hyperlink").click();
- bot.sleep(TIME_500MS);
+ bot.sleep(Timing.time500MS());
SWTBotTable table = bot.activeShell().bot().table(0);
for (int i = 0; i < table.rowCount(); i++) {
if (table.getTableItem(i).getText().contains(chosenOption)) {
@@ -180,14 +180,14 @@
}
} else {
getEd().setFocus();
- bot.sleep(TIME_500MS);
+ bot.sleep(Timing.time500MS());
getEd().pressShortcut(Keystrokes.F3);
}
bot.sleep(Timing.time1S());
setEd(bot.activeEditor().toTextEditor());
}
- public void addLibraryToProjectsClassPath(String projectName, String libraryName) {
+ public static void addLibraryToProjectsClassPath(String projectName, String libraryName)
{
SWTBotTree tree = projectExplorer.bot().tree();
ContextMenuHelper.prepareTreeItemForContextMenu(tree);
@@ -199,14 +199,14 @@
bot.tree().expandNode("Java Build Path").select();
bot.tabItem("Libraries").activate();
bot.button("Add JARs...").click();
- bot.sleep(TIME_500MS);
+ bot.sleep(Timing.time500MS());
String file = libraryName;
bot.tree().expandNode(projectName).expandNode(file).select();
bot.button(IDELabel.Button.OK).click();
- bot.sleep(TIME_1S);
+ bot.sleep(Timing.time1S());
bot.button(IDELabel.Button.OK).click();
- bot.sleep(TIME_1S);
+ bot.sleep(Timing.time1S());
}
/*
@@ -261,7 +261,7 @@
+ projectName,libraryInProject);
bot.button(IDELabel.Button.CANCEL).click();
- bot.sleep(TIME_1S);
+ bot.sleep(Timing.time1S());
}
public void moveFileInProjectExplorer(String file, String sourceFolder, String
destFolder) {
@@ -291,10 +291,10 @@
bot.button("OK").click();
- bot.sleep(TIME_1S*2);
+ bot.sleep(Timing.time2S());
}
- public boolean projectExists(String projectName) {
+ public static boolean projectExists(String projectName) {
SWTBotTree tree = projectExplorer.bot().tree();
boolean projectExists = false;
try {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/editor/BeansEditor.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/editor/BeansEditor.java 2011-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/editor/BeansEditor.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.cdi.bot.test.uiutils.editor;
+import org.apache.log4j.Level;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
@@ -17,6 +18,7 @@
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.ui.IEditorReference;
import org.jboss.tools.ui.bot.ext.SWTBotExt;
import org.jboss.tools.ui.bot.ext.widgets.SWTBotMultiPageEditor;
@@ -70,7 +72,11 @@
}
private BeansEditor modify(Item item, String name, String actionLabel, DialogHandler h)
{
- SWTBotTree tree = bot.tree();
+ SWTBotTree tree = bot.tree(1);
+ for (SWTBotTreeItem ti:tree.getAllItems()) {
+ log.setLevel(Level.FATAL);
+ log.fatal(ti.getText());
+ }
tree.expandNode(ROOT_NODE, item.getNode()).select().click();
selectItem(item, name);
getItemButton(item, actionLabel).click();
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIATWizardTest.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -0,0 +1,396 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2011 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.wizard;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
+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.wizards.CDIWizard;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * @author Lukas Jungmann
+ * @author jjankovi
+ */
+@Require(clearProjects = false, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
+public class CDIATWizardTest extends CDIBase {
+
+ private static final String PROJECT_NAME = "CDIProject";
+ private static final String PACKAGE_NAME = "cdi";
+ private static final Logger L = Logger.getLogger(CDIATWizardTest.class.getName());
+
+ @After
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
+ }
+
+ @BeforeClass
+ public static void checkAndCreateProject() {
+ if (!projectExists(PROJECT_NAME)) {
+ createAndCheckCDIProject(bot, util, projectExplorer,PROJECT_NAME);
+ }
+ }
+
+ @Test
+ public void testQualifier() {
+ CDIUtil.qualifier(PACKAGE_NAME, "Q1", false, false).finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Q1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Qualifier"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ CDIUtil.qualifier(PACKAGE_NAME, "Q2", true, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Q2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Qualifier"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testScope() {
+ CDIUtil.scope(PACKAGE_NAME, "Scope1", true, false, true, false).finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Scope1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@NormalScope"));
+ assertFalse(code.contains("@Scope"));
+ assertFalse(code.contains("passivating"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ CDIUtil.scope(PACKAGE_NAME, "Scope2", false, true, true, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Scope2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@NormalScope(passivating = true)"));
+ assertFalse(code.contains("@Scope"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+
+ CDIUtil.scope(PACKAGE_NAME, "Scope3", false, true, false, false).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Scope3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Scope"));
+ assertFalse(code.contains("@NormalScope"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testIBinding() {
+ CDIWizard w = CDIUtil.binding(PACKAGE_NAME, "B1", null, true, false);
+ assertEquals(2, w.getTargets().size());
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD })"));
+ assertTrue(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ CDIUtil.binding(PACKAGE_NAME, "B2", "TYPE", false, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+
+ CDIUtil.binding(PACKAGE_NAME, "B3", "TYPE", false, true).finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertFalse(code.contains("@Inherited"));
+ assertTrue(code.startsWith("/**"));
+
+ w = CDIUtil.binding(PACKAGE_NAME, "B4", "TYPE", true, false);
+ w.addIBinding(PACKAGE_NAME + ".B2");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("B4.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@InterceptorBinding"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertTrue(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+ assertTrue(code.contains("@B2"));
+ }
+
+ @Test
+ public void testStereotype() {
+ CDIWizard w = CDIUtil.stereotype(PACKAGE_NAME, "S1", null, null, false,
false, false, false,
+ false);
+ assertEquals(9, w.getScopes().size());
+ assertEquals(5, w.getTargets().size());
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("S1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Stereotype"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
+ assertFalse(code.contains("@Named"));
+ assertFalse(code.contains("@Alternative"));
+ assertFalse(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+
+ CDIUtil.stereotype(PACKAGE_NAME, "S2", "@Scope3",
"FIELD", true, true, true, false, true)
+ .finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("S2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Stereotype"));
+ assertTrue(code.contains("@Scope3"));
+ assertTrue(code.contains("@Named"));
+ assertTrue(code.contains("@Alternative"));
+ assertTrue(code.contains("@Inherited"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ FIELD })"));
+ assertTrue(code.startsWith("/**"));
+
+ w = CDIUtil.stereotype(PACKAGE_NAME, "S3", null, null, false, false, true,
false, false);
+ w.addIBinding(PACKAGE_NAME + ".B1");
+ w.addStereotype(PACKAGE_NAME + ".S1");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("S3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Stereotype"));
+ assertFalse(code.contains("@Scope3"));
+ assertFalse(code.contains("@Named"));
+ assertTrue(code.contains("@Alternative"));
+ assertTrue(code.contains("@B1"));
+ assertTrue(code.contains("@S1"));
+ assertTrue(code.contains("@Retention(RUNTIME)"));
+ assertTrue(code.contains("@Target({ TYPE })"));
+ assertFalse(code.contains("@Inherited"));
+ assertFalse(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testDecorator() {
+ CDIWizard w = CDIUtil.decorator(PACKAGE_NAME, "",
"java.lang.Comparable", null, true, true, false, false);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new
SWTWorkbenchBot().editorByTitle("ComparableDecorator.java");
+ assertTrue(("ComparableDecorator.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Decorator"));
+ assertTrue(code.contains("abstract class"));
+ assertTrue(code.contains("@Delegate"));
+ assertTrue(code.contains("@Inject"));
+ assertTrue(code.contains("@Any"));
+ assertTrue(code.contains("private Comparable<T> comparable;"));
+ assertFalse(code.contains("final"));
+ assertFalse(code.startsWith("/**"));
+
+ w = CDIUtil.decorator(PACKAGE_NAME, "", "java.util.Map",
"field", false, false, true, true);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().editorByTitle("MapDecorator.java");
+ assertTrue(("MapDecorator.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@Decorator"));
+ assertFalse(code.contains("abstract"));
+ assertTrue(code.contains("@Delegate"));
+ assertTrue(code.contains("@Inject"));
+ assertTrue(code.contains("@Any"));
+ assertTrue(code.contains("private Map<K, V> field;"));
+ assertTrue(code.contains("final class"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testInterceptor() {
+ CDIWizard w = CDIUtil.interceptor(PACKAGE_NAME, "I1", "B2", null,
null, false);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().editorByTitle("I1.java");
+ assertTrue(("I1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@B2"));
+ assertTrue(code.contains("@Interceptor"));
+ assertTrue(code.contains("@AroundInvoke"));
+ assertTrue(code.contains("public Object manage(InvocationContext ic) throws
Exception {"));
+ assertFalse(code.contains("final"));
+ assertFalse(code.startsWith("/**"));
+
+ w = CDIUtil.interceptor(PACKAGE_NAME, "I2", "B4",
"java.util.Date", "sample", true);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().editorByTitle("I2.java");
+ assertTrue(("I2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("@B4"));
+ assertTrue(code.contains("@Interceptor"));
+ assertTrue(code.contains("@AroundInvoke"));
+ assertTrue(code.contains("public Object sample(InvocationContext ic) throws
Exception {"));
+ assertFalse(code.contains("final"));
+ assertTrue(code.startsWith("/**"));
+ assertTrue(code.contains("extends Date"));
+ }
+
+ @Test
+ public void testBeansXml() {
+ CDIWizard w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
+ w.setSourceFolder(PROJECT_NAME + "/WebContent/WEB-INF");
+ assertFalse(w.canFinish());
+ w.setSourceFolder(PROJECT_NAME + "/src/" +
PACKAGE_NAME.replaceAll(".", "/"));
+ assertTrue(w.canFinish());
+ w.cancel();
+ w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
+ assertFalse(w.canFinish());
+ w.cancel();
+ }
+
+ @Test
+ public void testBean() {
+ CDIWizard w = CDIUtil.bean(PACKAGE_NAME, "Bean1", true, true, false, false,
false, false, null, null, null, null);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Bean1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("public abstract class Bean1 {"));
+ assertFalse(code.contains("@Named"));
+ assertFalse(code.contains("final"));
+ assertFalse(code.startsWith("/**"));
+
+ w = CDIUtil.bean(PACKAGE_NAME, "Bean2", false, false, true, true, false,
false, "", null, "@Dependent", null);
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Bean2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("@Named"));
+ assertFalse(code.contains("@Named("));
+ assertTrue(code.contains("@Dependent"));
+ assertTrue(code.contains("final class Bean2 {"));
+ assertTrue(code.startsWith("/**"));
+
+ w = CDIUtil.bean(PACKAGE_NAME, "Bean3", true, false, false, true, false,
false, "TestedBean", null, "@Scope2", "Q1");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("Bean3.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.fine(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("@Named(\"TestedBean\")"));
+ assertTrue(code.contains("@Scope2"));
+ assertTrue(code.contains("@Q1"));
+ assertTrue(code.contains("public class Bean3 {"));
+ assertFalse(code.contains("final"));
+ assertTrue(code.startsWith("/**"));
+ }
+
+ @Test
+ public void testAnnLiteral() {
+ CDIWizard w = CDIUtil.annLiteral(PACKAGE_NAME, "AnnL1", true, false, true,
false, PACKAGE_NAME + ".Q1");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("AnnL1.java").equals(ed.getTitle()));
+ String code = ed.toTextEditor().getText();
+ L.info(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("public final class AnnL1 extends
AnnotationLiteral<Q1> implements Q1"));
+ assertTrue(code.contains("public static final Q1 INSTANCE = new AnnL1();"));
+ assertFalse(code.contains("abstract"));
+ assertFalse(code.startsWith("/**"));
+
+ w = CDIUtil.annLiteral(PACKAGE_NAME, "AnnL2", false, true, false, true,
"Q2");
+ w.finish();
+ util.waitForNonIgnoredJobs();
+ ed = new SWTWorkbenchBot().activeEditor();
+ assertTrue(("AnnL2.java").equals(ed.getTitle()));
+ code = ed.toTextEditor().getText();
+ L.info(code);
+ assertTrue(code.contains("package cdi;"));
+ assertTrue(code.contains("abstract class AnnL2 extends AnnotationLiteral<Q2>
implements Q2 {"));
+ assertTrue(code.contains("public static final Q2 INSTANCE = new AnnL2();"));
+ assertFalse(code.substring(code.indexOf("final") +
5).contains("final"));
+ assertTrue(code.contains("abstract"));
+ assertTrue(code.startsWith("/**"));
+ }
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -0,0 +1,148 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.cdi.bot.test.wizard;
+
+
+import java.util.logging.Logger;
+
+import org.eclipse.swt.SWTException;
+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.CDISmokeBotTests;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+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;
+import org.jboss.tools.ui.bot.ext.types.PerspectiveType;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+* Test operates on CDI perspective
+*
+* @author Jaroslav Jankovic
+*/
+
+@Require(clearProjects = false, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
+public class CDIPerspectiveTest extends CDIBase {
+
+ private static final Logger LOGGER =
Logger.getLogger(CDIPerspectiveTest.class.getName());
+ private static final String PROJECT_NAME = "CDIProject";
+ private enum CDIARTIFACTS {
+ BEAN, QUALIFIER, STEREOTYPE, SCOPE, INTERBINDING, INTERCEPTOR, DECORATOR, ANNOTLITERAL,
BEANSXML
+ }
+
+
+ @BeforeClass
+ public static void checkAndCreateProject() {
+ if (!projectExists(PROJECT_NAME)) {
+ createAndCheckCDIProject(bot, util, projectExplorer, PROJECT_NAME);
+ }
+ eclipse.openPerspective(PerspectiveType.CDI);
+ LOGGER.info("CDI perspective selected");
+ bot.sleep(Timing.time2S());
+ }
+
+ @Test
+ public void testCDIArtifactBeanWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.BEAN));
+ }
+
+ @Test
+ public void testCDIArtifactAnnotationLiteralWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.ANNOTLITERAL));
+ }
+
+ @Test
+ public void testCDIArtifactBeanXMLWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.BEANSXML));
+ }
+
+ @Test
+ public void testCDIArtifactDecoratorWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.DECORATOR));
+ }
+
+ @Test
+ public void testCDIArtifactQualifierWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.QUALIFIER));
+ }
+
+ @Test
+ public void testCDIArtifactScopeWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.SCOPE));
+ }
+
+ @Test
+ public void testCDIArtifactStereoscopeWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIARTIFACTS.STEREOTYPE));
+ }
+
+ private boolean openCDIArtifactsWizard(CDIARTIFACTS artifact) {
+
+ SWTBotTree tree = packageExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(PROJECT_NAME);
+ item.expand();
+ boolean artifactWizardExists = true;
+ try {
+ CDIUtil.nodeContextMenu(tree, item, "New",
getArtifactMenuItem(artifact)).click();
+ bot.sleep(Timing.time500MS());
+ bot.activeShell().bot().button("Cancel").click();
+
+ } catch (SWTException exc) {
+ artifactWizardExists = false;
+ }
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+ return artifactWizardExists;
+ }
+
+ private String getArtifactMenuItem(CDIARTIFACTS artifact) {
+ switch (artifact) {
+ case ANNOTLITERAL:
+ return "Annotation Literal";
+ case BEAN:
+ return "Bean";
+ case BEANSXML:
+ return "File beans.xml";
+ case DECORATOR:
+ return "Decorator";
+ case INTERBINDING:
+ return "Interceptor Binding Annotation";
+ case INTERCEPTOR:
+ return "Interceptor";
+ case QUALIFIER:
+ return "Qualifier Annotation";
+ case SCOPE:
+ return "Scope Annotation";
+ case STEREOTYPE:
+ return "Stereotype Annotation";
+ default:
+ return null;
+ }
+ }
+
+}
Deleted:
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-10-24
15:28:50 UTC (rev 35944)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java 2011-10-24
15:37:18 UTC (rev 35945)
@@ -1,393 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.cdi.bot.test.wizard;
-
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
-import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIBase;
-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.wizards.CDIWizard;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
-import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
-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;
-import org.junit.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * @author Lukas Jungmann
- * @author jjankovi
- */
-@Require(perspective = "Java EE", server = @Server(state =
ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
-public class CdiATWizardTest extends CDIBase {
-
- private static final String PROJECT_NAME = "CDIProject";
- private static final String PACKAGE_NAME = "org.cdi.test";
- private static final Logger L = Logger.getLogger(CdiATWizardTest.class.getName());
-
- @After
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- }
-
- @Test
- public void createProject() {
- createAndCheckCDIProject(bot, util, projectExplorer, PROJECT_NAME);
- }
-
- @Test
- public void testQualifier() {
- CDIUtil.qualifier(PACKAGE_NAME, "Q1", false, false).finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Q1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Qualifier"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
- assertFalse(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
-
- CDIUtil.qualifier(PACKAGE_NAME, "Q2", true, true).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Q2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Qualifier"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, PARAMETER, FIELD })"));
- assertTrue(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
- }
-
- @Test
- public void testScope() {
- CDIUtil.scope(PACKAGE_NAME, "Scope1", true, false, true, false).finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Scope1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@NormalScope"));
- assertFalse(code.contains("@Scope"));
- assertFalse(code.contains("passivating"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
- assertTrue(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
-
- CDIUtil.scope(PACKAGE_NAME, "Scope2", false, true, true, true).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Scope2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@NormalScope(passivating = true)"));
- assertFalse(code.contains("@Scope"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
- assertFalse(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
-
- CDIUtil.scope(PACKAGE_NAME, "Scope3", false, true, false, false).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Scope3.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Scope"));
- assertFalse(code.contains("@NormalScope"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
- assertFalse(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
- }
-
- @Test
- public void testIBinding() {
- CDIWizard w = CDIUtil.binding(PACKAGE_NAME, "B1", null, true, false);
- assertEquals(2, w.getTargets().size());
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("B1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@InterceptorBinding"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD })"));
- assertTrue(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
-
- CDIUtil.binding(PACKAGE_NAME, "B2", "TYPE", false, true).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("B2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@InterceptorBinding"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE })"));
- assertFalse(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
-
- CDIUtil.binding(PACKAGE_NAME, "B3", "TYPE", false, true).finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("B3.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@InterceptorBinding"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE })"));
- assertFalse(code.contains("@Inherited"));
- assertTrue(code.startsWith("/**"));
-
- w = CDIUtil.binding(PACKAGE_NAME, "B4", "TYPE", true, false);
- w.addIBinding(PACKAGE_NAME + ".B2");
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("B4.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@InterceptorBinding"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE })"));
- assertTrue(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
- assertTrue(code.contains("@B2"));
- }
-
- @Test
- public void testStereotype() {
- CDIWizard w = CDIUtil.stereotype(PACKAGE_NAME, "S1", null, null, false,
false, false, false,
- false);
- assertEquals(9, w.getScopes().size());
- assertEquals(5, w.getTargets().size());
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("S1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Stereotype"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE, METHOD, FIELD })"));
- assertFalse(code.contains("@Named"));
- assertFalse(code.contains("@Alternative"));
- assertFalse(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
-
- CDIUtil.stereotype(PACKAGE_NAME, "S2", "@Scope3",
"FIELD", true, true, true, false, true)
- .finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("S2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Stereotype"));
- assertTrue(code.contains("@Scope3"));
- assertTrue(code.contains("@Named"));
- assertTrue(code.contains("@Alternative"));
- assertTrue(code.contains("@Inherited"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ FIELD })"));
- assertTrue(code.startsWith("/**"));
-
- w = CDIUtil.stereotype(PACKAGE_NAME, "S3", null, null, false, false, true,
false, false);
- w.addIBinding(PACKAGE_NAME + ".B1");
- w.addStereotype(PACKAGE_NAME + ".S1");
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("S3.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Stereotype"));
- assertFalse(code.contains("@Scope3"));
- assertFalse(code.contains("@Named"));
- assertTrue(code.contains("@Alternative"));
- assertTrue(code.contains("@B1"));
- assertTrue(code.contains("@S1"));
- assertTrue(code.contains("@Retention(RUNTIME)"));
- assertTrue(code.contains("@Target({ TYPE })"));
- assertFalse(code.contains("@Inherited"));
- assertFalse(code.startsWith("/**"));
- }
-
- @Test
- public void testDecorator() {
- CDIWizard w = CDIUtil.decorator(PACKAGE_NAME, "",
"java.lang.Comparable", null, true, true, false, false);
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new
SWTWorkbenchBot().editorByTitle("ComparableDecorator.java");
- assertTrue(("ComparableDecorator.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Decorator"));
- assertTrue(code.contains("abstract class"));
- assertTrue(code.contains("@Delegate"));
- assertTrue(code.contains("@Inject"));
- assertTrue(code.contains("@Any"));
- assertTrue(code.contains("private Comparable<T> comparable;"));
- assertFalse(code.contains("final"));
- assertFalse(code.startsWith("/**"));
-
- w = CDIUtil.decorator(PACKAGE_NAME, "", "java.util.Map",
"field", false, false, true, true);
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().editorByTitle("MapDecorator.java");
- assertTrue(("MapDecorator.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@Decorator"));
- assertFalse(code.contains("abstract"));
- assertTrue(code.contains("@Delegate"));
- assertTrue(code.contains("@Inject"));
- assertTrue(code.contains("@Any"));
- assertTrue(code.contains("private Map<K, V> field;"));
- assertTrue(code.contains("final class"));
- assertTrue(code.startsWith("/**"));
- }
-
- @Test
- public void testInterceptor() {
- CDIWizard w = CDIUtil.interceptor(PACKAGE_NAME, "I1", "B2", null,
null, false);
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().editorByTitle("I1.java");
- assertTrue(("I1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@B2"));
- assertTrue(code.contains("@Interceptor"));
- assertTrue(code.contains("@AroundInvoke"));
- assertTrue(code.contains("public Object manage(InvocationContext ic) throws
Exception {"));
- assertFalse(code.contains("final"));
- assertFalse(code.startsWith("/**"));
-
- w = CDIUtil.interceptor(PACKAGE_NAME, "I2", "B4",
"java.util.Date", "sample", true);
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().editorByTitle("I2.java");
- assertTrue(("I2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("@B4"));
- assertTrue(code.contains("@Interceptor"));
- assertTrue(code.contains("@AroundInvoke"));
- assertTrue(code.contains("public Object sample(InvocationContext ic) throws
Exception {"));
- assertFalse(code.contains("final"));
- assertTrue(code.startsWith("/**"));
- assertTrue(code.contains("extends Date"));
- }
-
- @Test
- public void testBeansXml() {
- CDIWizard w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
- w.setSourceFolder(PROJECT_NAME + "/WebContent/WEB-INF");
- assertFalse(w.canFinish());
- w.setSourceFolder(PROJECT_NAME + "/src/" +
PACKAGE_NAME.replaceAll(".", "/"));
- assertTrue(w.canFinish());
- w.cancel();
- w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
- assertFalse(w.canFinish());
- w.cancel();
- }
-
- @Test
- public void testBean() {
- CDIWizard w = CDIUtil.bean(PACKAGE_NAME, "Bean1", true, true, false, false,
false, false, null, null, null, null);
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Bean1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("package org.cdi.test;"));
- assertTrue(code.contains("public abstract class Bean1 {"));
- assertFalse(code.contains("@Named"));
- assertFalse(code.contains("final"));
- assertFalse(code.startsWith("/**"));
-
- w = CDIUtil.bean(PACKAGE_NAME, "Bean2", false, false, true, true, false,
false, "", null, "@Dependent", null);
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Bean2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("package org.cdi.test;"));
- assertTrue(code.contains("@Named"));
- assertFalse(code.contains("@Named("));
- assertTrue(code.contains("@Dependent"));
- assertTrue(code.contains("final class Bean2 {"));
- assertTrue(code.startsWith("/**"));
-
- w = CDIUtil.bean(PACKAGE_NAME, "Bean3", true, false, false, true, false,
false, "TestedBean", null, "@Scope2", "Q1");
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("Bean3.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.fine(code);
- assertTrue(code.contains("package org.cdi.test;"));
- assertTrue(code.contains("@Named(\"TestedBean\")"));
- assertTrue(code.contains("@Scope2"));
- assertTrue(code.contains("@Q1"));
- assertTrue(code.contains("public class Bean3 {"));
- assertFalse(code.contains("final"));
- assertTrue(code.startsWith("/**"));
- }
-
- @Test
- public void testAnnLiteral() {
- CDIWizard w = CDIUtil.annLiteral(PACKAGE_NAME, "AnnL1", true, false, true,
false, PACKAGE_NAME + ".Q1");
- w.finish();
- util.waitForNonIgnoredJobs();
- SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("AnnL1.java").equals(ed.getTitle()));
- String code = ed.toTextEditor().getText();
- L.info(code);
- assertTrue(code.contains("package org.cdi.test;"));
- assertTrue(code.contains("public final class AnnL1 extends
AnnotationLiteral<Q1> implements Q1"));
- assertTrue(code.contains("public static final Q1 INSTANCE = new AnnL1();"));
- assertFalse(code.contains("abstract"));
- assertFalse(code.startsWith("/**"));
-
- w = CDIUtil.annLiteral(PACKAGE_NAME, "AnnL2", false, true, false, true,
"Q2");
- w.finish();
- util.waitForNonIgnoredJobs();
- ed = new SWTWorkbenchBot().activeEditor();
- assertTrue(("AnnL2.java").equals(ed.getTitle()));
- code = ed.toTextEditor().getText();
- L.info(code);
- assertTrue(code.contains("package org.cdi.test;"));
- assertTrue(code.contains("abstract class AnnL2 extends AnnotationLiteral<Q2>
implements Q2 {"));
- assertTrue(code.contains("public static final Q2 INSTANCE = new AnnL2();"));
- assertFalse(code.substring(code.indexOf("final") +
5).contains("final"));
- assertTrue(code.contains("abstract"));
- assertTrue(code.startsWith("/**"));
- }
-}