[jbosstools-commits] JBoss Tools SVN: r35515 - in trunk/cdi/tests/org.jboss.tools.cdi.bot.test: resources/cdi and 6 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Mon Oct 10 11:29:04 EDT 2011


Author: jjankovi
Date: 2011-10-10 11:29:04 -0400 (Mon, 10 Oct 2011)
New Revision: 35515

Added:
   trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B2.java.cdi
   trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/libraries/
   trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/libraries/seam-international.jar
   trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/libraries/seam-solder.jar
   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/PluginActivator.java
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/uiutils/actions/CDIBase.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/uiutils/wizards/CDIWizard.java
   trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java
Log:
New OpenOn CDI test, seam-solder and seam-international libraries were added

Added: 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	                        (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/B2.java.cdi	2011-10-10 15:29:04 UTC (rev 35515)
@@ -0,0 +1,19 @@
+package org.cdi.test;
+
+import java.net.URL;
+
+import javax.inject.Inject;
+
+import org.jboss.seam.solder.resourceLoader.Resource;
+
+public class B2 {
+
+	@Inject
+	@Resource("WEB-INF/beans.xml")
+	URL beansXml;
+	
+	public ResourceBean() {
+		// TODO Auto-generated constructor stub
+	}
+
+}
\ No newline at end of file

Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/libraries/seam-international.jar
===================================================================
(Binary files differ)


Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/libraries/seam-international.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/libraries/seam-solder.jar
===================================================================
(Binary files differ)


Property changes on: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/libraries/seam-solder.jar
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: 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	                        (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java	2011-10-10 15:29:04 UTC (rev 35515)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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;
+
+import org.jboss.tools.cdi.bot.test.wizard.CdiATWizardTest;
+import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * This test suite requires JBoss AS 6 or newer
+ * 
+ * System properties:
+ *  -Dswtbot.test.properties.file=$PATH
+ *  -Dusage_reporting_enabled=$BOOLEAN
+ *  
+ *  Format of swtbot.properties file:
+ *  SERVER=EAP|JBOSS_AS,<server version>,<jre version to run with>|default,<server home>
+ *  
+ *  Sample swtbot.properties file:
+ *
+ *  SERVER=JBOSS_AS,6.0,default,/home/lukas/latest/jboss-6.0.0.Final
+ *  JAVA=1.6,/space/java/sdk/jdk1.6.0_22
+ *  
+ *  
+ *  Suite duration: aprox. 12min
+ * 
+ * @author Lukas Jungmann
+ * @author Jaroslav Jankovic
+ */
+ at RunWith(RequirementAwareSuite.class)
+ at SuiteClasses({
+	CdiATWizardTest.class,	
+	})
+public class CDISmokeBotTests {
+}

Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/PluginActivator.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/PluginActivator.java	                        (rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/PluginActivator.java	2011-10-10 15:29:04 UTC (rev 35515)
@@ -0,0 +1,66 @@
+ /*******************************************************************************
+  * Copyright (c) 2007-2009 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
+  *
+  * Contributor:
+  *     Red Hat, Inc. - initial API and implementation
+  ******************************************************************************/
+package org.jboss.tools.cdi.bot.test;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class PluginActivator extends AbstractUIPlugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.jboss.tools.cdi.bot.test";
+
+	// The shared instance
+	private static PluginActivator plugin;
+
+	/**
+	 * The constructor
+	 */
+	public PluginActivator() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
+	 * )
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
+	 * )
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+		super.stop(context);
+	}
+
+	/**
+	 * Returns the shared instance
+	 * 
+	 * @return the shared instance
+	 */
+	public static PluginActivator getDefault() {
+		return plugin;
+	}
+
+}

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-10 15:20:49 UTC (rev 35514)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java	2011-10-10 15:29:04 UTC (rev 35515)
@@ -1,12 +1,20 @@
 package org.jboss.tools.cdi.bot.test.openon;
 
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+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.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.jboss.tools.ui.bot.ext.helper.TreeHelper;
 import org.jboss.tools.ui.bot.ext.types.ViewType;
 import org.junit.After;
 import org.junit.BeforeClass;
@@ -33,8 +41,7 @@
 @SuiteClasses({ CDIAllBotTests.class })
 public class CDIOpenOnTest extends CDIBase {
 
-	// private static final Logger LOGGER =
-	// Logger.getLogger(CDIQuickFixTest.class.getName());
+	private static final Logger LOGGER = Logger.getLogger(CDIQuickFixTest.class.getName());
 	private static final String PROJECT_NAME = "CDIProject3";
 	private static final String PACKAGE_NAME = "org.cdi.test";
 
@@ -52,7 +59,7 @@
 	public void testCreateProject() {
 		createAndCheckCDIProject(bot, util, projectExplorer, PROJECT_NAME);
 	}
-
+	
 	@Test
 	public void testInjectOpenOn() {
 
@@ -63,39 +70,112 @@
 		CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
 				.getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"),
 				false);
-		openOn("@Inject", "BrokenFarm.java", true);
+		openOn("@Inject", "BrokenFarm.java", "@Inject");
 		assertTrue("ERROR: redirected to " + getEd().getTitle(), getEd()
 				.getTitle().equals("Animal.java"));
 	}
-
+	
 	@Test
 	public void testBeansXMLClassesOpenOn() {
 
 		// https://issues.jboss.org/browse/JBIDE-7025
-		createComponent(CDICOMPONENT.BEANSXML, null, PROJECT_NAME + "/WebContent/WEB-INF", null);
+		createComponent(CDICOMPONENT.BEANSXML, null, PROJECT_NAME
+				+ "/WebContent/WEB-INF", null);
 		
-		createComponent(CDICOMPONENT.DECORATOR, "D1", PACKAGE_NAME, "java.util.Set");
+		createComponent(CDICOMPONENT.DECORATOR, "D1", PACKAGE_NAME,
+				"java.util.Set");
 		bot.editorByTitle("beans.xml").show();
-		bot.cTabItem("Source").activate();		
-		openOn(PACKAGE_NAME + ".D1", "beans.xml", false);
-		//assertTrue(bot.activeEditor().getTitle(), bot.activeEditor().getTitle().equals("D1.java"));
+		bot.cTabItem("Source").activate();
+		openOn(PACKAGE_NAME + ".D1", "beans.xml", null);
+		assertTrue("ERROR: redirected to " + getEd(),
+				getEd().getTitle().equals("D1.java"));
 		
-		createComponent(CDICOMPONENT.INTERCEPTOR, "Interceptor1", PACKAGE_NAME, null);
-		bot.editorByTitle("beans.xml").show();		
-		openOn(PACKAGE_NAME + ".Interceptor1", "beans.xml", false);
-		//assertTrue("ERROR: redirected to " + getEd(), getEd().getTitle().equals("Interceptor1.java"));
+		createComponent(CDICOMPONENT.INTERCEPTOR, "Interceptor1", PACKAGE_NAME,
+				null);
+		bot.editorByTitle("beans.xml").show();
+		openOn(PACKAGE_NAME + ".Interceptor1", "beans.xml", null);
+		assertTrue("ERROR: redirected to " + getEd(),
+					getEd().getTitle().equals("Interceptor1.java"));
+		
+		createComponent(CDICOMPONENT.BEAN, "B1", PACKAGE_NAME,
+				"alternative+beansxml");
+		bot.editorByTitle("beans.xml").show();
+		openOn(PACKAGE_NAME + ".B1", "beans.xml", null);
+		assertTrue("ERROR: redirected to " + getEd(),
+					getEd().getTitle().equals("B1.java"));
+		
+		createComponent(CDICOMPONENT.STEREOSCOPE, "S1", PACKAGE_NAME,
+				"alternative+beansxml");
+		bot.editorByTitle("beans.xml").show();
+		openOn(PACKAGE_NAME + ".S1", "beans.xml", null);
+		assertTrue("ERROR: redirected to " + getEd(),
+					getEd().getTitle().equals("S1.java"));		
+		
 	}
 
 	@Test
 	public void testResourceOpenOn() {
 
 		// https://issues.jboss.org/browse/JBIDE-8202
+		addLibrary("seam-solder.jar");
+				
+		createComponent(CDICOMPONENT.BEAN, "B2", PACKAGE_NAME, null);
+		CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
+				.getResourceAsStream("/resources/cdi/B2.java.cdi"), false);
+		openOn("beansXml", "B2.java", "Open Resource");
+		String destinationFile = getEd().getTitle();		
+		assertTrue("ERROR: redirected to " + destinationFile,
+					destinationFile.equals("beans.xml"));
+
+		moveFileInProjectExplorer("beans.xml", PROJECT_NAME + "/WebContent/WEB-INF",
+								  PROJECT_NAME + "/WebContent/META-INF");
+		LOGGER.info("bean.xml was moved to META-INF");
+		
+		setEd(bot.swtBotEditorExtByTitle("B2.java"));
+		CDIUtil.replaceInEditor(getEd(), bot, "WEB", "META");
+		openOn("beansXml", "B2.java", "Open Resource");
+		
+		destinationFile = getEd().getTitle();
+		assertTrue("ERROR: redirected to " + destinationFile,
+				   destinationFile.equals("beans.xml"));
+
 	}
-
+	
 	@Test
 	public void testGenericOpenOn() {
 
 		// https://issues.jboss.org/browse/JBIDE-8692
+
+		/*
+		 * copy files from project which is mentioned in JIRA, then it will be easy 
+		 */
 	}
+	
+	private void moveFileInProjectExplorer(String file, String sourceFolder, String destFolder) {
+		SWTBotTree tree = projectExplorer.bot().tree();
+		SWTBotTreeItem item = projectExplorer.selectTreeItem(file, sourceFolder.split("/"));
+		
+		CDIUtil.nodeContextMenu(tree, item, "Move...").click();
+		
+		assertFalse(bot.button("OK").isEnabled());
+		
+		tree = bot.tree();	
+		tree.collapseNode(destFolder.split("/")[0]);	
+		
+		TreeHelper.expandNode(bot, destFolder.split("/")).select();		
 
+		assertTrue(bot.button("OK").isEnabled());
+		bot.button("OK").click();		
+	}
+	
+	private void addLibrary(String libraryName) {
+		try {
+			addLibraryIntoProject(PROJECT_NAME, libraryName);
+			LOGGER.info("Library: \"" + libraryName + "\" copied");
+			addLibraryToProjectsClassPath(PROJECT_NAME, libraryName);
+		} catch (IOException exc) {
+			LOGGER.log(Level.SEVERE, "Error while adding seam solder library into project");
+		}		
+	}
+	
 }
\ No newline at end of file

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-10 15:20:49 UTC (rev 35514)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java	2011-10-10 15:29:04 UTC (rev 35515)
@@ -1,17 +1,28 @@
 package org.jboss.tools.cdi.bot.test.uiutils.actions;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.channels.FileChannel;
+
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
 import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
+import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
 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.PluginActivator;
 import org.jboss.tools.cdi.bot.test.uiutils.wizards.DynamicWebProjectWizard;
 import org.jboss.tools.ui.bot.ext.SWTBotExt;
 import org.jboss.tools.ui.bot.ext.SWTJBTExt;
 import org.jboss.tools.ui.bot.ext.SWTTestExt;
 import org.jboss.tools.ui.bot.ext.SWTUtilExt;
 import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+import org.jboss.tools.ui.bot.ext.types.IDELabel;
 import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
 
 public class CDIBase extends SWTTestExt {
@@ -48,7 +59,17 @@
 			String packageName, String necessaryParam) {
 		switch (component) {
 		case STEREOSCOPE:
-			CDIUtil.stereotype(packageName, name, null, null, false, false, false,
+			boolean alternative = false;
+			boolean regInBeansXml = false;
+			if (necessaryParam != null) {
+				if (necessaryParam.equals("alternative+beansxml")) {
+					alternative = true;
+					regInBeansXml = true;
+				} else if (necessaryParam.equals("alternative")) {
+					alternative = true;
+				}
+			}
+			CDIUtil.stereotype(packageName, name, null, null, false, false, alternative, regInBeansXml,
 					false).finish();
 			break;
 		case QUALIFIER:
@@ -58,7 +79,17 @@
 			CDIUtil.scope(packageName, name, false, false, true, false).finish();
 			break;
 		case BEAN:
-			CDIUtil.bean(packageName, name, true, false, false, false, null, null,
+			alternative = false;
+			regInBeansXml = false;
+			if (necessaryParam != null) {
+				if (necessaryParam.equals("alternative+beansxml")) {
+					alternative = true;
+					regInBeansXml = true;
+				} else if (necessaryParam.equals("alternative")) {
+					alternative = true;
+				}
+			}
+			CDIUtil.bean(packageName, name, true, false, false, false, alternative, regInBeansXml, null, null,
 					null, null).finish();
 			break;
 		case INTERCEPTOR:
@@ -108,32 +139,78 @@
 		util.waitForNonIgnoredJobs();
 	}
 	
-	public void openOn(String openOnString, String titleName, boolean moreOptions) {
+	public void openOn(String openOnString, String titleName, String chosenOption) {
 		SWTBotEditor ed = bot.editorByTitle(titleName);
 		ed.show();
 		ed.setFocus();		
 		int offset = openOnString.contains("@")?1:0;		
 		setEd(SWTJBTExt.selectTextInSourcePane(bot, titleName,
 				openOnString, offset, openOnString.length() - offset));
-		if (moreOptions) {			
+		if (chosenOption != null) {			
 			SWTBotMenu navigateMenu = bot.menu("Navigate");
 			bot.sleep(TIME_500MS);
 			navigateMenu.menu("Open Hyperlink").click();
 			bot.sleep(TIME_500MS);
 			SWTBotTable table = bot.activeShell().bot().table(0);
 			for (int i = 0; i < table.rowCount(); i++) {
-				if (table.getTableItem(i).getText().contains(openOnString)) {
+				if (table.getTableItem(i).getText().contains(chosenOption)) {
 					table.click(i, 0);					
 					break;
 				}
 			}							
 		} else {							
-			getEd().setFocus();
+			getEd().setFocus();	
 			bot.sleep(TIME_500MS);
-			//KeyboardHelper.pressKeyCodeUsingAWT(KeyEvent.VK_F3);			
+			getEd().pressShortcut(Keystrokes.F3);			
 		}		
 		bot.sleep(Timing.time1S());
 		setEd(bot.activeEditor().toTextEditor());		
 	}
+		
+	public void addLibraryToProjectsClassPath(String projectName, String libraryName) {
+		SWTBotTree tree = projectExplorer.bot().tree();
+			
+		ContextMenuHelper.prepareTreeItemForContextMenu(tree);
+	    new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Refresh",false)).click();
+		
+		ContextMenuHelper.prepareTreeItemForContextMenu(tree);
+	    new SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
+	    
+	    bot.tree().expandNode("Java Build Path").select();
+	    bot.tabItem("Libraries").activate();
+	    bot.button("Add JARs...").click();
+	    bot.sleep(TIME_500MS);
+	    String file = libraryName;
+	    bot.tree().expandNode(projectName).expandNode(file).select();
+	    
+	    bot.button(IDELabel.Button.OK).click();
+	    bot.sleep(TIME_1S);
+	    bot.button(IDELabel.Button.OK).click();
+	    bot.sleep(TIME_1S);
+	}
 
+	/*
+	 * copy library located in PROJECT_NAME/resources/libraries into project
+	 * libraryName must include extension: seam-solder.jar
+	 */
+	public static void addLibraryIntoProject(String projectName, String libraryName) throws IOException {
+		File in = null;
+		FileChannel inChannel = null;
+		FileChannel outChannel = null;
+		
+		
+		in = SWTUtilExt.getResourceFile(PluginActivator.PLUGIN_ID, "libraries", libraryName);
+		
+		File out = new File(Platform.getLocation() + File.separator + projectName + 
+				File.separator + File.separator + libraryName);
+			
+		inChannel = new FileInputStream(in).getChannel();
+		outChannel = new FileOutputStream(out).getChannel();
+
+		inChannel.transferTo(0, inChannel.size(),	outChannel);
+						
+		if (inChannel != null) inChannel.close();
+		if (outChannel != null) outChannel.close();		 	    	   
+	}
+
 }
\ No newline at end of file

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-10-10 15:20:49 UTC (rev 35514)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java	2011-10-10 15:29:04 UTC (rev 35515)
@@ -129,12 +129,15 @@
 
 	public static CDIWizard stereotype(String pkg, String name, String scope,
 			String target, boolean inherited, boolean named,
-			boolean alternative, boolean comments) {
+			boolean alternative, boolean regInBeansXML, boolean comments) {
 		CDIWizard w = create(CDIWizardType.STEREOTYPE, pkg, name, inherited,
 				comments).setAlternative(alternative).setNamed(named);
 		if (scope != null) {
 			w = w.setScope(scope);
 		}
+		if (alternative && regInBeansXML) {
+			w.setRegisterInBeansXml(regInBeansXML);
+		}
 		return target != null ? w.setTarget(target) : w;
 	}
 
@@ -163,7 +166,8 @@
 	}
 
 	public static CDIWizard bean(String pkg, String name, boolean isPublic,
-			boolean isAbstract, boolean isFinal, boolean comments,
+			boolean isAbstract, boolean isFinal, boolean comments, 
+			boolean alternative, boolean registerInBeansXML,
 			String named, String interfaces, String scope, String qualifier) {
 		CDIWizard w = create(CDIWizardType.BEAN, pkg, name, comments);
 		if (named != null) {
@@ -172,7 +176,7 @@
 				w.setNamedName(named);
 			}
 		}
-		w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract);
+		w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract).setAlternative(alternative);
 		if (interfaces != null && !"".equals(interfaces.trim())) {
 			w.addInterface(interfaces);
 		}
@@ -182,6 +186,9 @@
 		if (qualifier != null && !"".equals(qualifier.trim())) {
 			w.addQualifier(qualifier);
 		}
+		if (alternative && registerInBeansXML) {
+			w.setRegisterInBeansXml(registerInBeansXML);
+		}
 		return w;
 	}
 

Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java	2011-10-10 15:20:49 UTC (rev 35514)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java	2011-10-10 15:29:04 UTC (rev 35515)
@@ -15,16 +15,10 @@
 
 import org.eclipse.swt.widgets.Button;
 import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
-import org.eclipse.swtbot.swt.finder.results.Result;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
 import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
 
 public class CDIWizard extends Wizard {
 
@@ -120,6 +114,7 @@
 	public CDIWizard setAlternative(boolean set) {
 		switch (type) {
 		case STEREOTYPE:
+		case BEAN:
 			setCheckbox("Add @Alternative", set);
 			break;
 		default:
@@ -131,11 +126,34 @@
 	public boolean isAlternative() {
 		switch (type) {
 		case STEREOTYPE:
+		case BEAN:
 			return isCheckboxSet("Add @Alternative");
 		default:
 			return false;
 		}
 	}
+	
+	public CDIWizard setRegisterInBeansXml(boolean set) {
+		switch (type) {
+		case STEREOTYPE:
+		case BEAN:
+			setCheckbox("Register in beans.xml", set);
+			break;
+		default:
+			throw new UnsupportedOperationException();
+		}
+		return this;
+	}
+	
+	public boolean isRegisteredInBeansXML() {
+		switch (type) {
+		case STEREOTYPE:
+		case BEAN:
+			return isCheckboxSet("Register in beans.xml");
+		default:
+			return false;
+		}
+	}
 
 	public CDIWizard setNamed(boolean set) {
 		switch (type) {

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-10-10 15:20:49 UTC (rev 35514)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CdiATWizardTest.java	2011-10-10 15:29:04 UTC (rev 35515)
@@ -15,6 +15,7 @@
 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;
@@ -31,7 +32,7 @@
 
 @Require(perspective = "Java EE", server = @Server(state = ServerState.NotRunning, version = "6.0", operator = ">="))
 @RunWith(RequirementAwareSuite.class)
- at SuiteClasses({ CDIAllBotTests.class })
+ at SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
 public class CdiATWizardTest extends CDIBase {
 
 	private static final String PROJECT_NAME = "CDIProject1";
@@ -175,7 +176,7 @@
 
 	@Test
 	public void testStereotype() {
-		CDIWizard w = CDIUtil.stereotype("cdi", "S1", null, null, false, false, false,
+		CDIWizard w = CDIUtil.stereotype("cdi", "S1", null, null, false, false, false, false,
 				false);
 		assertEquals(9, w.getScopes().size());
 		assertEquals(5, w.getTargets().size());
@@ -193,7 +194,7 @@
 		assertFalse(code.contains("@Inherited"));
 		assertFalse(code.startsWith("/**"));
 
-		CDIUtil.stereotype("cdi", "S2", "@Scope3", "FIELD", true, true, true, true)
+		CDIUtil.stereotype("cdi", "S2", "@Scope3", "FIELD", true, true, true, false, true)
 				.finish();
 		util.waitForNonIgnoredJobs();
 		ed = new SWTWorkbenchBot().activeEditor();
@@ -209,7 +210,7 @@
 		assertTrue(code.contains("@Target({ FIELD })"));
 		assertTrue(code.startsWith("/**"));
 
-		w = CDIUtil.stereotype("cdi", "S3", null, null, false, false, true, false);
+		w = CDIUtil.stereotype("cdi", "S3", null, null, false, false, true, false, false);
 		w.addIBinding("cdi.B1");
 		w.addStereotype("cdi.S1");
 		w.finish();
@@ -312,7 +313,7 @@
 	
 	@Test
 	public void testBean() {
-		CDIWizard w = CDIUtil.bean("cdi", "Bean1", true, true, false, false, null, null, null, null);
+		CDIWizard w = CDIUtil.bean("cdi", "Bean1", true, true, false, false, false, false, null, null, null, null);
 		w.finish();
 		util.waitForNonIgnoredJobs();
 		SWTBotEditor ed = new SWTWorkbenchBot().activeEditor();
@@ -325,7 +326,7 @@
 		assertFalse(code.contains("final"));
 		assertFalse(code.startsWith("/**"));
 		
-		w = CDIUtil.bean("cdi", "Bean2", false, false, true, true, "", null, "@Dependent", null);
+		w = CDIUtil.bean("cdi", "Bean2", false, false, true, true, false, false, "", null, "@Dependent", null);
 		w.finish();
 		util.waitForNonIgnoredJobs();
 		ed = new SWTWorkbenchBot().activeEditor();
@@ -339,7 +340,7 @@
 		assertTrue(code.contains("final class Bean2 {"));
 		assertTrue(code.startsWith("/**"));
 
-		w = CDIUtil.bean("cdi", "Bean3", true, false, false, true, "TestedBean", null, "@Scope2", "Q1");
+		w = CDIUtil.bean("cdi", "Bean3", true, false, false, true, false, false, "TestedBean", null, "@Scope2", "Q1");
 		w.finish();
 		util.waitForNonIgnoredJobs();
 		ed = new SWTWorkbenchBot().activeEditor();



More information about the jbosstools-commits mailing list