Author: jjankovi
Date: 2012-04-05 06:03:26 -0400 (Thu, 05 Apr 2012)
New Revision: 40065
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorFromWebBeanTest.java
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorCreatingTest.java
Log:
new cdi bot test implemented
Deleted:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorCreatingTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorCreatingTest.java 2012-04-05
10:02:44 UTC (rev 40064)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorCreatingTest.java 2012-04-05
10:03:26 UTC (rev 40065)
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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.decorator;
-
-import org.jboss.tools.cdi.bot.test.CDITestBase;
-
-/**
- * Test operates on creating new decorator
- *
- * @author Jaroslav Jankovic
- *
- */
-
-public class DecoratorCreatingTest extends CDITestBase {
-
- //https://issues.jboss.org/browse/JBIDE-3136
-
- @Override
- public String getProjectName() {
- return "CDIDecoratorCreating";
- }
-
-
-
-}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorFromWebBeanTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorFromWebBeanTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/decorator/DecoratorFromWebBeanTest.java 2012-04-05
10:03:26 UTC (rev 40065)
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2010-2012 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.decorator;
+
+import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.jboss.tools.cdi.bot.test.CDIConstants;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.editor.BeansEditor;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.NewCDIFileWizard;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBase;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test operates on creating new decorator from web bean
+ * implementing some existing interface
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+
+public class DecoratorFromWebBeanTest extends CDITestBase {
+
+ private final String ACCOUNT = "Account";
+
+ private final String ACCOUNT_JAVA = ACCOUNT + ".java";
+
+ private final String ACCOUNT_DECORATOR = "AccountDecorator";
+
+ private final String ACCOUNT_DECORATOR_JAVA = ACCOUNT_DECORATOR + ".java";
+
+ @Override
+ public String getProjectName() {
+ return "DecoratorFromWebBean";
+ }
+
+ @Before
+ public void prepareWorkspace() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ importCDITestProject("/resources/projects/" +
+ getProjectName(), getProjectName());
+ eclipse.cleanAllProjects();
+ }
+ }
+
+ @After
+ public void waitForJobs() {
+ projectExplorer.deleteProject(getProjectName(), true);
+ }
+
+ @Test
+ public void testCreatingDecoratorWithMenu() {
+
+ String[] path = (getProjectName() + "/" + CDIConstants.SRC
+ + "/" + getPackageName()).split("/");
+
+ packageExplorer.show();
+ packageExplorer.selectTreeItem(ACCOUNT_JAVA, path);
+
+ CDIWizardBase decoratorWizard = new NewCDIFileWizard(
+ CDIWizardType.DECORATOR).run();
+
+ assertTrue(decoratorWizard.getName().equals(ACCOUNT_DECORATOR));
+
+ assertTrue(decoratorWizard.getDecoratedInterfaces().size() == 1);
+
+ assertTrue(decoratorWizard.getDecoratedInterfaces().
+ get(0).equals(getPackageName() + "." + ACCOUNT));
+
+ assertTrue(decoratorWizard.canFinish());
+
+ decoratorWizard.finishWithWait();
+
+ packageExplorer.openFile(getProjectName(),
+ CDIConstants.WEB_INF_BEANS_XML_PATH.split("/"));
+
+ SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
+ BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
+ be.activatePage("Source");
+ setEd(bot.activeEditor().toTextEditor());
+
+ assertTrue(getEd().getText().contains("\n <decorators>\n " +
+ "<class>cdi.AccountDecorator</class>\n </decorators>"));
+
+ setEd(packageExplorer.openFile(getProjectName(), CDIConstants.SRC,
+ getPackageName(), ACCOUNT_DECORATOR_JAVA).toTextEditor());
+
+ assertTrue(getEd().getText().contains("@Decorator"));
+ assertTrue(getEd().getText().contains("@Inject\n\t@Delegate\n\t@Any" +
+ "\n\tprivate Account account;"));
+ assertTrue(getEd().getText().contains("BigDecimal getBalance()"));
+ assertTrue(getEd().getText().contains("User getOwner()"));
+ assertTrue(getEd().getText().contains("void withdraw(BigDecimal amount)"));
+ assertTrue(getEd().getText().contains("void deposit(BigDecimal amount)"));
+
+
+ }
+
+ @Test
+ public void testCreatingDecoratorWithWizard() {
+
+ CDIWizardBase decoratorWizard = new NewCDIFileWizard(
+ CDIWizardType.DECORATOR).run();
+ decoratorWizard.setName(ACCOUNT_DECORATOR).
+ setPackage(getPackageName()).
+ addInterface(getPackageName() + "." + ACCOUNT).
+ finishWithWait();
+
+ packageExplorer.openFile(getProjectName(),
+ CDIConstants.WEB_INF_BEANS_XML_PATH.split("/"));
+
+ SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
+ BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
+ be.activatePage("Source");
+ setEd(bot.activeEditor().toTextEditor());
+
+ assertTrue(getEd().getText().contains("\n <decorators>\n " +
+ "<class>cdi.AccountDecorator</class>\n </decorators>"));
+
+ setEd(packageExplorer.openFile(getProjectName(), CDIConstants.SRC,
+ getPackageName(), ACCOUNT_DECORATOR_JAVA).toTextEditor());
+
+ assertTrue(getEd().getText().contains("@Decorator"));
+ assertTrue(getEd().getText().contains("@Inject\n\t@Delegate\n\t@Any" +
+ "\n\tprivate Account account;"));
+ assertTrue(getEd().getText().contains("BigDecimal getBalance()"));
+ assertTrue(getEd().getText().contains("User getOwner()"));
+ assertTrue(getEd().getText().contains("void withdraw(BigDecimal amount)"));
+ assertTrue(getEd().getText().contains("void deposit(BigDecimal amount)"));
+
+ }
+
+}