Author: jjankovi
Date: 2011-11-28 10:48:05 -0500 (Mon, 28 Nov 2011)
New Revision: 36701
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithEmptyTag.xml.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithStereotype.xml.cdi
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.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/jsf/JSFTestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIWizardHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/JSFWebProjectWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java
Log:
BeansXML completion test added
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithEmptyTag.xml.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithEmptyTag.xml.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithEmptyTag.xml.cdi 2011-11-28
15:48:05 UTC (rev 36701)
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<beans
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://jboss.org/schema/cdi/beans_1_0.xsd">
+
+ <>
+
+</beans>
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithStereotype.xml.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithStereotype.xml.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/beansXML/beansXmlWithStereotype.xml.cdi 2011-11-28
15:48:05 UTC (rev 36701)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<beans
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://jboss.org/schema/cdi/beans_1_0.xsd">
+
+<alternatives>
+ <stereotype>Component</stereotype>
+</alternatives>
+
+</beans>
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -10,9 +10,9 @@
******************************************************************************/
package org.jboss.tools.cdi.bot.test;
+import org.jboss.tools.cdi.bot.test.beansxml.BeansXMLCompletionTest;
import org.jboss.tools.cdi.bot.test.beansxml.BeansXMLValidationTest;
import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
-import org.jboss.tools.cdi.bot.test.jsf.NamedRefactoringTest;
import org.jboss.tools.cdi.bot.test.openon.FindObserverForEventTest;
import org.jboss.tools.cdi.bot.test.openon.OpenOnTest;
import org.jboss.tools.cdi.bot.test.quickfix.BeanValidationQuickFixTest;
@@ -49,7 +49,7 @@
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
- * Suite duration: aprox. 22min
+ * Suite duration: aprox. 24min
*
* @author Lukas Jungmann
* @author Jaroslav Jankovic
@@ -57,23 +57,23 @@
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({
// PerspectiveTest.class,
-// ConfigurationPresetTest.class,
-// FacetTest.class,
-// WizardTest.class,
-// BeansEditorTest.class,
- NamedRefactoringTest.class,
-// BeansXMLValidationTest.class,
-// BeansXMLCompletionTest.class,
-// StereotypeValidationQuickFixTest.class,
-// QualifierValidationQuickFixTest.class,
-// ScopeValidationQuickFixTest.class,
-// BeanValidationQuickFixTest.class,
-// InterceptorValidationQuickFixTest.class,
-// DecoratorValidationQuickFixTest.class,
-// IBindingValidationQuickFixTest.class,
-// OpenOnTest.class,
-// FindObserverForEventTest.class,
-// Seam3Test.class
+ ConfigurationPresetTest.class,
+ FacetTest.class,
+ WizardTest.class,
+ BeansEditorTest.class,
+// NamedRefactoringTest.class,
+ BeansXMLValidationTest.class,
+ BeansXMLCompletionTest.class,
+ StereotypeValidationQuickFixTest.class,
+ QualifierValidationQuickFixTest.class,
+ ScopeValidationQuickFixTest.class,
+ BeanValidationQuickFixTest.class,
+ InterceptorValidationQuickFixTest.class,
+ DecoratorValidationQuickFixTest.class,
+ IBindingValidationQuickFixTest.class,
+ OpenOnTest.class,
+ FindObserverForEventTest.class,
+ Seam3Test.class
})
public class CDIAllBotTests extends CDITestBase {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -11,20 +11,23 @@
package org.jboss.tools.cdi.bot.test.beansxml;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.logging.Logger;
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
import org.jboss.tools.cdi.bot.test.CDITestBase;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
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.junit.Ignore;
+import org.jboss.tools.ui.bot.ext.helper.ContentAssistHelper;
+import org.jboss.tools.ui.bot.ext.parts.ContentAssistBot;
+import org.jboss.tools.ui.bot.ext.parts.SWTBotEditorExt;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;
@@ -45,6 +48,21 @@
private static final Logger LOGGER = Logger
.getLogger(BeansXMLCompletionTest.class.getName());
+
+ private static final List<String> BEANS_XML_TAGS = Arrays.asList(
+ "alternatives", "decorators", "interceptors");
+ private static final List<String> INTERCEPTOR_NAMES = Arrays.asList(
+ "I1", "I2", "I3");
+ private static final List<String> DECORATORS_NAMES = Arrays.asList(
+ "D1", "D2", "D3");
+ private static final List<String> ALTERNATIVES_NAMES = Arrays.asList(
+ "A1", "A2", "A3");
+ private static final List<String> STEREOTYPES_NAMES = Arrays.asList(
+ "S1", "S2", "S3");
+ private static final String BEANS_XML = "beans.xml";
+ private static final String CLASS_END_TAG = "</class>";
+ private static final String STEREOTYPE_END_TAG = "</stereotype>";
+
@Override
public String getProjectName() {
@@ -53,97 +71,146 @@
@Test
public void testPossibleCompletionInBeansXML() {
- beansHelper.createClearBeansXML(getPackageName());
+ beansHelper.createClearBeansXML(getProjectName());
LOGGER.info("Clear beans.xml was created");
- List<String> autoCompletion = getAutoCompletion(3, 0, "<");
-
- assertTrue("Error: Size of auto completion proposals should be 3 " +
- "instead of " + autoCompletion.size(), autoCompletion.size() == 3);
+ checkAutoCompletion(3, 0, "<>", BEANS_XML, BEANS_XML_TAGS);
}
- @Ignore
+
@Test
public void testInterceptorsCompletion() {
- prepareInterceptors();
-
- beansHelper.createClearBeansXML(getPackageName());
- LOGGER.info("Clear beans.xml was created");
+ wizard.createCDIComponents(CDIWizardType.INTERCEPTOR, getPackageName(),
+ INTERCEPTOR_NAMES, null, false);
+ beansHelper.createBeansXMLWithInterceptor(getProjectName(), getPackageName(), null);
+ LOGGER.info("Beans.xml with interceptors tag was created");
+
+ List<String> proposalList = getProposalList(BEANS_XML, CLASS_END_TAG, 0, 0);
+ for (String interceptor : INTERCEPTOR_NAMES) {
+ assertTrue(proposalList.contains(interceptor + " - " + getPackageName()));
+ }
}
- @Ignore
+
@Test
public void testDecoratorsCompletion() {
- prepareDecorators();
-
- beansHelper.createClearBeansXML(getPackageName());
- LOGGER.info("Clear beans.xml was created");
+ wizard.createCDIComponents(CDIWizardType.DECORATOR, getPackageName(),
+ DECORATORS_NAMES, "java.util.Set", false);
+
+ beansHelper.createBeansXMLWithDecorator(getProjectName(), getPackageName(), null);
+ LOGGER.info("Beans.xml with decorators tag was created");
+
+ List<String> proposalList = getProposalList(BEANS_XML, CLASS_END_TAG, 0, 0);
+ for (String decorator : DECORATORS_NAMES) {
+ assertTrue(proposalList.contains(decorator + " - " + getPackageName()));
+ }
}
- @Ignore
+
@Test
- public void testAlternativesCompletion() {
+ public void testStereotypesCompletion() {
- prepareAlternatives();
-
- beansHelper.createClearBeansXML(getPackageName());
- LOGGER.info("Clear beans.xml was created");
+ wizard.createCDIComponents(CDIWizardType.STEREOTYPE, getPackageName(),
+ STEREOTYPES_NAMES, "alternative", false);
+
+ beansHelper.createBeansXMLWithStereotype(getProjectName(), getPackageName(), null);
+ LOGGER.info("Beans.xml with stereotype tag was created");
+
+ List<String> proposalList = getProposalList(BEANS_XML, STEREOTYPE_END_TAG, 0,
0);
+ for (String stereotype : STEREOTYPES_NAMES) {
+ assertTrue(proposalList.contains(stereotype + " - " + getPackageName()));
+ }
}
-
- private void prepareInterceptors() {
-
- wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, "Interceptor1",
- getPackageName(), null);
-
- wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, "Interceptor2",
- getPackageName(), null);
-
- wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, "Interceptor3",
- getPackageName(), null);
-
- }
- private void prepareDecorators() {
-
- wizard.createCDIComponent(CDIWizardType.DECORATOR, "Decorator1",
- getPackageName(), "java.util.Set");
+ @Test
+ public void testAlternativesCompletion() {
- wizard.createCDIComponent(CDIWizardType.DECORATOR, "Decorator2",
- getPackageName(), "java.util.Set");
+ wizard.createCDIComponents(CDIWizardType.BEAN, getPackageName(),
+ ALTERNATIVES_NAMES, "alternative", false);
+
+ beansHelper.createBeansXMLWithAlternative(getProjectName(), getPackageName(), null);
+ LOGGER.info("Beans.xml with alternative tag was created");
- wizard.createCDIComponent(CDIWizardType.DECORATOR, "Decorator3",
- getPackageName(), "java.util.Set");
+ List<String> proposalList = getProposalList(BEANS_XML, CLASS_END_TAG, 0, 0);
+ for (String alternative : ALTERNATIVES_NAMES) {
+ assertTrue(proposalList.contains(alternative + " - " + getPackageName()));
+ }
}
- private void prepareAlternatives() {
+ @Test
+ public void testNonSupportedComponentCompletion() {
- wizard.createCDIComponent(CDIWizardType.BEAN, "Alternative1",
- getPackageName(), "alternative");
+ String[] components = {"AL1", "Q1", "B1",
"IB1", "Sc1"};
- wizard.createCDIComponent(CDIWizardType.BEAN, "Alternative2",
- getPackageName(), "alternative");
+ wizard.createCDIComponent(CDIWizardType.ANNOTATION_LITERAL, components[0],
+ getPackageName(), null);
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, components[1],
+ getPackageName(), null);
+ wizard.createCDIComponent(CDIWizardType.BEAN, components[2],
+ getPackageName(), null);
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR_BINDING, components[3],
+ getPackageName(), null);
+ wizard.createCDIComponent(CDIWizardType.SCOPE, components[4],
+ getPackageName(), null);
- wizard.createCDIComponent(CDIWizardType.BEAN, "Alternative3",
- getPackageName(), "alternative");
+ beansHelper.createClearBeansXMLWithEmptyTag(getProjectName());
+ LOGGER.info("Clear beans.xml with empty tag was created");
+ List<String> proposalList = getProposalList(BEANS_XML, "<>", 1,
0);
+ List<String> nonSupportedComponents = Arrays.asList(components);
+
+ for (String nonSupportedComponent : nonSupportedComponents) {
+ for (String proposalOption : proposalList) {
+ assertFalse((nonSupportedComponent + " - " + getPackageName()).
+ equals(proposalOption));
+ }
+ }
+
}
-
- //not complete yet
- private List<String> getAutoCompletion(int row, int column, String text) {
- List<String> listOfCompletion = new ArrayList<String>();
+
+ /**
+ * Method checks auto completion proposals. First, it
+ * types provided text on location provided by parameters.
+ * Then checks all items in proposal list by
+ * ContentAssistHelper.checkContentAssistContent() method.
+ * At the end, it removes inserted text(due to possible formating error)
+ * @param row
+ * @param column
+ * @param text
+ * @param expectedProposalList
+ */
+ private void checkAutoCompletion(int row, int column, String text, String editorTitle,
+ List<String> expectedProposalList) {
getEd().navigateTo(row, column);
- bot.sleep(Timing.time500MS());
getEd().typeText(text);
- bot.sleep(Timing.time500MS());
- getEd().pressShortcut(Keystrokes.CTRL, Keystrokes.SPACE);
+ ContentAssistHelper.checkContentAssistContent(bot,
+ editorTitle, text, 1, 0, expectedProposalList);
+ editResourceUtil.replaceInEditor(text, "");
+ }
+
+ /**
+ * Method returns proposal list for given text on given position
+ * @param editorTitle
+ * @param textToSelect
+ * @param selectionOffset
+ * @param selectionLength
+ * @return
+ */
+ private List<String> getProposalList(String editorTitle, String textToSelect, int
selectionOffset,
+ int selectionLength) {
+ SWTJBTExt.selectTextInSourcePane(bot,
+ editorTitle, textToSelect, selectionOffset, selectionLength,
+ 0);
+
bot.sleep(Timing.time1S());
- for (int i = 0; i < bot.table().rowCount(); i++) {
- listOfCompletion.add(bot.table().getTableItem(i).getText());
- }
- return listOfCompletion;
+
+ SWTBotEditorExt editor = SWTTestExt.bot.swtBotEditorExtByTitle(editorTitle);
+ ContentAssistBot contentAssist = editor.contentAssist();
+ List<String> currentProposalList = contentAssist.getProposalList();
+ return currentProposalList;
}
}
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-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -48,7 +48,7 @@
* @author Lukas Jungmann
* @author jjankovi
*/
-@Require(clearProjects = true, perspective = "Java EE",
+@Require(clearProjects = false, perspective = "Java EE",
server = @Server(state = ServerState.NotRunning,
version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/JSFTestBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/JSFTestBase.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/JSFTestBase.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -11,28 +11,40 @@
package org.jboss.tools.cdi.bot.test.jsf;
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.jboss.tools.cdi.bot.test.CDITestBase;
import org.jboss.tools.cdi.bot.test.annotations.JSFEnvironment;
import org.jboss.tools.cdi.bot.test.annotations.JSFTemplate;
import org.jboss.tools.cdi.bot.test.uiutils.actions.NewJSFProjectWizard;
import org.jboss.tools.cdi.bot.test.uiutils.actions.NewXHTMLFileWizard;
import org.jboss.tools.cdi.bot.test.uiutils.wizards.XHTMLDialogWizard;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
import org.jboss.tools.ui.bot.ext.Timing;
import org.junit.Before;
public class JSFTestBase extends CDITestBase {
+ private static final Logger LOGGER = Logger.getLogger(JSFTestBase.class.getName());
+
private JSFEnvironment env = JSFEnvironment.JSF_20;
+ private JSFTemplate template = JSFTemplate.BLANK_LIBS;
+
public JSFEnvironment getEnv() {
return env;
}
+ public JSFTemplate getTemplate() {
+ return template;
+ }
+
@Before
public void checkAndCreateProject() {
if (!projectHelper.projectExists(getProjectName())) {
- createJSFProjectWithCDISupport(getProjectName(), getEnv());
+ createJSFProjectWithCDISupport(getProjectName(), getEnv(), getTemplate());
}
}
@@ -44,20 +56,46 @@
util.waitForNonIgnoredJobs();
setEd(bot.activeEditor().toTextEditor());
}
+
+ protected void contextMenuForTextInEditor(final String text,
+ final String... menu) {
+ assert menu.length > 0;
+ SWTJBTExt.selectTextInSourcePane(bot, getEd().getTitle(),
+ text, 0, text.length());
+ bot.sleep(Timing.time2S());
+
+ getEd().toTextEditor().contextMenu(menu[0]);
+ bot.sleep(Timing.time3S());
+ util.waitForNonIgnoredJobs();
+
+ }
- private void createJSFProjectWithCDISupport(String projectName, JSFEnvironment env) {
+ private void createJSFProjectWithCDISupport(String projectName, JSFEnvironment env,
+ JSFTemplate template) {
- createJSFProject(projectName, env);
+ createJSFProject(projectName, env, template);
projectHelper.addCDISupport(projectName);
}
- private void createJSFProject(String projectName, JSFEnvironment env) {
+ private void createJSFProject(String projectName, JSFEnvironment env,
+ JSFTemplate template) {
new NewJSFProjectWizard().run().
setName(getProjectName()).
setEnvironment(env).
- setJSFTemplate(JSFTemplate.BLANK_LIBS).finish();
- util.waitForNonIgnoredJobs();
+ setJSFTemplate(template).
+ finish();
+ /*
+ * workaround for non Web Perspective, click No button
+ * to not change perspective to Web Perspectives
+ *
+ */
+ try {
+ bot.button("No").click();
+ } catch (WidgetNotFoundException exc) {
+ log.info("There is no dialog to change perspective.");
+ }
+ util.waitForNonIgnoredJobs();
}
}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/jsf/NamedRefactoringTest.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -14,7 +14,6 @@
import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
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;
@@ -23,26 +22,26 @@
import org.junit.runners.Suite.SuiteClasses;
/**
- * Test operates on EL named refactoring
+ * Test operates on @Named refactoring
*
* @author Jaroslav Jankovic
*
*/
-@Require(clearProjects = true, perspective = "Web Development",
+@Require(clearProjects = true, perspective = "Java EE",
server = @Server(state = ServerState.NotRunning,
version = "6.0", operator = ">="))
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({ CDIAllBotTests.class })
public class NamedRefactoringTest extends JSFTestBase {
-
+
@Override
public String getProjectName() {
return "CDIRefactoring";
}
@Test
- public void testNamedAnnotation() {
+ public void testNamedAnnotationRefactor() {
wizard.createCDIComponent(CDIWizardType.BEAN, "ManagedBean",
getPackageName(), null);
editResourceUtil.replaceClassContentByResource(NamedRefactoringTest.class.
@@ -52,8 +51,10 @@
editResourceUtil.replaceClassContentByResource(NamedRefactoringTest.class.
getResourceAsStream("/resources/jsf/index.xhtml.cdi"), false);
+ bot.editorByTitle("ManagedBean.java").show();
+ setEd(bot.activeEditor().toTextEditor());
+ contextMenuForTextInEditor("@Named(\"bean\")", "Open
With", "Other...");
-
}
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -19,11 +19,11 @@
public abstract class AbstractValidationProvider implements ValidationErrorProvider {
- protected Map<String, ArrayList<String>> validationErrors = null;
- protected ArrayList<String> warningsForAnnotationType = null;
- protected ArrayList<String> errorsForAnnotationType = null;
- protected ArrayList<CDIAnnotationsType> warningsAnnotation = null;
- protected ArrayList<CDIAnnotationsType> errorsAnnotation = null;
+ protected static Map<String, ArrayList<String>> validationErrors = null;
+ protected static ArrayList<String> warningsForAnnotationType = null;
+ protected static ArrayList<String> errorsForAnnotationType = null;
+ protected static ArrayList<CDIAnnotationsType> warningsAnnotation = null;
+ protected static ArrayList<CDIAnnotationsType> errorsAnnotation = null;
public AbstractValidationProvider() {
validationErrors = new LinkedHashMap<String, ArrayList<String>>();
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -57,4 +57,5 @@
* @return
*/
ArrayList<CDIAnnotationsType> getAllErrorsAnnotation();
+
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/BeansXMLValidationHelper.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -16,6 +16,7 @@
import org.jboss.tools.cdi.bot.test.annotations.BeansXMLValidationErrors;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
import org.jboss.tools.cdi.bot.test.openon.OpenOnTest;
+import org.jboss.tools.ui.bot.ext.Timing;
import org.jboss.tools.ui.bot.ext.view.ProblemsView;
/**
@@ -121,9 +122,20 @@
}
/**
+ * Methods creates beans.xml with empty tag <> for entered project.
+ * @param projectName
+ */
+ public void createClearBeansXMLWithEmptyTag(String projectName) {
+
+ createBeansXMLWithContent(projectName, "/resources/beansXML/" +
+ "beansXmlWithEmptyTag.xml.cdi");
+ }
+
+ /**
* Methods creates beans.xml with interceptor tags in it for entered project.
* Package and interceptor component name which should be showed in tag is
- * determined by parameters
+ * determined by parameters. If className is null, then Component text will be
+ * removed
* @param projectName
* @param packageName
* @param className
@@ -132,15 +144,21 @@
String className) {
createBeansXMLWithContent(projectName, "/resources/beansXML/" +
- "beansXmlWithInterceptor.xml.cdi");
- editResourceUtil.replaceInEditor("Component", packageName + "." +
className);
+ "beansXmlWithInterceptor.xml.cdi");
+ if (className == null || className.length() == 0) {
+ editResourceUtil.replaceInEditor("<class>Component</class>",
+ "<class></class>");
+ } else {
+ editResourceUtil.replaceInEditor("Component", packageName + "." +
className);
+ }
}
/**
* Methods creates beans.xml with decorator tags in it for entered project.
* Package and decorator component name which should be showed in tag is
- * determined by parameters
+ * determined by parameters. If className is null, then Component text will be
+ * removed
* @param projectName
* @param packageName
* @param className
@@ -150,13 +168,43 @@
createBeansXMLWithContent(projectName, "/resources/beansXML/" +
"beansXmlWithDecorator.xml.cdi");
- editResourceUtil.replaceInEditor("Component", packageName + "." +
className);
+ if (className == null || className.length() == 0) {
+ editResourceUtil.replaceInEditor("<class>Component</class>",
+ "<class></class>");
+ } else {
+ editResourceUtil.replaceInEditor("Component", packageName + "." +
className);
+ }
+
}
/**
+ * Methods creates beans.xml with stereotype tags in it for entered project.
+ * Package and stereotype component name which should be showed in tag is
+ * determined by parameters. If className is null, then Component text will be
+ * removed
+ * @param projectName
+ * @param packageName
+ * @param className
+ */
+ public void createBeansXMLWithStereotype(String projectName, String packageName,
+ String className) {
+
+ createBeansXMLWithContent(projectName, "/resources/beansXML/" +
+ "beansXmlWithStereotype.xml.cdi");
+ if (className == null || className.length() == 0) {
+ editResourceUtil.replaceInEditor("<stereotype>Component</stereotype>",
+ "<stereotype></stereotype>");
+ } else {
+ editResourceUtil.replaceInEditor("Component", packageName + "." +
className);
+ }
+
+ }
+
+ /**
* Methods creates beans.xml with alternative tags in it for entered project.
* Package and alternative bean component name which should be showed in tag is
- * determined by parameters
+ * determined by parameters. If className is null, then Component text will be
+ * removed
* @param projectName
* @param packageName
* @param className
@@ -166,7 +214,12 @@
createBeansXMLWithContent(projectName, "/resources/beansXML/" +
"beansXmlWithAlternative.xml.cdi");
- editResourceUtil.replaceInEditor("Component", packageName + "." +
className);
+ if (className == null || className.length() == 0) {
+ editResourceUtil.replaceInEditor("<class>Component</class>",
+ "<class></class>");
+ } else {
+ editResourceUtil.replaceInEditor("Component", packageName + "." +
className);
+ }
}
/**
@@ -195,6 +248,7 @@
editResourceUtil.replaceClassContentByResource(OpenOnTest.class
.getResourceAsStream(path),
false);
+ bot.sleep(Timing.time500MS());
}
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIWizardHelper.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIWizardHelper.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIWizardHelper.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -11,6 +11,8 @@
package org.jboss.tools.cdi.bot.test.uiutils;
+import java.util.List;
+
import org.jboss.tools.cdi.bot.test.CDITestBase;
import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBaseExt;
@@ -69,6 +71,32 @@
}
/**
+ * Method creates larger number("amount") of the same component with using
+ * List of class names
+ * @param component
+ * @param packageBaseName
+ * @param classNames
+ * @param necessaryParam
+ * @param differentPackages
+ */
+ public void createCDIComponents(CDIWizardType component, String packageBaseName,
+ List<String> classNames, String necessaryParam, boolean differentPackages) {
+ if (classNames == null) {
+ throw new IllegalArgumentException("List with class names should not be " +
+ "null");
+ }
+ if (classNames.size() == 0) {
+ throw new IllegalArgumentException("List with class names should not be " +
+ "empty");
+ }
+ for (int i = 0; i < classNames.size(); i++) {
+ String packageName = (differentPackages) ? packageBaseName + i : packageBaseName;
+ createCDIComponent(component, classNames.get(i), packageName, necessaryParam);
+ }
+
+ }
+
+ /**
* Method that actually creates CDI component according to parameter
* @param component
* @param name
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -40,5 +40,5 @@
}
});
}
-
+
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -11,6 +11,8 @@
package org.jboss.tools.cdi.bot.test.uiutils.wizards;
+import static org.junit.Assert.assertTrue;
+
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
@@ -35,23 +37,24 @@
}
public DynamicWebProjectWizard setCDIFacet() {
- clickButton("Modify...");
- SWTBot bot = bot().shell("Project Facets").bot();
- setCDIFacetInFacets(bot);
+ clickButton("Modify...");
+ setCDIFacetInFacets(bot());
bot().sleep(Timing.time1S());
return this;
}
private void setCDIFacetInFacets(SWTBot bot) {
- SWTBotTree tree= bot.tree();
+ assertTrue(bot.activeShell().getText().equals("Project Facets"));
+ SWTBot facetsBot = bot.activeShell().bot();
+ SWTBotTree tree= facetsBot.tree();
for (SWTBotTreeItem ti: tree.getAllItems()) {
if (ti.cell(0).contains("CDI (Contexts and Dependency Injection)")) {
ti.check();
break;
}
}
- bot.sleep(Timing.time1S());
- bot.button("OK").click();
+ facetsBot.sleep(Timing.time1S());
+ facetsBot.button("OK").click();
}
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/JSFWebProjectWizard.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/JSFWebProjectWizard.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/JSFWebProjectWizard.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -33,7 +33,9 @@
}
public JSFWebProjectWizard setJSFTemplate(JSFTemplate template) {
- setTextInCombobox("Template*", template.getName());
+ if (canCheckInCombobox("Template*", template.getName())) {
+ setTextInCombobox("Template*", template.getName());
+ }
return this;
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java 2011-11-28
15:44:55 UTC (rev 36700)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java 2011-11-28
15:48:05 UTC (rev 36701)
@@ -82,13 +82,22 @@
t.setFocus();
t.setText(text);
}
+
+ protected void setTextInCombobox(String combobox, String text) {
+ bot().comboBoxWithLabel(combobox).setSelection(text);
+ bot().sleep(Timing.time500MS());
+ }
protected boolean canClick(String button) {
return bot().button(button).isEnabled();
}
- protected void setTextInCombobox(String combobox, String text) {
- bot().comboBoxWithLabel(combobox).setSelection(text);
- bot().sleep(Timing.time500MS());
+ protected boolean canCheckInCombobox(String combobox, String text) {
+ for (int i = 0; i < bot().comboBoxWithLabel(combobox).itemCount(); i++) {
+ if (bot().comboBoxWithLabel(combobox).items()[i].equals(text)) {
+ return true;
+ }
+ }
+ return false;
}
}