Author: jjankovi
Date: 2011-11-21 04:33:15 -0500 (Mon, 21 Nov 2011)
New Revision: 36468
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/beans.xml.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/BeanWithDisposerAndProducer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/EventBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/ObserverBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/BrokenFarm.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/Dog.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/SerializableBean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectDisposes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectProducer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ConstructorWithParam.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ObserverWithDisposer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ProducerWithParam.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithDisposes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithNamed.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithProducer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithSpecializes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithStateless.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithDisposes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithNamed.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithProducer.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithSpecializes.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithStateless.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/IBindingWithAnnotation.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/Scope.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/Stereotype.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/Bean.java.cdi
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIWizardType.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/ProblemsType.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/
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/BeansXMLValidationTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditor.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/FindObserverForEventTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/DecoratorValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/IBindingValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/InterceptorValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QualifierValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/ScopeValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/StereotypeValidationQuickFixTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/
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/BeanValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.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/seam3/Seam3Test.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/EditorResourceHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/LibraryHelper.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/OpenOnHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBase.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBaseExt.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/ConfigurationPresetTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/FacetTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/PerspectiveTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java
Removed:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/cdi/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/injectedPoints/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/CDIBeansEditorTest.java
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/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/actions/CDIUtil.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/editor/
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.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/CDIConfigurationPresetTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIFacetTest.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java
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/CDISmokeBotTests.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.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/uiutils/wizards/DynamicWebProjectWizard.java
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/todo.txt
Log:
BeansXMLValidationTest + OpenOn test on assignable beans + huge refactoring of all tests
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/beans.xml.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/beans.xml.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/codeCompletion/beans.xml.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,5 @@
+<?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/openon/BeanWithDisposerAndProducer.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/BeanWithDisposerAndProducer.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/BeanWithDisposerAndProducer.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,21 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class BeanComponent {
+
+ @Inject
+ int value;
+
+ public void disposeMethod(@Disposes int value) {
+
+ }
+
+ @Produces
+ public int produceMethod() {
+ return 0;
+ }
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/EventBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/EventBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/EventBean.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,16 @@
+package cdi;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+public class EventBean {
+
+ public EventBean() {
+
+ }
+
+ @Inject
+ @Q1
+ Event<ObserverBean> event;
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/ObserverBean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/ObserverBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/openon/ObserverBean.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,15 @@
+package cdi;
+
+import javax.enterprise.event.Observes;
+
+public class ObserverBean {
+
+ public ObserverBean() {
+
+ }
+
+ public void observerMethod(@Observes ObserverBean bean) {
+
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/BrokenFarm.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/BrokenFarm.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/BrokenFarm.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,9 @@
+package cdi;
+
+import javax.inject.Inject;
+
+public class BrokenFarm {
+ @SuppressWarnings("unused")
+ @Inject private Animal animal;
+
+}
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/Dog.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/Dog.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/Dog.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,9 @@
+package cdi;
+
+public class Dog extends Animal {
+
+ public Dog() {
+
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/SerializableBean.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/SerializableBean.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/SerializableBean.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,14 @@
+package cdi;
+
+import javax.enterprise.context.SessionScoped;
+
+@SessionScoped
+public class BeanComponent {
+
+ private static final long serialVersionUID = 1L;
+
+ public BeanComponent() {
+
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectDisposes.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectDisposes.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectDisposes.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class BeanComponent {
+
+ @Inject
+ public void method(@Disposes int value) {
+
+ }
+
+ @Produces
+ public int getInt() {
+ return 0;
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectProducer.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectProducer.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/BeanInjectProducer.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,14 @@
+package cdi;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class BeanComponent {
+
+ @Inject
+ @Produces
+ public int getInt() {
+ return 0;
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ConstructorWithParam.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ConstructorWithParam.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ConstructorWithParam.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+public class BeanComponent {
+
+ @Inject
+ public BeanComponent(@Disposes String value) {
+
+ }
+
+ @Produces
+ public String getValue() {
+ return null;
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ObserverWithDisposer.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ObserverWithDisposer.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ObserverWithDisposer.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,16 @@
+package cdi;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+
+public class BeanComponent {
+ @Produces
+ public long produce(){
+ return 0;
+ }
+
+ public void method(@Observes long param1, @Disposes long param2){
+
+ }
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ProducerWithParam.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ProducerWithParam.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/bean/ProducerWithParam.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,17 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.enterprise.inject.Produces;
+
+public class BeanComponent {
+
+ @Produces
+ public String getValue(@Disposes String value) {
+ return null;
+ }
+
+ @Produces
+ public String getValue2() {
+ return null;
+ }
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithDisposes.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithDisposes.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithDisposes.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,23 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Disposes;
+import javax.inject.Inject;
+
+@Decorator
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+ public void method(@Disposes String value) {
+
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithNamed.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithNamed.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithNamed.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Decorator
+@Named
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithProducer.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithProducer.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithProducer.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,24 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Produces;
+import javax.inject.Inject;
+
+@Decorator
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+ @Produces
+ public int getValue() {
+ return 0;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithSpecializes.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithSpecializes.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithSpecializes.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,22 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Specializes;
+import javax.inject.Inject;
+
+@Decorator
+@Specializes
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithStateless.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithStateless.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/decorator/DecoratorWithStateless.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import java.util.Set;
+
+import javax.decorator.Decorator;
+import javax.decorator.Delegate;
+import javax.ejb.Stateless;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+@Decorator
+@Stateless
+public abstract class DecoratorComponent implements Set<String> {
+
+ @Inject
+ @Delegate
+ @Any
+ private Set<String> set;
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithDisposes.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithDisposes.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithDisposes.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import javax.enterprise.inject.Disposes;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+ public void method(@Disposes String value) {
+
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithNamed.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithNamed.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithNamed.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,17 @@
+package cdi;
+
+import javax.inject.Named;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@Named
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithProducer.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithProducer.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithProducer.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,21 @@
+package cdi;
+
+import javax.enterprise.inject.Produces;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+ @Produces
+ public int getValue() {
+ return 0;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithSpecializes.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithSpecializes.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithSpecializes.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,17 @@
+package cdi;
+
+import javax.enterprise.inject.Specializes;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@Specializes
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithStateless.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithStateless.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptor/InterceptorWithStateless.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,17 @@
+package cdi;
+
+import javax.ejb.Stateless;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor
+@Stateless
+public class InterceptorComponent {
+
+ @AroundInvoke
+ public Object manage(InvocationContext ic) throws Exception {
+ return null;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/IBindingWithAnnotation.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/IBindingWithAnnotation.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/interceptorBinding/IBindingWithAnnotation.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,23 @@
+package cdi;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.interceptor.InterceptorBinding;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@InterceptorBinding
+@Inherited
+@Target({ TYPE, METHOD })
+@Retention(RUNTIME)
+@Documented
+public @interface IBindingComponent {
+
+ AAnnotation value();
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,23 @@
+package cdi;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.PARAMETER;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Qualifier
+@Target({ TYPE, METHOD, PARAMETER, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface QualifierComponent {
+
+ AAnnotation value();
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/Scope.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/Scope.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/scope/Scope.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,22 @@
+package cdi;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.context.NormalScope;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@NormalScope
+@Inherited
+@Target({ TYPE, METHOD, FIELD })
+@Retention(RUNTIME)
+@Documented
+public @interface ScopeComponent {
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/Stereotype.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/Stereotype.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/Stereotype.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,18 @@
+package cdi;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+
+@Retention(RUNTIME)
+@Stereotype
+@Target({ TYPE, METHOD, FIELD })
+@Documented
+public @interface StereotypeComponent {
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+import javax.inject.Named;
+
+@Retention(RUNTIME)
+@Stereotype
+@Target({FIELD})
+@Named("name")
+@Documented
+public @interface StereotypeComponent {
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,20 @@
+package cdi;
+
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import javax.enterprise.inject.Stereotype;
+import javax.enterprise.inject.Typed;
+
+@Retention(RUNTIME)
+@Stereotype
+@Target({FIELD})
+@Typed
+@Documented
+public @interface StereotypeComponent {
+
+}
\ No newline at end of file
Added: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/Bean.java.cdi
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/Bean.java.cdi
(rev 0)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/resources/seam3/Bean.java.cdi 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+package cdi;
+
+import java.net.URL;
+
+import javax.inject.Inject;
+
+import org.jboss.seam.solder.resourceLoader.Resource;
+
+public class BeanComponent {
+
+ @Inject
+ @Resource("WEB-INF/beans.xml")
+ URL beansXml;
+
+ public ResourceBean() {
+ // TODO Auto-generated constructor stub
+ }
+
+}
\ 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-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIAllBotTests.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -10,16 +10,22 @@
******************************************************************************/
package org.jboss.tools.cdi.bot.test;
-import org.jboss.tools.cdi.bot.test.editor.CDIBeansEditorTest;
-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.CDIConfigurationPresetTest;
-import org.jboss.tools.cdi.bot.test.wizard.CDIFacetTest;
+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.openon.FindObserverForEventTest;
+import org.jboss.tools.cdi.bot.test.openon.OpenOnTest;
+import org.jboss.tools.cdi.bot.test.quickfix.BeanValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.DecoratorValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.IBindingValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.InterceptorValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.QualifierValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.ScopeValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.quickfix.StereotypeValidationQuickFixTest;
+import org.jboss.tools.cdi.bot.test.seam3.Seam3Test;
+import org.jboss.tools.cdi.bot.test.uiutils.SWTEclipseCDIExtUtil;
+import org.jboss.tools.cdi.bot.test.wizard.ConfigurationPresetTest;
+import org.jboss.tools.cdi.bot.test.wizard.FacetTest;
+import org.jboss.tools.cdi.bot.test.wizard.WizardTest;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.BeforeClass;
@@ -38,37 +44,45 @@
*
* Sample swtbot.properties file:
*
- * SERVER=JBOSS_AS,6.0,default,/home/lukas/latest/jboss-6.0.0.Final
+ *
SERVER=JBOSS_AS,6.0,default,/home/jjankovi/Dokumenty/Red_Hat_Stuff/Runtimes/jboss-6.0.0.Final
* JAVA=1.6,/space/java/sdk/jdk1.6.0_22
*
*
- * Suite duration: aprox. 19min
+ * Suite duration: aprox. 25min
*
* @author Lukas Jungmann
* @author Jaroslav Jankovic
*/
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({
- //CDIPerspectiveTest.class,
- CDIConfigurationPresetTest.class,
- CDIFacetTest.class,
- CDIATWizardTest.class,
- CDIBeansEditorTest.class,
- CDIQuickFixTest.class,
- CDIOpenOnTest.class,
- CDIFindObserverForEventTest.class,
- CDISeam3Test.class
+// PerspectiveTest.class,
+ ConfigurationPresetTest.class,
+ FacetTest.class,
+ WizardTest.class,
+ BeansEditorTest.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 CDIBase {
+public class CDIAllBotTests extends CDITestBase {
/*
* init method "setup()" shows a project explorer view as default,
- * disable folding ( to easier source code editing)
+ * disable folding (to easier source code editing)
*/
@BeforeClass
public static void setUpSuite() {
eclipse.showView(ViewType.PROJECT_EXPLORER);
- CDIUtil.disableFolding(bot, util);
+ SWTEclipseCDIExtUtil.disableFolding(bot, util);
}
}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIBase.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDIBase.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.jboss.tools.ui.bot.ext.SWTTestExt;
+
+public class CDIBase extends SWTTestExt{
+
+ private static SWTBotEclipseEditor ed;
+
+ public SWTBotEclipseEditor getEd() {
+ return ed;
+ }
+
+ public void setEd(SWTBotEclipseEditor ed) {
+ CDIBase.ed = ed;
+ }
+}
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-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDISmokeBotTests.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -10,12 +10,11 @@
******************************************************************************/
package org.jboss.tools.cdi.bot.test;
-import org.jboss.tools.cdi.bot.test.editor.CDIBeansEditorTest;
-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.CDIConfigurationPresetTest;
-import org.jboss.tools.cdi.bot.test.wizard.CDIFacetTest;
+import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
+import org.jboss.tools.cdi.bot.test.uiutils.SWTEclipseCDIExtUtil;
+import org.jboss.tools.cdi.bot.test.wizard.WizardTest;
+import org.jboss.tools.cdi.bot.test.wizard.ConfigurationPresetTest;
+import org.jboss.tools.cdi.bot.test.wizard.FacetTest;
import org.jboss.tools.ui.bot.ext.RequirementAwareSuite;
import org.jboss.tools.ui.bot.ext.types.ViewType;
import org.junit.BeforeClass;
@@ -44,13 +43,13 @@
*/
@RunWith(RequirementAwareSuite.class)
@SuiteClasses({
- //CDIPerspectiveTest.class,
- CDIConfigurationPresetTest.class,
- CDIFacetTest.class,
- CDIATWizardTest.class,
- CDIBeansEditorTest.class,
+ //PerspectiveTest.class,
+ ConfigurationPresetTest.class,
+ FacetTest.class,
+ WizardTest.class,
+ BeansEditorTest.class,
})
-public class CDISmokeBotTests extends CDIBase {
+public class CDISmokeBotTests extends CDITestBase {
/*
* init method "setup()" shows a project explorer view as default,
@@ -59,6 +58,6 @@
@BeforeClass
public static void setUpSuite() {
eclipse.showView(ViewType.PROJECT_EXPLORER);
- CDIUtil.disableFolding(bot, util);
+ SWTEclipseCDIExtUtil.disableFolding(bot, util);
}
}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/CDITestBase.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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;
+
+import org.jboss.tools.cdi.bot.test.uiutils.CDIProjectHelper;
+import org.jboss.tools.cdi.bot.test.uiutils.EditorResourceHelper;
+import org.jboss.tools.cdi.bot.test.uiutils.LibraryHelper;
+import org.jboss.tools.cdi.bot.test.uiutils.OpenOnHelper;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
+import org.junit.After;
+import org.junit.Before;
+
+public class CDITestBase extends CDIBase {
+
+ private String projectName = "CDIProject";
+ private String packageName = "cdi";
+ public final String LINE_SEPARATOR = System.getProperty("line.separator");
+
+ public static CDIProjectHelper projectHelper = new CDIProjectHelper();
+ public static CDIWizard wizard = new CDIWizard();
+ public static OpenOnHelper openOnUtil = new OpenOnHelper();
+ public static LibraryHelper libraryUtil = new LibraryHelper();
+ public static EditorResourceHelper editResourceUtil = new EditorResourceHelper();
+
+ @Before
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createCDIProject(getProjectName());
+ }
+ }
+
+ @After
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIAnnotationsType.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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.annotations;
+
+public enum CDIAnnotationsType {
+
+ SERIALIZABLE, TARGET, RETENTION, NAMED, TYPED, DISPOSES, OBSERVES, INTERCEPTOR,
+ SPECIALIZES, DECORATOR, PRODUCES, NONBINDING, STATELESS, INJECT;
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIWizardType.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIWizardType.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/CDIWizardType.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * 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.annotations;
+
+public enum CDIWizardType {
+
+ INTERCEPTOR_BINDING, QUALIFIER, SCOPE, STEREOTYPE,
+ DECORATOR, INTERCEPTOR, BEAN, ANNOTATION_LITERAL,
+ BEANS_XML;
+
+ String getName() {
+ switch (this) {
+ case INTERCEPTOR_BINDING:
+ return "Interceptor Binding";
+ case QUALIFIER:
+ return "Qualifier";
+ case SCOPE:
+ return "Scope";
+ case STEREOTYPE:
+ return "Stereotype";
+ case DECORATOR:
+ return "Decorator";
+ case INTERCEPTOR:
+ return "Interceptor";
+ case BEAN:
+ return "Bean";
+ case ANNOTATION_LITERAL:
+ return "Annotation Literal";
+ case BEANS_XML:
+ return "File beans.xml";
+ default:
+ throw new AssertionError("Unknown type");
+ }
+ }
+
+ public String getAnnotationType() {
+ return isAnnotation() ? getName() + " Annotation" : getName();
+ }
+
+ private boolean isAnnotation() {
+ return this.ordinal() < DECORATOR.ordinal();
+ }
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/ProblemsType.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/ProblemsType.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/annotations/ProblemsType.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,16 @@
+/*******************************************************************************
+ * 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.annotations;
+
+public enum ProblemsType {
+ WARNINGS, ERRORS
+}
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLCompletionTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * 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.beansxml;
+
+import java.util.ArrayList;
+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.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.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on code completion in beans.xml
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class BeansXMLCompletionTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger
+ .getLogger(BeansXMLCompletionTest.class.getName());
+
+ @Override
+ public String getProjectName() {
+ return "CDIBeansCodeCompletion";
+ }
+
+ @Test
+ public void testPossibleCompletionInBeansXML() {
+ wizard.createClearBeansXML(getPackageName());
+ 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);
+ }
+ @Ignore
+ @Test
+ public void testInterceptorsCompletion() {
+
+ prepareInterceptors();
+
+ wizard.createClearBeansXML(getPackageName());
+ LOGGER.info("Clear beans.xml was created");
+
+ }
+ @Ignore
+ @Test
+ public void testDecoratorsCompletion() {
+
+ prepareDecorators();
+
+ wizard.createClearBeansXML(getPackageName());
+ LOGGER.info("Clear beans.xml was created");
+
+ }
+ @Ignore
+ @Test
+ public void testAlternativesCompletion() {
+
+ prepareAlternatives();
+
+ wizard.createClearBeansXML(getPackageName());
+ LOGGER.info("Clear beans.xml was created");
+
+ }
+
+ private void prepareInterceptors() {
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "Interceptor1",
+ getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "Interceptor2",
+ getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "Interceptor3",
+ getPackageName(), null);
+
+ }
+
+ private void prepareDecorators() {
+
+ wizard.createComponent(CDIWizardType.DECORATOR, "Decorator1",
+ getPackageName(), "java.util.Set");
+
+ wizard.createComponent(CDIWizardType.DECORATOR, "Decorator2",
+ getPackageName(), "java.util.Set");
+
+ wizard.createComponent(CDIWizardType.DECORATOR, "Decorator3",
+ getPackageName(), "java.util.Set");
+
+ }
+
+ private void prepareAlternatives() {
+
+ wizard.createComponent(CDIWizardType.BEAN, "Alternative1",
+ getPackageName(), "alternative");
+
+ wizard.createComponent(CDIWizardType.BEAN, "Alternative2",
+ getPackageName(), "alternative");
+
+ wizard.createComponent(CDIWizardType.BEAN, "Alternative3",
+ getPackageName(), "alternative");
+
+ }
+
+ //not complete yet
+ private List<String> getAutoCompletion(int row, int column, String text) {
+ List<String> listOfCompletion = new ArrayList<String>();
+ getEd().navigateTo(row, column);
+ bot.sleep(Timing.time500MS());
+ getEd().typeText(text);
+ bot.sleep(Timing.time500MS());
+ getEd().pressShortcut(Keystrokes.CTRL, Keystrokes.SPACE);
+ bot.sleep(Timing.time1S());
+ for (int i = 0; i < bot.table().rowCount(); i++) {
+ listOfCompletion.add(bot.table().getTableItem(i).getText());
+ }
+ return listOfCompletion;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/beansxml/BeansXMLValidationTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,130 @@
+/*******************************************************************************
+ * 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.beansxml;
+
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+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.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.view.ProblemsView;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on code completion in beans.xml
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class BeansXMLValidationTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger
+ .getLogger(BeansXMLValidationTest.class.getName());
+
+ @Override
+ public String getProjectName() {
+ return "CDIBeansValidation";
+ }
+
+ @Test
+ public void testClearBeansXMLValidation() {
+
+ wizard.createClearBeansXML(getProjectName());
+ LOGGER.info("Clear beans.xml was created");
+
+ SWTBotTreeItem[] validationErrors = getBeansXMLValidationErrors();
+
+ assertTrue(validationErrors.length == 0);
+
+ }
+
+ @Test
+ public void testInterceptorsValidation() {
+
+ String firstPackage = getPackageName() + ".test1";
+ String secondPackage = getPackageName() + ".test2";
+ String nonExistingPackage = getPackageName() + ".test3";
+
+ prepareTwoInterceptors(firstPackage, secondPackage);
+
+ wizard.createClearBeansXML(getProjectName());
+ LOGGER.info("Clear beans.xml was created");
+
+ String interceptorTag = "<interceptors>" + LINE_SEPARATOR +
+ "</interceptors>" + LINE_SEPARATOR;
+ String firstInterceptor = "<class>" + firstPackage +
".I1</class>" + LINE_SEPARATOR;
+
+ editResourceUtil.insertInEditor(3, 0, interceptorTag);
+ editResourceUtil.insertInEditor(4, 0, firstInterceptor);
+ assertTrue(getBeansXMLValidationErrors().length == 0);
+
+ String secondDecorator = "<class>" + secondPackage +
".I2</class>" + LINE_SEPARATOR;
+ editResourceUtil.insertInEditor(5, 0, secondDecorator);
+ assertTrue(getBeansXMLValidationErrors().length == 0);
+
+
+ editResourceUtil.replaceInEditor(firstPackage, nonExistingPackage);
+
+ SWTBotTreeItem[] validationErrors = getBeansXMLValidationErrors();
+ assertTrue(validationErrors.length == 1);
+ assertTrue(validationErrors[0].getText().contains("There is no class with the
specified name"));
+
+ wizard.createComponent(CDIWizardType.BEAN, "Bean1", firstPackage, null);
+ bot.editorByTitle("beans.xml").show();
+ bot.editorByTitle("beans.xml").setFocus();
+ setEd(bot.activeEditor().toTextEditor());
+ editResourceUtil.replaceInEditor(nonExistingPackage + ".I1", firstPackage +
".Bean1");
+
+ validationErrors = getBeansXMLValidationErrors();
+ assertTrue(validationErrors.length == 1);
+ assertTrue(validationErrors[0].getText().contains("must specify the name of an
interceptor class"));
+ }
+
+ @Test
+ public void testDecoratorsValidation() {
+
+ }
+
+ @Test
+ public void testAlternativesValidation() {
+
+ }
+
+ @Test
+ public void testNotSupportedCDIComponentsValidation() {
+
+ }
+
+ private SWTBotTreeItem[] getBeansXMLValidationErrors() {
+ return ProblemsView.getFilteredErrorsTreeItems(bot, null, "/"
+ + getProjectName() + "/WebContent/WEB-INF", "beans.xml",
"CDI Problem");
+ }
+
+ private void prepareTwoInterceptors(String firstPackage, String secondPackage) {
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "I1", firstPackage, null);
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "I2", secondPackage,
null);
+
+ }
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditor.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditor.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditor.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * 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.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;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+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;
+
+/**
+ * @author Lukas Jungmann
+ */
+public class BeansEditor extends SWTBotMultiPageEditor {
+
+ public enum Item {
+ INTERCEPTOR("Interceptors"), DECORATOR("Decorators"),
+ CLASS("Alternatives"), STEREOTYPE("Alternatives");
+
+ private final String node;
+
+ private Item(String node) {
+ this.node = node;
+ }
+
+ private String getNode() {
+ return node;
+ }
+
+ public String getElementName() {
+ switch (this) {
+ case STEREOTYPE:
+ return "stereotype";
+ default:
+ return "class";
+ }
+ }
+ }
+
+ private SWTBotExt bot = new SWTBotExt();
+ private static final String ROOT_NODE = "beans.xml";
+
+ public BeansEditor(IEditorReference editorReference, SWTWorkbenchBot bot) {
+ super(editorReference, bot);
+ }
+
+ public BeansEditor add(Item item, String name) {
+ return modify(item, name, "Add...", new AddDialogHandler(item, name));
+ }
+
+ public BeansEditor remove(Item item, String name) {
+ return modify(item, name, "Remove...", new DeleteDialogHandler());
+ }
+
+ public String getSelectedItem() {
+ return bot().tree().selection().get(0, 0);
+ }
+
+ private BeansEditor modify(Item item, String name, String actionLabel, DialogHandler h)
{
+ 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();
+ h.handle(bot.activeShell());
+ bot.sleep(500);
+ this.setFocus();
+ return this;
+ }
+
+ private void selectItem(Item item, String name) {
+ SWTBotTable t = item == Item.STEREOTYPE ? bot.table(1) : bot.table(0);
+ if (t.containsItem(name)) {
+ t.select(name);
+ }
+ }
+
+ private SWTBotButton getItemButton(Item i, String label) {
+ return i == Item.STEREOTYPE ? bot.button(label, 1) : bot.button(label, 0);
+ }
+
+ private interface DialogHandler {
+ void handle(SWTBotShell dialog);
+ }
+
+ private class AddDialogHandler implements DialogHandler {
+
+ private final Item type;
+ private final String name;
+
+ public AddDialogHandler(Item type, String name) {
+ this.type = type;
+ this.name = name;
+ }
+
+ public void handle(SWTBotShell dialog) {
+ SWTBot sh = dialog.bot();
+ SWTBotText t = type == Item.STEREOTYPE
+ ? sh.textWithLabel("Stereotype:*")
+ : sh.textWithLabel("Class:*");
+ t.setText(name);
+ sh.button("Finish").click();
+ }
+ }
+
+ private class DeleteDialogHandler implements DialogHandler {
+
+ public void handle(SWTBotShell dialog) {
+ dialog.bot().button("OK").click();
+ }
+
+ }
+}
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/BeansEditorTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,224 @@
+/*******************************************************************************
+ * 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.editor;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+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.CDITestBase;
+import org.jboss.tools.cdi.bot.test.editor.BeansEditor.Item;
+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.view.ProjectExplorer;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * prerequisite - CDIAtWizardTest!!!
+ *
+ *
+ * @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 })
+public class BeansEditorTest extends CDITestBase {
+
+ private static final String descPath = "WebContent/WEB-INF/beans.xml";
+ private static final Logger LOGGER = Logger.getLogger(BeansEditorTest.class.getName());
+
+ @BeforeClass
+ public static void setup() {
+ editResourceUtil.copyResource("resources/beans.xml", descPath);
+ editResourceUtil.copyResource("resources/Foo.jav_",
"src/cdi/Foo.java");
+ editResourceUtil.copyResource("resources/Bar.jav_",
"src/cdi/Bar.java");
+ }
+
+ @Override
+ public void checkAndCreateProject() {
+ new ProjectExplorer().openFile(getProjectName(),
descPath.split("/"));
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDIWizardTest";
+ }
+
+ @Test
+ public void testClasses() {
+ addItem(Item.CLASS, getPackageName() + ".Foo");
+ addItem(Item.CLASS, getPackageName() + ".Bar");
+ removeItem(Item.CLASS, getPackageName() + ".Foo");
+ }
+
+ @Test
+ public void testInterceptors() {
+ addItem(Item.INTERCEPTOR, getPackageName() + ".I1");
+ removeItem(Item.INTERCEPTOR, getPackageName() + ".I1");
+ addItem(Item.INTERCEPTOR, getPackageName() + ".I2");
+ }
+
+
+ @Test
+ public void testDecorators() {
+ addItem(Item.DECORATOR, getPackageName() + ".MapDecorator");
+ addItem(Item.DECORATOR, getPackageName() + ".ComparableDecorator");
+ removeItem(Item.DECORATOR, getPackageName() + ".ComparableDecorator");
+ }
+
+
+ @Test
+ public void testStereotypes() {
+ addItem(Item.STEREOTYPE, getPackageName() + ".S2");
+ addItem(Item.STEREOTYPE, getPackageName() + ".S3");
+ removeItem(Item.STEREOTYPE, getPackageName() + ".S3");
+ addItem(Item.STEREOTYPE, getPackageName() + ".S1");
+ removeItem(Item.STEREOTYPE, getPackageName() + ".S2");
+ }
+
+ @Test
+ public void testResult() {
+ SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
+ BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
+ be.activatePage("Source");
+ String text = be.toTextEditor().getText();
+ List<Node> nl = getItems(text, Item.INTERCEPTOR);
+ assertEquals(1, nl.size());
+ assertTrue(containsItem(nl, getPackageName() + ".I2"));
+
+ nl = getItems(text, Item.DECORATOR);
+ assertEquals(1, nl.size());
+ assertTrue(containsItem(nl, getPackageName() + ".MapDecorator"));
+
+ nl = getItems(text, Item.CLASS);
+ assertEquals(1, nl.size());
+ assertTrue(containsItem(nl, getPackageName() + ".Bar"));
+
+ nl = getItems(text, Item.STEREOTYPE);
+ assertEquals(1, nl.size());
+ assertTrue(containsItem(nl, getPackageName() + ".S1"));
+ }
+
+ private void addItem(Item item, String name) {
+ SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
+ BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
+ be.activatePage("Tree");
+ try {
+ be.add(item, name);
+ Assert.assertTrue(be.isDirty());
+ Assert.assertEquals(name, be.getSelectedItem());
+ be.activatePage("Source");
+ String text = be.toTextEditor().getText();
+ List<Node> nl = getItems(text, item);
+ assertTrue(containsItem(nl, name));
+ } finally {
+ if (be.isDirty()) {
+ be.save();
+ }
+ }
+ }
+
+ private void removeItem(Item item, String name) {
+ SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
+ BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
+ be.activatePage("Tree");
+ try {
+ be.remove(item, name);
+ Assert.assertTrue(be.isDirty());
+ be.activatePage("Source");
+ String text = be.toTextEditor().getText();
+ List<Node> nl = getItems(text, item);
+ assertFalse(containsItem(nl, name));
+ } finally {
+ if (be.isDirty()) {
+ be.save();
+ }
+ }
+ }
+
+ private Document getDocument(String text) {
+ Document d = null;
+ try {
+ d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new
ByteArrayInputStream(text.getBytes()));
+ } catch (SAXException e) {
+ LOGGER.log(Level.SEVERE, e.getMessage(), e);
+ } catch (IOException e) {
+ LOGGER.log(Level.SEVERE, e.getMessage(), e);
+ } catch (ParserConfigurationException e) {
+ LOGGER.log(Level.SEVERE, e.getMessage(), e);
+ }
+ return d;
+ }
+
+ private List<Node> getItems(String doc, Item i) {
+ Document d = getDocument(doc);
+ NodeList nl = null;
+ switch (i) {
+ case DECORATOR:
+ nl = d.getElementsByTagName("decorators");
+ break;
+ case INTERCEPTOR:
+ nl = d.getElementsByTagName("interceptors");
+ break;
+ case STEREOTYPE:
+ return getNodes(d.getElementsByTagName("stereotype"), i);
+ case CLASS:
+ nl = d.getElementsByTagName("alternatives");
+ break;
+ }
+ return nl.getLength() > 0 ? getNodes(nl.item(0).getChildNodes(), i) : new
ArrayList<Node>();
+ }
+
+ private List<Node> getNodes(NodeList nl, Item item) {
+ List<Node> list = new ArrayList<Node>();
+ for (int i = 0; i < nl.getLength(); i++) {
+ Node n = nl.item(i);
+ if (item.getElementName().equals(n.getNodeName())) {
+ list.add(n);
+ }
+ }
+ return list;
+ }
+
+ private boolean containsItem(List<Node> nl, String name) {
+ if (nl == null) {
+ return false;
+ }
+ for (int i = 0; i < nl.size(); i++) {
+ if (name.equals(nl.get(i).getTextContent())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Deleted:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/CDIBeansEditorTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/CDIBeansEditorTest.java 2011-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/editor/CDIBeansEditorTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,225 +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.editor;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-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.uiutils.actions.CDIBase;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.CDIUtil;
-import org.jboss.tools.cdi.bot.test.uiutils.editor.BeansEditor;
-import org.jboss.tools.cdi.bot.test.uiutils.editor.BeansEditor.Item;
-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.view.ProjectExplorer;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-/**
- * prerequisite - CDIAtWizardTest!!!
- *
- *
- * @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 })
-public class CDIBeansEditorTest extends CDIBase {
-
- private static final String descPath = "WebContent/WEB-INF/beans.xml";
- private static final Logger LOGGER =
Logger.getLogger(CDIBeansEditorTest.class.getName());
-
- @BeforeClass
- public static void setup() {
- CDIUtil.copyResource("resources/beans.xml", descPath);
- CDIUtil.copyResource("resources/Foo.jav_", "src/cdi/Foo.java");
- CDIUtil.copyResource("resources/Bar.jav_", "src/cdi/Bar.java");
- }
-
- @Override
- public void checkAndCreateProject() {
- new ProjectExplorer().openFile(getProjectName(),
descPath.split("/"));
- }
-
- @Override
- public String getProjectName() {
- return "CDIWizardTest";
- }
-
- @Test
- public void testClasses() {
- addItem(Item.CLASS, getPackageName() + ".Foo");
- addItem(Item.CLASS, getPackageName() + ".Bar");
- removeItem(Item.CLASS, getPackageName() + ".Foo");
- }
-
- @Test
- public void testInterceptors() {
- addItem(Item.INTERCEPTOR, getPackageName() + ".I1");
- removeItem(Item.INTERCEPTOR, getPackageName() + ".I1");
- addItem(Item.INTERCEPTOR, getPackageName() + ".I2");
- }
-
-
- @Test
- public void testDecorators() {
- addItem(Item.DECORATOR, getPackageName() + ".MapDecorator");
- addItem(Item.DECORATOR, getPackageName() + ".ComparableDecorator");
- removeItem(Item.DECORATOR, getPackageName() + ".ComparableDecorator");
- }
-
-
- @Test
- public void testStereotypes() {
- addItem(Item.STEREOTYPE, getPackageName() + ".S2");
- addItem(Item.STEREOTYPE, getPackageName() + ".S3");
- removeItem(Item.STEREOTYPE, getPackageName() + ".S3");
- addItem(Item.STEREOTYPE, getPackageName() + ".S1");
- removeItem(Item.STEREOTYPE, getPackageName() + ".S2");
- }
-
- @Test
- public void testResult() {
- SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
- BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
- be.activatePage("Source");
- String text = be.toTextEditor().getText();
- List<Node> nl = getItems(text, Item.INTERCEPTOR);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, getPackageName() + ".I2"));
-
- nl = getItems(text, Item.DECORATOR);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, getPackageName() + ".MapDecorator"));
-
- nl = getItems(text, Item.CLASS);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, getPackageName() + ".Bar"));
-
- nl = getItems(text, Item.STEREOTYPE);
- assertEquals(1, nl.size());
- assertTrue(containsItem(nl, getPackageName() + ".S1"));
- }
-
- private void addItem(Item item, String name) {
- SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
- BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
- be.activatePage("Tree");
- try {
- be.add(item, name);
- Assert.assertTrue(be.isDirty());
- Assert.assertEquals(name, be.getSelectedItem());
- be.activatePage("Source");
- String text = be.toTextEditor().getText();
- List<Node> nl = getItems(text, item);
- assertTrue(containsItem(nl, name));
- } finally {
- if (be.isDirty()) {
- be.save();
- }
- }
- }
-
- private void removeItem(Item item, String name) {
- SWTBotEditor editor = new SWTWorkbenchBot().activeEditor();
- BeansEditor be = new BeansEditor(editor.getReference(), new SWTWorkbenchBot());
- be.activatePage("Tree");
- try {
- be.remove(item, name);
- Assert.assertTrue(be.isDirty());
- be.activatePage("Source");
- String text = be.toTextEditor().getText();
- List<Node> nl = getItems(text, item);
- assertFalse(containsItem(nl, name));
- } finally {
- if (be.isDirty()) {
- be.save();
- }
- }
- }
-
- private Document getDocument(String text) {
- Document d = null;
- try {
- d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new
ByteArrayInputStream(text.getBytes()));
- } catch (SAXException e) {
- LOGGER.log(Level.SEVERE, e.getMessage(), e);
- } catch (IOException e) {
- LOGGER.log(Level.SEVERE, e.getMessage(), e);
- } catch (ParserConfigurationException e) {
- LOGGER.log(Level.SEVERE, e.getMessage(), e);
- }
- return d;
- }
-
- private List<Node> getItems(String doc, Item i) {
- Document d = getDocument(doc);
- NodeList nl = null;
- switch (i) {
- case DECORATOR:
- nl = d.getElementsByTagName("decorators");
- break;
- case INTERCEPTOR:
- nl = d.getElementsByTagName("interceptors");
- break;
- case STEREOTYPE:
- return getNodes(d.getElementsByTagName("stereotype"), i);
- case CLASS:
- nl = d.getElementsByTagName("alternatives");
- break;
- }
- return nl.getLength() > 0 ? getNodes(nl.item(0).getChildNodes(), i) : new
ArrayList<Node>();
- }
-
- private List<Node> getNodes(NodeList nl, Item item) {
- List<Node> list = new ArrayList<Node>();
- for (int i = 0; i < nl.getLength(); i++) {
- Node n = nl.item(i);
- if (item.getElementName().equals(n.getNodeName())) {
- list.add(n);
- }
- }
- return list;
- }
-
- private boolean containsItem(List<Node> nl, String name) {
- if (nl == null) {
- return false;
- }
- for (int i = 0; i < nl.size(); i++) {
- if (name.equals(nl.get(i).getTextContent())) {
- return true;
- }
- }
- return false;
- }
-
-}
Deleted:
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 2011-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIFindObserverForEventTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,336 +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.openon;
-
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-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.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.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test operates on CDI perspective
- *
- * @author Jaroslav Jankovic
- */
-
-@Require(clearProjects = true, 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 final String[] events = { "myBean1Q1Event",
"myBean1AnyEvent",
- "myBean2Q1Event", "myBean2AnyEvent", "myBean1Q2Event",
- "myBean2Q2Event", "myBean1Q1Event.fire(new MyBean1());",
- "myBean1AnyEvent.fire(new MyBean1())",
- "myBean2Q1Event.fire(new MyBean2())",
- "myBean2AnyEvent.fire(new MyBean2())",
- "myBean1Q2Event.fire(new MyBean1())",
- "myBean2Q2Event.fire(new MyBean2())",
- "myBean1AnyEvent.fire(new MyBean2())" };
- private final String[] observers = { "observeNoQualifierMyBean1",
- "observeAnyMyBean1", "observeQ1MyBean1",
- "observeNoQualifierMyBean2", "observeAnyMyBean2",
- "observeQ1MyBean2", "observeQ2MyBean1",
"observeQ2MyBean2" };
-
- @Override
- public String getProjectName() {
- return "CDIObserverTest";
- }
-
- @Test
- public void testSimpleCaseObserverFinding() {
-
- prepareSimpleObserverFinding();
-
- testSimpleObserverFinding();
-
- }
-
- // not implemented yet
- @Test
- public void testComplexCaseObserverFinding() {
-
- prepareComplexObserverFinding();
-
- testComplexObserverFinding();
- }
-
- private void prepareSimpleObserverFinding() {
-
- createComponent(CDICOMPONENT.QUALIFIER, "Q1", getPackageName(), null);
-
- createComponent(CDICOMPONENT.QUALIFIER, "Q2", getPackageName(), null);
-
- createComponent(CDICOMPONENT.BEAN, "MyBean1", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIFindObserverForEventTest.class
- .getResourceAsStream("/resources/events/MyBean1.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "MyBean2", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIFindObserverForEventTest.class
- .getResourceAsStream("/resources/events/MyBean2.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "EventsProducer", getPackageName(),
null);
- CDIUtil.copyResourceToClass(
- getEd(),
- CDIFindObserverForEventTest.class
- .getResourceAsStream("/resources/events/EventsProducer.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "ObserverBean", getPackageName(), null);
- CDIUtil.copyResourceToClass(
- getEd(),
- CDIFindObserverForEventTest.class
- .getResourceAsStream("/resources/events/ObserverBean.java.cdi"),
- false);
- util.waitForNonIgnoredJobs();
- }
-
- private void testSimpleObserverFinding() {
-
-
- for (int i = 0; i < events.length; i++) {
- checkObserverMethodsForEvent(events[i]);
- }
-
-
- for (int i = 0; i < observers.length; i++) {
- checkEventsForObserverMethods(observers[i]);
- }
- }
-
- private void checkObserverMethodsForEvent(String eventName) {
-
- String eventsClass = "EventsProducer.java";
-
- String showObserverOption = "Show CDI Observer Methods...";
-
- checkEventsAndObserver(eventName, eventsClass, showObserverOption);
-
- }
-
- private void checkEventsForObserverMethods(String observerName) {
-
- String observerClass = "ObserverBean.java";
-
- /**
- * there are two observer methods for which there is only one
- * event, so there will be no "Show CDI Events" option, instead
- * of that, there will be "Open CDI Event" option
- */
- String showObserverOption = ((observerName.equals("observeQ1MyBean2")) ||
- (observerName.equals("observeQ2MyBean2"))) ? "Open CDI Event" :
"Show CDI Events...";
-
- checkEventsAndObserver(observerName, observerClass, showObserverOption);
- }
-
- private void checkEventsAndObserver(String name, String className,
- String option) {
- openOn(name, className, option);
- bot.sleep(Timing.time1S());
- if (option.equals("Open CDI Event")) {
- if (name.equals("observeQ1MyBean2")) {
- LOGGER.info("Testing observer: observeQ1MyBean2 started");
- assertTrue(getEd().toTextEditor().getSelection().equals("myBean2Q1Event"));
- LOGGER.info("Testing observer: observeQ1MyBean2 ended");
- }else {
- //observeQ1MyBean2
- LOGGER.info("Testing observer: observeQ1MyBean2 started");
- assertTrue(getEd().toTextEditor().getSelection().equals("myBean2Q2Event"));
- LOGGER.info("Testing observer: observeQ1MyBean2 ended");
- }
- } else {
- SWTBotTable observerTable = bot.table(0);
- if (className.equals("EventsProducer.java")) {
- assertTrue(checkAllObserverMethodsForEvent(name, observerTable));
- }
- if (className.equals("ObserverBean.java")) {
- assertTrue(checkAllEventsForObserverMethod(name, observerTable));
- }
- }
- }
-
- private boolean checkAllObserverMethodsForEvent(String eventName,
- SWTBotTable observerTable) {
- String observerClass = "ObserverBean";
- String packageProjectPath = getPackageName() + " - /" + getProjectName() +
"/src";
- String parametrizedEventItem = observerClass + ".observeXXX() - " +
packageProjectPath;
- boolean allObserversFound = false;
- for (int i = 0; i < events.length; i++) {
- if (eventName.equals(events[i])) {
- LOGGER.info("Testing event: " + events[i] + " started");
- switch (i) {
- //myBean1Q1Event
- //myBean1Q1Event.fire(new MyBean1())
- case 0:
- case 6:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q1MyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1"))) {
- allObserversFound = true;
- }
- break;
- //myBean1AnyEvent
- //myBean1AnyEvent.fire(new MyBean1())
- //myBean1AnyEvent.fire(new MyBean2())
- case 1:
- case 7:
- case 12:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1"))) {
- allObserversFound = true;
- }
- break;
- //myBean2Q1Event
- //myBean2Q1Event.fire(new MyBean2())
- case 2:
- case 8:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q1MyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q1MyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean2"))) {
- allObserversFound = true;
- }
- break;
- //myBean2AnyEvent
- //myBean2AnyEvent.fire(new MyBean2())
- case 3:
- case 9:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean2"))) {
- allObserversFound = true;
- }
- break;
- //myBean1Q2Event
- //myBean1Q2Event.fire(new MyBean1())
- case 4:
- case 10:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q2MyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1"))) {
- allObserversFound = true;
- }
- break;
- //myBean2Q2Event
- //myBean2Q2Event.fire(new MyBean2())
- case 5:
- case 11:
- if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q2MyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q2MyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean2")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1")) &&
- observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean2"))) {
- allObserversFound = true;
- }
- break;
- }
- LOGGER.info("Testing event: " + events[i] + " ended");
- break;
- }
- }
- return allObserversFound;
- }
-
- private boolean checkAllEventsForObserverMethod(String observerName,
- SWTBotTable eventsTable) {
- String eventsClass = "EventsProducer";
- String packageProjectPath = getPackageName() + " - /" + getProjectName() +
"/src";
- String parametrizedEventItem = eventsClass + ".myBeanXXX - " +
packageProjectPath;
- boolean allEventsFound = false;
- for (int i = 0; i < observers.length; i++) {
- if (observerName.equals(observers[i])) {
- LOGGER.info("Testing observer: " + observers[i] + " started");
- switch (i) {
- //observeNoQualifierMyBean1
- //observeAnyMyBean1
- case 0:
- case 1:
- if (eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1Q1Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q1Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1AnyEvent")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2AnyEvent")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1Q2Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q2Event"))) {
- allEventsFound = true;
- }
- //observeQ1MyBean1
- case 2:
- if (eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1Q1Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q1Event"))) {
- allEventsFound = true;
- }
- break;
- //observeNoQualifierMyBean2
- //observeAnyMyBean2
- case 3:
- case 4:
- if (eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q1Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2AnyEvent")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q2Event"))) {
- allEventsFound = true;
- }
- break;
- //observeQ1MyBean2
- case 5:
- throw new IllegalStateException("Observer method \"observeQ1MyBean2\"
should " +
- "have been tested earlier!!");
- //observeQ2MyBean1
- case 6:
- if (eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1Q2Event")) &&
- eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q2Event"))) {
- allEventsFound = true;
- }
- break;
- //observeQ2MyBean2
- case 7:
- throw new IllegalStateException("Observer method \"observeQ2MyBean2\"
should " +
- "have been tested earlier!!");
- }
- LOGGER.info("Testing observer: " + observers[i] + " ended");
- break;
- }
- }
- return allEventsFound;
- }
-
- // not implemented yet
- private void prepareComplexObserverFinding() {
-
- }
-
- // not implemented yet
- private void testComplexObserverFinding() {
- /**
- * main idea - check events which have multiple qualifiers defined
- * (
http://docs.jboss.org/weld/reference/1.0.0/en-US/html/events.html -
- * 11.6) - check events with qualifiers which has members
- * (
http://docs.jboss.org/weld/reference/1.0.0/en-US/html/events.html -
- * 11.5)
- */
- }
-}
Deleted:
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-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/CDIOpenOnTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,318 +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.openon;
-
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-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.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.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test operates on hyperlinks-openons using CDI tools
- *
- * @author Jaroslav Jankovic
- *
- */
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class })
-public class CDIOpenOnTest extends CDIBase {
-
- private static final Logger LOGGER =
Logger.getLogger(CDIQuickFixTest.class.getName());
-
- @Override
- public String getProjectName() {
- return "CDIOpenOnTest";
- }
-
- @Test
- public void testBeanInjectOpenOn() {
-
- prepareInjectedPointsComponents();
-
- testInjectedPoints();
-
- }
-
- /*
- *
https://issues.jboss.org/browse/JBIDE-7025
- */
- @Test
- public void testBeansXMLClassesOpenOn() {
-
- /*
- * check if beans.xml was not created in previous tests. If so, I cannot create
- * beans.xml into getProjectName()/WebContent/WEB-INF/beans.xml.
- */
- if (!projectExplorer.isFilePresent(getProjectName(),
"WebContent/META-INF/beans.xml") &&
- !projectExplorer.isFilePresent(getProjectName(),
"WebContent/WEB-INF/beans.xml")) {
- createComponent(CDICOMPONENT.BEANSXML, null, getProjectName() +
"/WebContent/WEB-INF", null);
- }
-
- createComponent(CDICOMPONENT.DECORATOR, "D1", getPackageName(),
- "java.util.Set");
- bot.editorByTitle("beans.xml").show();
- bot.cTabItem("Source").activate();
- openOn(getPackageName() + ".D1", "beans.xml", null);
- assertTrue("ERROR: redirected to " + getEd().getTitle(),
- getEd().getTitle().equals("D1.java"));
-
- createComponent(CDICOMPONENT.INTERCEPTOR, "Interceptor1", getPackageName(),
- null);
- bot.editorByTitle("beans.xml").show();
- openOn(getPackageName() + ".Interceptor1", "beans.xml", null);
- assertTrue("ERROR: redirected to " + getEd(),
- getEd().getTitle().equals("Interceptor1.java"));
-
- createComponent(CDICOMPONENT.BEAN, "B1", getPackageName(),
- "alternative+beansxml");
- bot.editorByTitle("beans.xml").show();
- openOn(getPackageName() + ".B1", "beans.xml", null);
- assertTrue("ERROR: redirected to " + getEd(),
- getEd().getTitle().equals("B1.java"));
-
- createComponent(CDICOMPONENT.STEREOSCOPE, "S1", getPackageName(),
- "alternative+beansxml");
- bot.editorByTitle("beans.xml").show();
- openOn(getPackageName() + ".S1", "beans.xml", null);
- assertTrue("ERROR: redirected to " + getEd(),
- getEd().getTitle().equals("S1.java"));
-
- }
-
- /*
- *
https://issues.jboss.org/browse/JBIDE-6251
- */
- @Test
- public void testDisposerProducerOpenOn() {
-
- String testedBean = "DisposerProducerBean";
- createComponent(CDICOMPONENT.BEAN, "MyBean", getPackageName(), null);
- createComponent(CDICOMPONENT.BEAN, testedBean, getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/" + testedBean +
".java.cdi"),
- false);
- openOn("disposeMethod", testedBean + ".java", "Open Bound
Producer");
- assertTrue(getEd().toTextEditor().getSelection().equals("produceMethod"));
-
- openOn("produceMethod", testedBean + ".java", "Open Bound
Disposer");
- assertTrue(getEd().toTextEditor().getSelection().equals("disposeMethod"));
- }
-
- @Test
- public void testObserverOpenOn() {
- createComponent(CDICOMPONENT.BEAN, "EventBean", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/EventBean.java.cdi"),
- false);
- createComponent(CDICOMPONENT.BEAN, "ObserverBean", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/cdi/ObserverBean.java.cdi"),
- false);
-
- bot.editorByTitle("EventBean.java").show();
- setEd(bot.activeEditor().toTextEditor());
- CDIUtil.replaceInEditor(getEd(), bot, " event", " event");
-
- openOn("observerMethod", "ObserverBean.java", "Open CDI
Event");
- assertTrue(getEd().toTextEditor().getSelection().equals("event"));
-
- openOn("Event<ObserverBean> event", "EventBean.java",
"Open CDI Observer Method");
- assertTrue(getEd().toTextEditor().getSelection().equals("observerMethod"));
- }
-
- private void prepareInjectedPointsComponents() {
- createComponent(CDICOMPONENT.QUALIFIER, "Q1", getPackageName(), null);
-
- createComponent(CDICOMPONENT.QUALIFIER, "Q2", getPackageName(), null);
-
- createComponent(CDICOMPONENT.BEAN, "MyBean1", getPackageName(), null);
-
- createComponent(CDICOMPONENT.BEAN, "MyBean2", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/injectedPoints/MyBean2.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "MyBean3", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/injectedPoints/MyBean3.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "MyBean4", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/injectedPoints/MyBean4.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "MyBean5", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/injectedPoints/MyBean5.java.cdi"),
- false);
-
- createComponent(CDICOMPONENT.BEAN, "MainBean", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIOpenOnTest.class
- .getResourceAsStream("/resources/injectedPoints/MainBean.java.cdi"),
- false);
- }
-
- private void testInjectedPoints() {
- String injectOption = null;
- for (int i = 1; i < 12; i++) {
- injectOption = "Show All Assignable Beans...";
- String injectPoint = "myBean" + i;
- if (i > 8) injectOption = "Open @Inject Bean";
- checkInjectedPoint(injectPoint, injectOption);
- }
-
- }
-
- private void checkInjectedPoint(String injectedPoint, String option) {
- openOn(injectedPoint, "MainBean.java", option);
- bot.sleep(Timing.time1S());
- if (option.equals("Open @Inject Bean")) {
- LOGGER.info("Testing injected point: \"" + injectedPoint +
"\" started");
- assertTrue(getEd().getTitle().equals("MyBean4.java"));
- assertTrue(getEd().toTextEditor().getSelection().equals("MyBean4"));
- LOGGER.info("Testing injected point: \"" + injectedPoint +
"\" ended");
- } else {
- SWTBotTable assignBeans = bot.table(0);
- assertTrue(checkAllAssignBeans(injectedPoint, assignBeans));
- }
- }
-
- private boolean checkAllAssignBeans(String injectedPoint,
- SWTBotTable assignBeans) {
- String packageProjectPath = getPackageName() + " - /" + getProjectName() +
"/src";
- String paramAssignBean = "XXX - " + packageProjectPath;
- String prodInjPoint = "@Produces MyBean3.getMyBeanXXX()";
- boolean allassignBeans = false;
- String indexOfInjPoint = injectedPoint.split("myBean")[1];
- int intIndexOfInjPoint = Integer.parseInt(indexOfInjPoint);
- LOGGER.info("Testing injected point: \"" + injectedPoint + "\"
started");
- switch (intIndexOfInjPoint) {
- case 1:
- if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean1")) &&
- assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "1")))&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX",
"1WithIMB2")))&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2")))) {
- allassignBeans = true;
- }
- break;
- case 2:
- if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2")))) {
- allassignBeans = true;
- }
- break;
- case 3:
- if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX",
"1WithQ1")))&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX",
"1WithIMB2Q1")))&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2WithQ1")))) {
- allassignBeans = true;
- }
- break;
- case 4:
- if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2WithQ1")))) {
- allassignBeans = true;
- }
- break;
- case 5:
- if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
- assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "1WithQ2")))
&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2WithQ2")))
&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "1WithIMB2Q2"))))
{
- allassignBeans = true;
- }
- break;
- case 6:
- if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
- assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2WithQ2")))) {
- allassignBeans = true;
- }
- break;
- case 7:
- if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean1")) &&
- assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
- assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
- assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "1"))) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "1WithIMB2")))
&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "1WithIMB2Q1")))
&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "1WithIMB2Q2")))
&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "1WithQ1")))
&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "1WithQ2")))
&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2"))) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2WithQ1")))
&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2WithQ2")))) {
- allassignBeans = true;
- }
- break;
- case 8:
- if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
- assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
- assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2"))) &&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2WithQ1")))
&&
- assignBeans.containsItem(paramAssignBean.replace(
- "XXX", prodInjPoint.replace("XXX", "2WithQ2")))) {
- allassignBeans = true;
- }
- break;
- case 9:
- case 10:
- case 11:
- throw new IllegalStateException("Injection Point \"" + injectedPoint +
"\" should " +
- "have been tested earlier!!");
- }
- LOGGER.info("Testing injected point: \"" + injectedPoint + "\"
ended");
- return allassignBeans;
- }
-
-}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/FindObserverForEventTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/FindObserverForEventTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/FindObserverForEventTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,319 @@
+/*******************************************************************************
+ * 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.util.logging.Logger;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+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;
+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 = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class FindObserverForEventTest extends OpenOnBase {
+
+ private static final Logger LOGGER =
Logger.getLogger(FindObserverForEventTest.class.getName());
+
+ @Override
+ public String getProjectName() {
+ return "CDIObserverTest";
+ }
+
+ @Test
+ public void testSimpleCaseObserverFinding() {
+
+ prepareSimpleObserverFinding();
+
+ testSimpleObserverFinding();
+
+ }
+
+ // not implemented yet
+ @Test
+ public void testComplexCaseObserverFinding() {
+
+ prepareComplexObserverFinding();
+
+ testComplexObserverFinding();
+ }
+
+ private void prepareSimpleObserverFinding() {
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q1", getPackageName(),
null);
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q2", getPackageName(),
null);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean1", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(FindObserverForEventTest.class
+ .getResourceAsStream("/resources/events/MyBean1.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean2", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(FindObserverForEventTest.class
+ .getResourceAsStream("/resources/events/MyBean2.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "EventsProducer",
getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(FindObserverForEventTest.class
+ .getResourceAsStream("/resources/events/EventsProducer.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "ObserverBean", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(FindObserverForEventTest.class
+ .getResourceAsStream("/resources/events/ObserverBean.java.cdi"),
+ false);
+ util.waitForNonIgnoredJobs();
+ }
+
+ private void testSimpleObserverFinding() {
+
+
+ for (int i = 0; i < events.length; i++) {
+ checkObserverMethodsForEvent(events[i]);
+ }
+
+
+ for (int i = 0; i < observers.length; i++) {
+ checkEventsForObserverMethods(observers[i]);
+ }
+ }
+
+ private void checkObserverMethodsForEvent(String eventName) {
+
+ String eventsClass = "EventsProducer.java";
+
+ String showObserverOption = "Show CDI Observer Methods...";
+
+ checkEventsAndObserver(eventName, eventsClass, showObserverOption);
+
+ }
+
+ private void checkEventsForObserverMethods(String observerName) {
+
+ String observerClass = "ObserverBean.java";
+
+ /**
+ * there are two observer methods for which there is only one
+ * event, so there will be no "Show CDI Events" option, instead
+ * of that, there will be "Open CDI Event" option
+ */
+ String showObserverOption = ((observerName.equals("observeQ1MyBean2")) ||
+ (observerName.equals("observeQ2MyBean2"))) ? "Open CDI Event" :
"Show CDI Events...";
+
+ checkEventsAndObserver(observerName, observerClass, showObserverOption);
+ }
+
+ private void checkEventsAndObserver(String name, String className,
+ String option) {
+ openOnUtil.openOnByOption(name, className, option);
+ bot.sleep(Timing.time1S());
+ if (option.equals("Open CDI Event")) {
+ if (name.equals("observeQ1MyBean2")) {
+ LOGGER.info("Testing observer: observeQ1MyBean2 started");
+ assertTrue(getEd().toTextEditor().getSelection().equals("myBean2Q1Event"));
+ LOGGER.info("Testing observer: observeQ1MyBean2 ended");
+ }else {
+ //observeQ1MyBean2
+ LOGGER.info("Testing observer: observeQ1MyBean2 started");
+ assertTrue(getEd().toTextEditor().getSelection().equals("myBean2Q2Event"));
+ LOGGER.info("Testing observer: observeQ1MyBean2 ended");
+ }
+ } else {
+ SWTBotTable observerTable = bot.table(0);
+ if (className.equals("EventsProducer.java")) {
+ assertTrue(checkAllObserverMethodsForEvent(name, observerTable));
+ }
+ if (className.equals("ObserverBean.java")) {
+ assertTrue(checkAllEventsForObserverMethod(name, observerTable));
+ }
+ }
+ }
+
+ private boolean checkAllObserverMethodsForEvent(String eventName,
+ SWTBotTable observerTable) {
+ String observerClass = "ObserverBean";
+ String packageProjectPath = getPackageName() + " - /" + getProjectName() +
"/src";
+ String parametrizedEventItem = observerClass + ".observeXXX() - " +
packageProjectPath;
+ boolean allObserversFound = false;
+ for (int i = 0; i < events.length; i++) {
+ if (eventName.equals(events[i])) {
+ LOGGER.info("Testing event: " + events[i] + " started");
+ switch (i) {
+ //myBean1Q1Event
+ //myBean1Q1Event.fire(new MyBean1())
+ case 0:
+ case 6:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q1MyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean1AnyEvent
+ //myBean1AnyEvent.fire(new MyBean1())
+ //myBean1AnyEvent.fire(new MyBean2())
+ case 1:
+ case 7:
+ case 12:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean2Q1Event
+ //myBean2Q1Event.fire(new MyBean2())
+ case 2:
+ case 8:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q1MyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q1MyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean2"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean2AnyEvent
+ //myBean2AnyEvent.fire(new MyBean2())
+ case 3:
+ case 9:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean2"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean1Q2Event
+ //myBean1Q2Event.fire(new MyBean1())
+ case 4:
+ case 10:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q2MyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1"))) {
+ allObserversFound = true;
+ }
+ break;
+ //myBean2Q2Event
+ //myBean2Q2Event.fire(new MyBean2())
+ case 5:
+ case 11:
+ if (observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q2MyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"Q2MyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"AnyMyBean2")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean1")) &&
+ observerTable.containsItem(parametrizedEventItem.replace("XXX",
"NoQualifierMyBean2"))) {
+ allObserversFound = true;
+ }
+ break;
+ }
+ LOGGER.info("Testing event: " + events[i] + " ended");
+ break;
+ }
+ }
+ return allObserversFound;
+ }
+
+ private boolean checkAllEventsForObserverMethod(String observerName,
+ SWTBotTable eventsTable) {
+ String eventsClass = "EventsProducer";
+ String packageProjectPath = getPackageName() + " - /" + getProjectName() +
"/src";
+ String parametrizedEventItem = eventsClass + ".myBeanXXX - " +
packageProjectPath;
+ boolean allEventsFound = false;
+ for (int i = 0; i < observers.length; i++) {
+ if (observerName.equals(observers[i])) {
+ LOGGER.info("Testing observer: " + observers[i] + " started");
+ switch (i) {
+ //observeNoQualifierMyBean1
+ //observeAnyMyBean1
+ case 0:
+ case 1:
+ if (eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1Q1Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q1Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1AnyEvent")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2AnyEvent")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1Q2Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q2Event"))) {
+ allEventsFound = true;
+ }
+ //observeQ1MyBean1
+ case 2:
+ if (eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1Q1Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q1Event"))) {
+ allEventsFound = true;
+ }
+ break;
+ //observeNoQualifierMyBean2
+ //observeAnyMyBean2
+ case 3:
+ case 4:
+ if (eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q1Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2AnyEvent")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q2Event"))) {
+ allEventsFound = true;
+ }
+ break;
+ //observeQ1MyBean2
+ case 5:
+ throw new IllegalStateException("Observer method \"observeQ1MyBean2\"
should " +
+ "have been tested earlier!!");
+ //observeQ2MyBean1
+ case 6:
+ if (eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"1Q2Event")) &&
+ eventsTable.containsItem(parametrizedEventItem.replace("XXX",
"2Q2Event"))) {
+ allEventsFound = true;
+ }
+ break;
+ //observeQ2MyBean2
+ case 7:
+ throw new IllegalStateException("Observer method \"observeQ2MyBean2\"
should " +
+ "have been tested earlier!!");
+ }
+ LOGGER.info("Testing observer: " + observers[i] + " ended");
+ break;
+ }
+ }
+ return allEventsFound;
+ }
+
+ // not implemented yet
+ private void prepareComplexObserverFinding() {
+
+ }
+
+ // not implemented yet
+ private void testComplexObserverFinding() {
+ /**
+ * main idea - check events which have multiple qualifiers defined
+ * (
http://docs.jboss.org/weld/reference/1.0.0/en-US/html/events.html -
+ * 11.6) - check events with qualifiers which has members
+ * (
http://docs.jboss.org/weld/reference/1.0.0/en-US/html/events.html -
+ * 11.5)
+ */
+ }
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnBase.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnBase.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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 org.jboss.tools.cdi.bot.test.CDITestBase;
+
+public class OpenOnBase extends CDITestBase{
+
+ public static final String[] events = { "myBean1Q1Event",
"myBean1AnyEvent",
+ "myBean2Q1Event", "myBean2AnyEvent", "myBean1Q2Event",
+ "myBean2Q2Event", "myBean1Q1Event.fire(new MyBean1());",
+ "myBean1AnyEvent.fire(new MyBean1())",
+ "myBean2Q1Event.fire(new MyBean2())",
+ "myBean2AnyEvent.fire(new MyBean2())",
+ "myBean1Q2Event.fire(new MyBean1())",
+ "myBean2Q2Event.fire(new MyBean2())",
+ "myBean1AnyEvent.fire(new MyBean2())" };
+ public static final String[] observers = { "observeNoQualifierMyBean1",
+ "observeAnyMyBean1", "observeQ1MyBean1",
+ "observeNoQualifierMyBean2", "observeAnyMyBean2",
+ "observeQ1MyBean2", "observeQ2MyBean1",
"observeQ2MyBean2" };
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/openon/OpenOnTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,321 @@
+/*******************************************************************************
+ * 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.util.logging.Logger;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+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.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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on hyperlinks-openons using CDI tools
+ *
+ * @author Jaroslav Jankovic
+ *
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class OpenOnTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger.getLogger(OpenOnTest.class.getName());
+
+ @Override
+ public String getProjectName() {
+ return "CDIOpenOnTest";
+ }
+
+ @Test
+ public void testBeanInjectOpenOn() {
+
+ prepareInjectedPointsComponents();
+
+ testInjectedPoints();
+
+ }
+
+ /**
+ *
https://issues.jboss.org/browse/JBIDE-7025
+ */
+ @Test
+ public void testBeansXMLClassesOpenOn() {
+
+ /**
+ * check if beans.xml was not wizard.created in previous tests. If so, I cannot
wizard.create
+ * beans.xml into getProjectName()/WebContent/WEB-INF/beans.xml.
+ */
+ if (!projectExplorer.isFilePresent(getProjectName(),
+ "WebContent/META-INF/beans.xml".split("/")) &&
+ !projectExplorer.isFilePresent(getProjectName(),
+ "WebContent/WEB-INF/beans.xml".split("/"))) {
+ wizard.createComponent(CDIWizardType.BEANS_XML, null, getProjectName() +
"/WebContent/WEB-INF", null);
+ }
+
+ wizard.createComponent(CDIWizardType.DECORATOR, "D1", getPackageName(),
+ "java.util.Set");
+ bot.editorByTitle("beans.xml").show();
+ bot.cTabItem("Source").activate();
+ openOnUtil.openOnDirect(getPackageName() + ".D1", "beans.xml");
+ assertTrue("ERROR: redirected to " + getEd().getTitle(),
+ getEd().getTitle().equals("D1.java"));
+
+ wizard.createComponent(CDIWizardType.INTERCEPTOR, "Interceptor1",
getPackageName(),
+ null);
+ bot.editorByTitle("beans.xml").show();
+ openOnUtil.openOnDirect(getPackageName() + ".Interceptor1",
"beans.xml");
+ assertTrue("ERROR: redirected to " + getEd(),
+ getEd().getTitle().equals("Interceptor1.java"));
+
+ wizard.createComponent(CDIWizardType.BEAN, "B1", getPackageName(),
+ "alternative+beansxml");
+ bot.editorByTitle("beans.xml").show();
+ openOnUtil.openOnDirect(getPackageName() + ".B1", "beans.xml");
+ assertTrue("ERROR: redirected to " + getEd(),
+ getEd().getTitle().equals("B1.java"));
+
+ wizard.createComponent(CDIWizardType.STEREOTYPE, "S1", getPackageName(),
+ "alternative+beansxml");
+ bot.editorByTitle("beans.xml").show();
+ openOnUtil.openOnDirect(getPackageName() + ".S1", "beans.xml");
+ assertTrue("ERROR: redirected to " + getEd(),
+ getEd().getTitle().equals("S1.java"));
+
+ }
+
+ /**
+ *
https://issues.jboss.org/browse/JBIDE-6251
+ */
+ @Test
+ public void testDisposerProducerOpenOn() {
+
+ String className = "Bean1";
+
+ wizard.createComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/BeanWithDisposerAndProducer.java.cdi"),
+ false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+ openOnUtil.openOnByOption("disposeMethod", className + ".java",
"Open Bound Producer");
+ assertTrue(getEd().toTextEditor().getSelection().equals("produceMethod"));
+
+ openOnUtil.openOnByOption("produceMethod", className + ".java",
"Open Bound Disposer");
+ assertTrue(getEd().toTextEditor().getSelection().equals("disposeMethod"));
+ }
+
+ @Test
+ public void testObserverOpenOn() {
+ wizard.createComponent(CDIWizardType.BEAN, "EventBean", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/EventBean.java.cdi"),
+ false);
+ wizard.createComponent(CDIWizardType.BEAN, "ObserverBean", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/ObserverBean.java.cdi"),
+ false);
+
+ bot.editorByTitle("EventBean.java").show();
+ setEd(bot.activeEditor().toTextEditor());
+ editResourceUtil.replaceInEditor(" event", " event");
+
+ openOnUtil.openOnByOption("observerMethod", "ObserverBean.java",
"Open CDI Event");
+ assertTrue(getEd().toTextEditor().getSelection().equals("event"));
+
+ openOnUtil.openOnByOption("Event<ObserverBean> event",
"EventBean.java", "Open CDI Observer Method");
+ assertTrue(getEd().toTextEditor().getSelection().equals("observerMethod"));
+ }
+
+ private void prepareInjectedPointsComponents() {
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q1", getPackageName(),
null);
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q2", getPackageName(),
null);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean1", getPackageName(),
null);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean2", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MyBean2.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean3", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MyBean3.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean4", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MyBean4.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean5", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MyBean5.java.cdi"),
+ false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MainBean", getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/openon/injectedPoints/MainBean.java.cdi"),
+ false);
+ }
+
+ private void testInjectedPoints() {
+ String injectOption = null;
+ for (int i = 1; i < 12; i++) {
+ String injectPoint = "myBean" + i;
+ injectOption = "Show All Assignable Beans...";
+ if (i > 8) injectOption = "Open @Inject Bean";
+ checkInjectedPoint(injectPoint, injectOption);
+ }
+
+ }
+
+ private void checkInjectedPoint(String injectedPoint, String option) {
+ openOnUtil.openOnByOption(injectedPoint, "MainBean.java", option);
+ bot.sleep(Timing.time1S());
+ if (option.equals("Open @Inject Bean")) {
+ LOGGER.info("Testing injected point: \"" + injectedPoint +
"\" started");
+ assertTrue(getEd().getTitle().equals("MyBean4.java"));
+ assertTrue(getEd().toTextEditor().getSelection().equals("MyBean4"));
+ LOGGER.info("Testing injected point: \"" + injectedPoint +
"\" ended");
+ } else {
+ SWTBotTable assignBeans = bot.table(0);
+ assertTrue(checkAllAssignBeans(injectedPoint, assignBeans));
+ }
+ }
+
+ private boolean checkAllAssignBeans(String injectedPoint,
+ SWTBotTable assignBeans) {
+ String packageProjectPath = getPackageName() + " - /" + getProjectName() +
"/src";
+ String paramAssignBean = "XXX - " + packageProjectPath;
+ String prodInjPoint = "@Produces MyBean3.getMyBeanXXX()";
+ boolean allassignBeans = false;
+ String indexOfInjPoint = injectedPoint.split("myBean")[1];
+ int intIndexOfInjPoint = Integer.parseInt(indexOfInjPoint);
+ LOGGER.info("Testing injected point: \"" + injectedPoint + "\"
started");
+ switch (intIndexOfInjPoint) {
+ case 1:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean1")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1")))&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX",
"1WithIMB2")))&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 2:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 3:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX",
"1WithQ1")))&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX",
"1WithIMB2Q1")))&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ1")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 4:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ1")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 5:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithQ2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithIMB2Q2"))))
{
+ allassignBeans = true;
+ }
+ break;
+ case 6:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 7:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean1")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1"))) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithIMB2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithIMB2Q1")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithIMB2Q2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithQ1")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "1WithQ2")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2"))) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ1")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 8:
+ if (assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean2")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean4")) &&
+ assignBeans.containsItem(paramAssignBean.replace("XXX",
"MyBean5")) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2"))) &&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ1")))
&&
+ assignBeans.containsItem(paramAssignBean.replace(
+ "XXX", prodInjPoint.replace("XXX", "2WithQ2")))) {
+ allassignBeans = true;
+ }
+ break;
+ case 9:
+ case 10:
+ case 11:
+ throw new IllegalStateException("Injection Point \"" + injectedPoint +
"\" should " +
+ "have been tested earlier!!");
+ }
+ LOGGER.info("Testing injected point: \"" + injectedPoint + "\"
ended");
+ return allassignBeans;
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/BeanValidationQuickFixTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,213 @@
+/*******************************************************************************
+ * 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.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.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.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class BeanValidationQuickFixTest extends QuickFixTestBase {
+
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixBeanTest";
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-8550
+ @Test
+ public void testSerializableManagedBean() {
+
+ String className = "ManagedBean";
+
+ wizard.createComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource( BeanValidationQuickFixTest.class
+ .getResourceAsStream("/resources/quickfix/SerializableBean.java.cdi"),
false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.SERIALIZABLE, CDIWizardType.BEAN);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7635
+ @Test
+ public void testMultipleBeansQF() {
+ String animalClassName = "Animal";
+ String dogClassName = "Dog";
+ String brokenFarmClassName = "BrokenFarm";
+
+
+ wizard.createComponent(CDIWizardType.BEAN, brokenFarmClassName, getPackageName(),
null);
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Q1", getPackageName(),
null);
+
+ wizard.createComponent(CDIWizardType.BEAN, animalClassName, getPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.BEAN, dogClassName, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(BeanValidationQuickFixTest.class
+ .getResourceAsStream("/resources/quickfix/Dog.java.cdi"), false);
+
+ bot.editorByTitle(brokenFarmClassName + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+ editResourceUtil.replaceClassContentByResource(BeanValidationQuickFixTest.class
+ .getResourceAsStream("/resources/quickfix/BrokenFarm.java.cdi"),
+ false);
+
+ bot.sleep(TIME_1S);
+ util.waitForNonIgnoredJobs();
+
+ resolveMultipleBeans();
+
+ checkMultipleBean();
+ }
+
+ @Ignore
+ //
https://issues.jboss.org/browse/JBIDE-7664
+ @Test
+ public void testConstructor() {
+
+ String className = "Bean1";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ConstructorWithParam.java.cdi"),
false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ConstructorWithParam.java.cdi"),
false);
+
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+ }
+ @Ignore
+ //
https://issues.jboss.org/browse/JBIDE-7665
+ @Test
+ public void testProducer() {
+
+ String className = "Bean2";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ProducerWithParam.java.cdi"),
false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ProducerWithParam.java.cdi"),
false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+
+ }
+ @Ignore
+ //
https://issues.jboss.org/browse/JBIDE-7667
+ @Test
+ public void testInjectDisposer() {
+
+ String className = "Bean3";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/BeanInjectDisposes.java.cdi"),
false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.BEAN);
+
+ }
+ @Ignore
+ //
https://issues.jboss.org/browse/JBIDE-7667
+ @Test
+ public void testInjectObserver() {
+
+ String className = "Bean4";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/BeanInjectDisposes.java.cdi"),
false);
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+
+ }
+ @Ignore
+ //
https://issues.jboss.org/browse/JBIDE-7667
+ @Test
+ public void testInjectProducer() {
+
+ String className = "Bean5";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/BeanInjectProducer.java.cdi"),
false);
+
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.BEAN);
+
+ }
+ @Ignore
+ //
https://issues.jboss.org/browse/JBIDE-7668
+ @Test
+ public void testObserverWithDisposer() {
+
+ String className = "Bean6";
+
+ wizard.createCDIComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/bean/ObserverWithDisposer.java.cdi"),
+ false);
+
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.BEAN);
+
+ }
+
+}
Deleted:
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-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/CDIQuickFixTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,799 +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.quickfix;
-
-
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
-import org.jboss.tools.cdi.bot.test.uiutils.actions.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.view.ProblemsView;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test operates on quick fixes of CDI components validation
- *
- * @author Jaroslav Jankovic
- */
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class })
-public class CDIQuickFixTest extends CDIBase {
-
- private static SWTBotTreeItem[] problemsTrees;
- private static final String LINE_SEPARATOR =
System.getProperty("line.separator");
-
- @Override
- public String getProjectName() {
- return "CDIQuickFixTest";
- }
-
- /*
- * check problems (warnings and errors in Problems View)
- */
- @Override
- public void waitForJobs() {
- checkProjectAllProblems();
- util.waitForNonIgnoredJobs();
- /**
- * needed for creating non-dependant components
- */
- projectExplorer.selectProject(getProjectName());
- }
-
-
- @Test
- public void testSerializableQF() {
-
-
- String className = "B1";
- createComponent(CDICOMPONENT.BEAN, className, getPackageName(), null);
-
- //
https://issues.jboss.org/browse/JBIDE-8550
- checkSerializableAnnotation(CDICOMPONENT.BEAN, className);
- }
-
- @Test
- public void testMultipleBeansQF() {
- String className = "BrokenFarm";
- createComponent(CDICOMPONENT.BEAN, className, getPackageName(), null);
-
- //
https://issues.jboss.org/browse/JBIDE-7635
- checkMultipleBeans(CDICOMPONENT.BEAN, className);
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about Stereoscope component
- */
-
- @Test
- public void testStereoscopeQF() {
- String className = "S1";
- prepareCdiComponent(CDICOMPONENT.STEREOSCOPE, className);
-
- // 1.QF -
https://issues.jboss.org/browse/JBIDE-7630
- checkTargetAnnotation(CDICOMPONENT.STEREOSCOPE, className);
-
- // 2.QF -
https://issues.jboss.org/browse/JBIDE-7631
- checkRetentionAnnotation(CDICOMPONENT.STEREOSCOPE, className);
-
- // 3.QF -
https://issues.jboss.org/browse/JBIDE-7634
- checkNamedAnnotation(CDICOMPONENT.STEREOSCOPE, className);
-
- // 4.QF -
https://issues.jboss.org/browse/JBIDE-7640
- checkTypedAnnotation(CDICOMPONENT.STEREOSCOPE, className);
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about Qualifier component
- */
-
- @Test
- public void testQualifiersQF() {
- String className = "Q2";
- prepareCdiComponent(CDICOMPONENT.QUALIFIER, className);
-
- // 1.QF -
https://issues.jboss.org/browse/JBIDE-7631
- checkRetentionAnnotation(CDICOMPONENT.QUALIFIER, className);
-
- // 2.QF -
https://issues.jboss.org/browse/JBIDE-7632
- checkTargetAnnotation(CDICOMPONENT.QUALIFIER, className);
-
- // 3.QF -
https://issues.jboss.org/browse/JBIDE-7641
- checkNonBindingAnnotation(CDICOMPONENT.QUALIFIER, className);
-
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about Scope component
- */
-
- @Test
- public void testScopeQF() {
- String className = "Scope1";
- prepareCdiComponent(CDICOMPONENT.SCOPE, className);
-
- // 1.QF -
https://issues.jboss.org/browse/JBIDE-7631
- checkRetentionAnnotation(CDICOMPONENT.SCOPE, className);
-
- // 2.QF -
https://issues.jboss.org/browse/JBIDE-7633
- checkTargetAnnotation(CDICOMPONENT.SCOPE, className);
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about general Bean component
- */
-
- @Test
- public void testBeanQF() {
- String className = "MyBean";
- prepareCdiComponent(CDICOMPONENT.BEAN, className);
-
- // 1.QF -
https://issues.jboss.org/browse/JBIDE-7664
- checkConstructor(CDICOMPONENT.BEAN, className);
-
- // 2.QF -
https://issues.jboss.org/browse/JBIDE-7665
- checkProducerMethod(CDICOMPONENT.BEAN, ANNOTATIONS.DISPOSES, className);
-
- // 3.QF -
https://issues.jboss.org/browse/JBIDE-7667
- checkObserverDisposerMethod(CDICOMPONENT.BEAN, className);
-
- // 4.QF -
https://issues.jboss.org/browse/JBIDE-7668
- checkObserWithDisposParamMethod(CDICOMPONENT.BEAN, className);
-
- // 5.QF -
https://issues.jboss.org/browse/JBIDE-7680
- checkSessionBean(CDICOMPONENT.BEAN, className);
- }
-
- /*
- * CDI Quick Fix test operates over validation
- * concerning about Interceptors/Interceptor Binding/Decorator component
- */
-
- @Test
- public void testInterDecorQF() {
- String className = "InterDecor";
- prepareCdiComponent(CDICOMPONENT.BEAN, className);
-
- // 1.QF -
https://issues.jboss.org/browse/JBIDE-7636
- checkNamedAnnotation(CDICOMPONENT.BEAN, className);
-
- // 2.QF -
https://issues.jboss.org/browse/JBIDE-7683
- checkProducerMethod(CDICOMPONENT.BEAN, ANNOTATIONS.INTERCEPTOR, className);
-
- // 3.QF -
https://issues.jboss.org/browse/JBIDE-7684
- checkDisposesAnnotation(CDICOMPONENT.BEAN, className);
-
- // 4.QF -
https://issues.jboss.org/browse/JBIDE-7685
- checkObserveAnnotation(CDICOMPONENT.BEAN, className);
-
- // 5.QF -
https://issues.jboss.org/browse/JBIDE-7686
- checkSpecializeAnnotation(CDICOMPONENT.BEAN, "TestBean");
-
- // 6.QF -
https://issues.jboss.org/browse/JBIDE-7641
- checkNonBindingAnnotation(CDICOMPONENT.INTERBINDING, "Interceptor");
- }
-
-
- /*
- * method edits default Target form because of "one space inconsistency"
- */
- private void prepareCdiComponent(CDICOMPONENT component, String name) {
- createComponent(component, name, getPackageName(), null);
- switch (component) {
- case QUALIFIER:
- CDIUtil.replaceInEditor(getEd(), bot, "@Target({ TYPE, METHOD, PARAMETER, FIELD
})",
- "@Target({TYPE, METHOD, PARAMETER, FIELD})");
- break;
- case STEREOSCOPE:
- case SCOPE:
- CDIUtil.replaceInEditor(getEd(), bot, "@Target({ TYPE, METHOD, FIELD })",
- "@Target({TYPE, METHOD, FIELD})");
- break;
- }
- }
-
- /*
- ****************************************************************
- *
- * "prepare" like methods which prepare structure of project
- * before testing itself
- *
- ****************************************************************
- */
-
- private void prepareSerializableAnnotation() {
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/B1.java.cdi"), false);
- }
-
- private void prepareMultipleBeans(String className) {
- createComponent(CDICOMPONENT.BEAN, "Animal", getPackageName(), null);
- createComponent(CDICOMPONENT.BEAN, "Dog", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/Dog.java.cdi"), false);
- createComponent(CDICOMPONENT.QUALIFIER, "Q1", getPackageName(), null);
- bot.editorByTitle(className + ".java").show();
- setEd(bot.activeEditor().toTextEditor());
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/BrokenFarm.java.cdi"),
- false);
-
- }
-
- private void prepareNamedAnnotation(CDICOMPONENT comp,
- String className, boolean add) {
- if (comp == CDICOMPONENT.BEAN) {
- CDIUtil.insertInEditor(getEd(), bot, 1, 0, "import javax.inject.Named;" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 3, 0, "@Named" + LINE_SEPARATOR);
- if (add) {
- CDIUtil.insertInEditor(getEd(), bot, 2, 0, "import
javax.decorator.Decorator;" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 4, 0, "@Decorator" + LINE_SEPARATOR);
- } else {
- CDIUtil.replaceInEditor(getEd(), bot, "import javax.decorator.Decorator;",
- "import javax.interceptor.Interceptor;");
- CDIUtil.replaceInEditor(getEd(), bot, "@Decorator",
"@Interceptor");
- }
- } else {
- if (add) {
- CDIUtil.insertInEditor(getEd(), bot, getEd().getLineCount()-4, 0,
"@Named(\"Name\")" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 6 , 0, "import javax.inject.Named;" +
LINE_SEPARATOR);
- } else {
- CDIUtil.replaceInEditor(getEd(), bot, "@Named", "");
- CDIUtil.replaceInEditor(getEd(), bot,
- "import javax.inject.Named;", "");
- }
- }
- }
-
- private void prepareTypedAnnotation() {
- CDIUtil.insertInEditor(getEd(), bot, getEd().getLineCount()-4 , 0, "@Typed" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 6 , 0, "import
javax.enterprise.inject.Typed;" + LINE_SEPARATOR);
- }
-
- private void prepareInjectAnnot() {
- CDIUtil.insertInEditor(getEd(), bot, 3 , 1, "@Inject" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 1 , 0, "import javax.inject.Inject;" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 6 , 15, "String aaa");
- }
-
- private void prepareProducer() {
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/MyBean.java.cdi"), false);
- }
-
- private void prepareObserverDisposer() {
- prepareProducer();
- CDIUtil.replaceInEditor(getEd(), bot, "@Produces", "@Inject");
- CDIUtil.replaceInEditor(getEd(), bot, "import
javax.enterprise.inject.Produces;", "");
- CDIUtil.replaceInEditor(getEd(), bot, "String produceString", "void
method");
- CDIUtil.replaceInEditor(getEd(), bot, "return \"test\";",
"");
- }
-
- private void prepareObserWithDisposParam() {
- prepareProducer();
- CDIUtil.replaceInEditor(getEd(), bot, "import javax.inject.Inject;",
"import javax.enterprise.event.Observes;" +
- LINE_SEPARATOR + "import javax.enterprise.inject.Disposes;" +
LINE_SEPARATOR);
- CDIUtil.replaceInEditor(getEd(), bot, "@Inject", "");
- CDIUtil.replaceInEditor(getEd(), bot, "MyBean(String aaa)",
- "void method(@Observes String param1, @Disposes String param2)");
- }
-
- private void prepareCheckSessionBean(String replacement) {
- if (replacement.equals("@Decorator")) {
- CDIUtil.insertInEditor(getEd(), bot, 3, 0, "import
javax.decorator.Decorator;" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 4, 0, "import javax.ejb.Stateless;" +
LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 5, 0, "@Decorator" + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 6, 0, "@Stateless" + LINE_SEPARATOR);
- } else {
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/MyBean2.java.cdi"), false);
- }
- }
-
- private void prepareDisposesAnnot() {
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/InterDecor.java.cdi"), false);
- }
-
- private void prepareComponentsForSpecializeAnnotation(String testBeanName) {
- createComponent(CDICOMPONENT.BEAN, "AnyBean", getPackageName(), null);
- createComponent(CDICOMPONENT.INTERBINDING, "AnyBinding", getPackageName(),
null);
- createComponent(CDICOMPONENT.BEAN, testBeanName, getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/TestBean.java.cdi"), false);
- }
-
-
- /*
- ****************************************************************
- *
- * "check" like methods which are the most general method to test
- * CDI components with various annotations, replacements and so on
- *
- ****************************************************************
- */
-
-
- private void checkSerializableAnnotation(CDICOMPONENT comp, String className) {
- prepareSerializableAnnotation();
- checkQuickFix(ANNOTATIONS.SERIALIZABLE, comp, className, "Serializable");
- cleanWarnings(className);
- }
-
- private void checkMultipleBeans(CDICOMPONENT comp, String className) {
- prepareMultipleBeans(className);
- checkQuickFix(ANNOTATIONS.NAMED, comp, className, "MultipleBeans");
- }
-
- private void checkTargetAnnotation(CDICOMPONENT comp, String className) {
- checkTargetAnnotWithAddon(comp, className, "@Target({TYPE, FIELD})");
- checkTargetAnnotWithAddon(comp, className, "");
- }
-
- private void checkTargetAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- switch (comp) {
- case STEREOSCOPE:
- case SCOPE:
- CDIUtil.replaceInEditor(getEd(), bot,
- "@Target({TYPE, METHOD, FIELD})", replacement);
- break;
- case QUALIFIER:
- if (replacement.equals("")) {
- CDIUtil.replaceInEditor(getEd(), bot,
- "@Target({TYPE, METHOD, FIELD, PARAMETER})", replacement);
- } else {
- CDIUtil.replaceInEditor(getEd(), bot,
- "@Target({TYPE, METHOD, PARAMETER, FIELD})", replacement);
- }
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.ElementType.PARAMETER;",
"");
- break;
- }
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.ElementType.METHOD;", "");
- if (replacement.equals("")) {
- CDIUtil.replaceInEditor(getEd(), bot,
- "import java.lang.annotation.Target;", "");
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.ElementType.TYPE;", "");
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.ElementType.FIELD;", "");
- }
- checkQuickFix(ANNOTATIONS.TARGET, comp, className, replacement);
- }
-
- private void checkRetentionAnnotation(CDICOMPONENT comp, String className) {
- checkRetentionAnnotWithAddon(comp, className, "@Retention(CLASS)");
- checkRetentionAnnotWithAddon(comp, className, "");
- }
-
- private void checkRetentionAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- CDIUtil.replaceInEditor(getEd(), bot, "@Retention(RUNTIME)", replacement);
- if (replacement.equals("@Retention(CLASS)")) {
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.RetentionPolicy.RUNTIME;",
- "import static java.lang.annotation.RetentionPolicy.CLASS;");
- } else {
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static java.lang.annotation.RetentionPolicy.RUNTIME;",
- "");
- CDIUtil.replaceInEditor(getEd(), bot,
- "import java.lang.annotation.Retention;", "");
- }
- checkQuickFix(ANNOTATIONS.RETENTION, comp, className, replacement);
- if (replacement.equals("@Retention(CLASS)")) {
- CDIUtil.replaceInEditor(getEd(), bot,
- "import static
java.lang.annotation.RetentionPolicy.CLASS;","");
- }
- }
-
- private void checkNamedAnnotation(CDICOMPONENT comp, String className) {
- if (className.equals("InterDecor")) {
- prepareNamedAnnotation(comp, className, true);
- checkNamedAnnotWithAddon(comp, className, "@Named");
- prepareNamedAnnotation(comp, className, false);
- checkNamedAnnotWithAddon(comp, className, "@Named");
- } else {
- prepareNamedAnnotation(comp, className, true);
- checkNamedAnnotWithAddon(comp, className, "@Named");
- prepareNamedAnnotation(comp, className, false);
- prepareNamedAnnotation(comp, className, true);
- checkNamedAnnotWithAddon(comp, className, "");
- }
- }
-
- private void checkNamedAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- checkQuickFix(ANNOTATIONS.NAMED, comp, className, replacement);
- }
-
- private void checkTypedAnnotation(CDICOMPONENT comp, String className) {
- prepareTypedAnnotation();
- checkTypedAnnotWithAddon(comp, className, "");
- }
-
- private void checkTypedAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- checkQuickFix(ANNOTATIONS.TYPED, comp, className, replacement);
- }
-
- private void checkConstructor(CDICOMPONENT comp, String className) {
- prepareInjectAnnot();
- checkConstructorWithAddon(comp, className, "@Disposes");
- checkConstructorWithAddon(comp, className, "@Observes");
- }
-
- private void checkConstructorWithAddon(CDICOMPONENT comp,
- String className, String replacement) {
- CDIUtil.insertInEditor(getEd(), bot, 6, 15, replacement + " ");
- dispObserCompletion(comp, className, replacement);
- }
-
- private void checkProducerMethod(CDICOMPONENT comp, ANNOTATIONS annonType, String
className) {
- if (className.equals("InterDecor")) {
- prepareProducer();
- CDIUtil.replaceInEditor(getEd(), bot, "MyBean", "InterDecor");
- checkProducerWithAddon(comp, annonType, className, "@Interceptor");
- prepareProducer();
- CDIUtil.replaceInEditor(getEd(), bot, "MyBean", "InterDecor");
- checkProducerWithAddon(comp, annonType, className, "@Decorator");
- } else {
- prepareProducer();
- checkProducerWithAddon(comp, annonType, className, "@Disposes");
- checkProducerWithAddon(comp, annonType, className, "@Observes");
- }
- }
-
- private void checkProducerWithAddon(CDICOMPONENT comp, ANNOTATIONS annonType,
- String className, String replacement) {
- if (className.equals("InterDecor")) {
- String annot =
replacement.equals("@Interceptor")?"@Interceptor":"@Decorator";
- String importAnnot = replacement.equals("@Interceptor")?
- "import javax.interceptor.Interceptor;":
- "import javax.decorator.Decorator;";
- CDIUtil.insertInEditor(getEd(), bot, 3, 0, annot + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 1, 0, importAnnot + LINE_SEPARATOR);
- checkQuickFix(replacement.equals("(a)Interceptor")?ANNOTATIONS.INTERCEPTOR:
- ANNOTATIONS.DECORATOR, comp, className, replacement);
- } else {
- CDIUtil.insertInEditor(getEd(), bot, 11, 29, replacement + " ");
- dispObserCompletion(comp, className, replacement);
- }
- }
-
- private void checkObserverDisposerMethod(CDICOMPONENT comp, String className) {
- prepareObserverDisposer();
- checkObserverDisposerWithAddon(comp, className, "@Disposes");
- checkObserverDisposerWithAddon(comp, className, "@Observes");
- }
-
- private void checkObserverDisposerWithAddon(CDICOMPONENT comp,
- String className, String replacement) {
- CDIUtil.insertInEditor(getEd(), bot, 10, 20, replacement + " ");
- dispObserCompletion(comp, className, replacement);
- }
-
- private void checkObserWithDisposParamMethod(CDICOMPONENT comp, String className) {
- prepareObserWithDisposParam();
- checkObserWithDisposParamWithAddon(comp, className, "@Disposes");
- checkObserWithDisposParamWithAddon(comp, className, "@Observes");
- }
-
- private void checkObserWithDisposParamWithAddon(CDICOMPONENT comp,
- String className, String replacement) {
- if (replacement.equals("@Observes")) {
- CDIUtil.insertInEditor(getEd(), bot, 3, 0, "import
javax.enterprise.inject.Disposes;");
- CDIUtil.insertInEditor(getEd(), bot, 6, 46, "@Disposes ");
- }
- checkQuickFix(replacement.equals("@Disposes")?ANNOTATIONS.DISPOSES:ANNOTATIONS.OBSERVES,
- CDICOMPONENT.BEAN, className, "");
- }
-
- private void checkSessionBean(CDICOMPONENT comp, String className) {
- checkSessionBeanWithAddon(comp, className, "@Decorator");
- checkSessionBeanWithAddon(comp, className, "@Interceptor");
- }
-
- private void checkSessionBeanWithAddon(CDICOMPONENT comp,
- String className, String replacement) {
- prepareCheckSessionBean(replacement);
- checkQuickFix(replacement.equals("@Decorator")?ANNOTATIONS.DECORATOR:ANNOTATIONS.INTERCEPTOR,
- comp, className, replacement);
- }
-
- private void dispObserCompletion(CDICOMPONENT comp, String className, String
replacement) {
- CDIUtil.insertInEditor(getEd(), bot, 2 , 0, "import javax.enterprise." +
- (replacement.contains("Disposes")?"inject.":"event.") +
- (replacement.substring(1) + ";" + LINE_SEPARATOR));
- ANNOTATIONS annonType =
(replacement.equals("@Disposes")?ANNOTATIONS.DISPOSES:ANNOTATIONS.OBSERVES);
- checkQuickFix(annonType, comp, className, replacement);
- }
-
- private void checkDisposesAnnotation(CDICOMPONENT comp, String className) {
- checkDisposesAnnotWithAddon(comp, className, "@Decorator");
- checkDisposesAnnotWithAddon(comp, className, "@Interceptor");
- }
-
- private void checkDisposesAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- prepareDisposesAnnot();
- String annot = replacement;
- String importAnnot = "import javax." + replacement.substring(1).toLowerCase()
- + "." + replacement.substring(1) + ";";
- CDIUtil.insertInEditor(getEd(), bot, 2, 0, annot + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 1, 0, importAnnot + LINE_SEPARATOR);
- checkQuickFix(ANNOTATIONS.DECORATOR, comp, className, replacement);
- }
-
- private void checkObserveAnnotation(CDICOMPONENT comp, String className) {
- checkObserveAnnotWithAddon(comp, className, "@Decorator");
- checkObserveAnnotWithAddon(comp, className, "@Interceptor");
- CDIUtil.replaceInEditor(getEd(), bot, "@Interceptor", "");
- CDIUtil.replaceInEditor(getEd(), bot, "import
javax.interceptor.Interceptor;", "");
- }
-
- private void checkObserveAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- prepareDisposesAnnot();
- CDIUtil.replaceInEditor(getEd(), bot, "@Disposes", "@Observes");
- CDIUtil.replaceInEditor(getEd(), bot, "import
javax.enterprise.inject.Disposes;",
- "import javax.enterprise.event.Observes;");
- CDIUtil.replaceInEditor(getEd(), bot, "dispose", "observe");
- String annot = replacement;
- String importAnnot = "import javax." + replacement.substring(1).toLowerCase()
- + "." + replacement.substring(1) + ";";
- CDIUtil.insertInEditor(getEd(), bot, 2, 0, annot + LINE_SEPARATOR);
- CDIUtil.insertInEditor(getEd(), bot, 1, 0, importAnnot + LINE_SEPARATOR);
- checkQuickFix(ANNOTATIONS.DECORATOR, comp, className, replacement);
- }
-
- private void checkSpecializeAnnotation(CDICOMPONENT comp, String className) {
- prepareComponentsForSpecializeAnnotation(className);
- checkSpecializeAnnotWithAddon(comp, className, "@Interceptor");
- checkSpecializeAnnotWithAddon(comp, className, "@Decorator");
- CDIUtil.copyResourceToClass(getEd(),
- CDIQuickFixTest.class.getResourceAsStream("/resources/cdi/TestBean3.java.cdi"),
false);
- }
-
- private void checkSpecializeAnnotWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- if (replacement.equals("@Decorator")) {
- CDIUtil.copyResourceToClass(getEd(),
- CDIQuickFixTest.class.getResourceAsStream("/resources/cdi/TestBean2.java.cdi"),
false);
- }
- checkQuickFix(ANNOTATIONS.SPECIALIZES, comp, className, replacement);
- }
-
- private void checkNonBindingAnnotation(CDICOMPONENT comp, String className) {
- checkNonBindingAnnotationWithAddon(comp, className, "Annotation");
- checkNonBindingAnnotationWithAddon(comp, className, "Array");
-
- }
-
- private void checkNonBindingAnnotationWithAddon(CDICOMPONENT comp, String className,
- String replacement) {
- if (comp == CDICOMPONENT.INTERBINDING) {
- boolean interceptorCreated = projectExplorer.isFilePresent(getProjectName(),
- "Java Resources", "src", getPackageName(), className +
".java");
- if (!interceptorCreated) {
- createComponent(CDICOMPONENT.INTERBINDING, className, getPackageName(), null);
- }
- }
-
- if (replacement.equals("Annotation")) {
- boolean annotationCreated = projectExplorer.isFilePresent(getProjectName(),
- "Java Resources", "src", getPackageName(),
"AAnnotation.java");
- if (!annotationCreated) {
- createComponent(null, "AAnnotation", getPackageName(), null);
- }
- bot.editorByTitle(className + ".java").show();
- setEd(bot.activeEditor().toTextEditor());
- CDIUtil.insertInEditor(getEd(), bot, getEd().getLineCount()-3, 1, "AAnnotation
annotValue();" + LINE_SEPARATOR);
- }else {
- CDIUtil.insertInEditor(getEd(), bot, getEd().getLineCount()-3, 1, "String[]
array();" + LINE_SEPARATOR);
- }
- checkQuickFix(ANNOTATIONS.NONBINDING, comp, className, replacement);
- }
-
- /*
- ****************************************************************
- *
- * checkQuickFix is the most important method in this class. It
- * gets validation error prior to component type, annotation and
- * class name, then it resolve validation error through quick fix
- * wizard and finally check if validation errors was fixed through
- * this wizard
- *
- ****************************************************************
- */
-
- private void checkQuickFix(ANNOTATIONS annonType, CDICOMPONENT comp,
- String className, String replacement) {
- problemsTrees = getProblems(annonType, comp, className + ".java");
- assertTrue(problemsTrees.length != 0);
- resolveQuickFix(annonType, comp, replacement);
- problemsTrees = getProblems(annonType, comp, className + ".java");
- assertTrue(problemsTrees.length == 0);
- }
-
- private SWTBotTreeItem[] getProblems(ANNOTATIONS annonType, CDICOMPONENT comp, String
className) {
- SWTBotTreeItem[] problemsTree;
- boolean warningType = true;
- switch (annonType) {
- case NAMED:
- case SPECIALIZES:
- case SERIALIZABLE:
- warningType = ((comp == CDICOMPONENT.BEAN)?true:false);
- break;
- case DISPOSES:
- case OBSERVES:
- case DECORATOR:
- case INTERCEPTOR:
- warningType = false;
- break;
- }
- String problemsContains = null;
- if (warningType) {
- switch (annonType) {
- case SPECIALIZES:
- problemsContains = "@Specializes";
- break;
- case NONBINDING:
- problemsContains = "@Nonbinding";
- break;
- case SERIALIZABLE:
- problemsContains = "declares a passivating scope SessionScoped";
- break;
- case NAMED:
- problemsContains = "should not have a name";
- }
-
- if (className.equals("BrokenFarm.java")) {
- problemsContains = "Multiple beans are eligible";
- }
- problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, problemsContains,
"/"
- + getProjectName(), className, "CDI Problem");
- } else {
- if (className.equals("InterDecor.java")) {
- if (getEd().toTextEditor().getText().contains("produceString")) {
- problemsContains = "Producer cannot be declared in";
- }
- if (getEd().toTextEditor().getText().contains("disposeMethod")) {
- problemsContains = "has a method annotated @Disposes";
- }
- if (getEd().toTextEditor().getText().contains("observeMethod")) {
- problemsContains = "have a method with a parameter annotated @Observes";
- }
- }
- problemsTree = ProblemsView.getFilteredErrorsTreeItems(bot, problemsContains,
"/"
- + getProjectName(), className, "CDI Problem");
- }
- return problemsTree;
- }
-
- private void resolveQuickFix(ANNOTATIONS annonType, CDICOMPONENT comp, String
replacement) {
- if (replacement.equals("MultipleBeans")) {
- resolveMultipleBeans();
- }else {
- int index = indexDetermine(annonType, comp, replacement);
- resolve(annonType, replacement, index);
- }
- }
-
- private int indexDetermine(ANNOTATIONS annonType, CDICOMPONENT comp, String replacement)
{
- boolean chooseFirstOption = true;
- if (annonType == ANNOTATIONS.NAMED && replacement.equals("")) {
- chooseFirstOption = false;
- }
- if ((comp == CDICOMPONENT.BEAN && annonType == ANNOTATIONS.DISPOSES) ||
- (comp == CDICOMPONENT.BEAN && annonType == ANNOTATIONS.OBSERVES)) {
- if ((problemsTrees[0].getText().contains("Producer method has a parameter
annotated "
- + replacement)) ||
- (problemsTrees[0].getText().contains("method cannot be annotated @Inject"))
||
- (annonType == ANNOTATIONS.OBSERVES &&
- problemsTrees[0].getText().contains("Observer method has a parameter annotated
@Disposes"))) {
- chooseFirstOption = false;
- }
- }
- return chooseFirstOption?0:1;
- }
-
- private void resolve(ANNOTATIONS annonType, String replacement, int index) {
- CDIUtil.openQuickFix(problemsTrees[0], bot);
- bot.table(0).click(index, 0);
- assertFalse(bot.button("Finish").isEnabled());
- bot.table(1).getTableItem(0).check();
- assertTrue(bot.button("Finish").isEnabled());
- bot.clickButton("Finish");
- bot.sleep(Timing.time1S());
- util.waitForNonIgnoredJobs();
- }
-
- private void resolveMultipleBeans() {
- CDIUtil.openQuickFix(problemsTrees[0], bot);
- String qualifBean = null;
- if (bot.table(0).cell(0, 0).contains("Animal")) {
- qualifBean = "Animal";
- } else {
- qualifBean = "Dog";
- }
- bot.activeShell().bot().button("Finish").click();
- bot.sleep(Timing.time1S());
- util.waitForNonIgnoredJobs();
- assertFalse(bot.button("Add >").isEnabled());
- assertFalse(bot.button("Finish").isEnabled());
- bot.table(0).click(bot.table(0).indexOf("Q1 - " + getPackageName()), 0);
- assertTrue(bot.button("Add >").isEnabled());
- assertFalse(bot.button("Finish").isEnabled());
- bot.clickButton("Add >");
- assertTrue(bot.button("Finish").isEnabled());
- bot.clickButton("Finish");
-
- bot.sleep(Timing.time1S());
- util.waitForNonIgnoredJobs();
- String code = getEd().toTextEditor().getText();
- assertTrue(code.contains("@Inject @Q1 private Animal animal;"));
- code = bot.editorByTitle(qualifBean + ".java").toTextEditor().getText();
- assertTrue(code.contains("@Q1"));
- }
-
- /*
- * method gets all the problems by all classes in the project.
- * Type of problems (warning, error) is chosen by proper value in parameter
- */
-
- private void checkProjectAllProblems() {
- problemsTrees = getAllProblems(PROBLEM_TYPE.WARNINGS);
- assertTrue(problemsTrees.length == 0);
- problemsTrees = getAllProblems(PROBLEM_TYPE.ERRORS);
- assertTrue(problemsTrees.length == 0);
- }
-
- private SWTBotTreeItem[] getAllProblems(PROBLEM_TYPE problemType) {
- SWTBotTreeItem[] problemsTree = null;
- if (problemType == PROBLEM_TYPE.WARNINGS) {
- problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
- + getProjectName(), null, null);
- }else if (problemType == PROBLEM_TYPE.ERRORS) {
- problemsTree = ProblemsView.getFilteredErrorsTreeItems(bot, null, "/"
- + getProjectName(), null, null);
- }
- return problemsTree;
- }
-
- private void cleanWarnings(String className) {
- problemsTrees = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
- + getProjectName(), className + ".java", null);
- assertTrue(problemsTrees.length != 0);
- CDIUtil.openQuickFix(problemsTrees[0], bot);
- bot.clickButton("Finish");
- bot.sleep(Timing.time1S());
- bot.activeEditor().save();
- problemsTrees = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
- + getProjectName(), className, "CDI Problem");
- assertTrue(problemsTrees.length == 0);
- }
-}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/DecoratorValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/DecoratorValidationQuickFixTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/DecoratorValidationQuickFixTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,172 @@
+/*******************************************************************************
+ * 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.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class DecoratorValidationQuickFixTest extends QuickFixTestBase {
+
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixDecoratorTest";
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7680
+ @Test
+ public void testSessionAnnotation() {
+
+ String className = "Decorator1";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithStateless.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.STATELESS, CDIWizardType.DECORATOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7636
+ @Test
+ public void testNamedAnnotation() {
+
+ String className = "Decorator2";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithNamed.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NAMED, CDIWizardType.DECORATOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7683
+ @Test
+ public void testProducer() {
+
+ String className = "Decorator3";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithProducer.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.DECORATOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7684
+ @Test
+ public void testDisposesAnnotation() {
+
+ String className = "Decorator4";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.DECORATOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7685
+ @Test
+ public void testObservesAnnotation() {
+
+ String className = "Decorator5";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.DECORATOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7686
+ @Test
+ public void testSpecializesAnnotation() {
+
+ String className = "Decorator6";
+
+ wizard.createCDIComponent(CDIWizardType.DECORATOR, className,
+ getPackageName(), "java.util.set");
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/decorator/" +
+ "DecoratorWithSpecializes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("DecoratorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.SPECIALIZES, CDIWizardType.DECORATOR);
+
+ }
+
+}
\ No newline at end of file
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/IBindingValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/IBindingValidationQuickFixTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/IBindingValidationQuickFixTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class IBindingValidationQuickFixTest extends QuickFixTestBase {
+
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixIBindingTest";
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7641
+ @Test
+ public void testNonbindingAnnotation() {
+
+ String className = "IBinding1";
+
+ wizard.createAnnotation("AAnnotation", getPackageName());
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR_BINDING,
+ className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptorBinding/" +
+ "IBindingWithAnnotation.java.cdi"), false);
+ editResourceUtil.replaceInEditor("IBindingComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.INTERCEPTOR_BINDING);
+
+ editResourceUtil.replaceInEditor("@Nonbinding AAnnotation",
"String[]");
+
+ checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.INTERCEPTOR_BINDING);
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/InterceptorValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/InterceptorValidationQuickFixTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/InterceptorValidationQuickFixTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * 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.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class InterceptorValidationQuickFixTest extends QuickFixTestBase {
+
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixInterceptorTest";
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7680
+ @Test
+ public void testSessionAnnotation() {
+
+ String className = "Interceptor1";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(),
null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithStateless.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.STATELESS, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7636
+ @Test
+ public void testNamedAnnotation() {
+
+ String className = "Interceptor2";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(),
null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithNamed.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NAMED, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7683
+ @Test
+ public void testProducer() {
+
+ String className = "Interceptor3";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(),
null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithProducer.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.PRODUCES, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7684
+ @Test
+ public void testDisposesAnnotation() {
+
+ String className = "Interceptor4";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(),
null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.DISPOSES, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7685
+ @Test
+ public void testObservesAnnotation() {
+
+ String className = "Interceptor5";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(),
null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithDisposes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("import javax.enterprise.inject.Disposes;",
+ "import javax.enterprise.event.Observes;");
+ editResourceUtil.replaceInEditor("@Disposes", "@Observes");
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.OBSERVES, CDIWizardType.INTERCEPTOR);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7686
+ @Test
+ public void testSpecializesAnnotation() {
+
+ String className = "Interceptor6";
+
+ wizard.createCDIComponent(CDIWizardType.INTERCEPTOR, className, getPackageName(),
null);
+ bot.editorByTitle(className + ".java").show();
+ setEd(bot.activeEditor().toTextEditor());
+
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/interceptor/" +
+ "InterceptorWithSpecializes.java.cdi"), false);
+ editResourceUtil.replaceInEditor("InterceptorComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.SPECIALIZES, CDIWizardType.INTERCEPTOR);
+
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QualifierValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QualifierValidationQuickFixTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QualifierValidationQuickFixTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * 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.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class QualifierValidationQuickFixTest extends QuickFixTestBase {
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixQualifierTest";
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7630
+ @Test
+ public void testTargetAnnotation() {
+
+ String className = "Qualifier1";
+
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Target({ TYPE, METHOD, PARAMETER, FIELD
})",
+ "@Target({ TYPE, FIELD })");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.QUALIFIER);
+
+ editResourceUtil.replaceInEditor("@Target({TYPE, METHOD, FIELD, PARAMETER})",
"");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.QUALIFIER);
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7631
+ @Test
+ public void testRetentionAnnotation() {
+
+ String className = "Qualifier2";
+
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)",
"@Retention(CLASS)");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.QUALIFIER);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.QUALIFIER);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7641
+ @Test
+ public void testNonbindingAnnotation() {
+
+ String className = "Qualifier3";
+
+ wizard.createAnnotation("AAnnotation", getPackageName());
+ wizard.createCDIComponent(CDIWizardType.QUALIFIER, className, getPackageName(), null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/qualifier/QualifierWithAnnotation.java.cdi"),
false);
+ editResourceUtil.replaceInEditor("QualifierComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.QUALIFIER);
+
+ editResourceUtil.replaceInEditor("@Nonbinding AAnnotation",
"String[]");
+
+ checkQuickFix(CDIAnnotationsType.NONBINDING, CDIWizardType.QUALIFIER);
+ }
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/QuickFixTestBase.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * 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.quickfix;
+
+
+import java.util.ArrayList;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.BeanValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.DecoratorValidationProvider;
+import
org.jboss.tools.cdi.bot.test.quickfix.validators.InterceptorBindingValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.InterceptorValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.QualifierValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.ScopeValidationProvider;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.StereotypeValidationProvider;
+import org.jboss.tools.cdi.bot.test.uiutils.QuickFixHelper;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.junit.BeforeClass;
+
+/**
+ * Test base for all QuickFix-like tests
+ *
+ * @author Jaroslav Jankovic
+ */
+
+public class QuickFixTestBase extends QuickFixHelper {
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createCDIProject(getProjectName());
+ }
+ }
+
+ @BeforeClass
+ public static void setup() {
+ problems.show();
+ }
+
+
+ /**
+ * checkQuickFix is the most important method in this class. It
+ * gets validation error prior to component type and annotation type,
+ * then it resolve validation error through quick fix
+ * wizard and finally check if validation errors was fixed through
+ * this wizard
+ * @param annonType
+ * @param compType
+ */
+ public void checkQuickFix(CDIAnnotationsType annonType, CDIWizardType compType) {
+ SWTBotTreeItem validationProblem = getProblem(annonType, compType);
+ assertNotNull(validationProblem);
+ resolveQuickFix(validationProblem);
+ validationProblem = getProblem(annonType, compType);
+ assertNull(validationProblem);
+ }
+
+ /**
+ * Methods gets the particular validation problem located in Problems View by
+ * using specific ValidationErrorsProvider
+ * @param annonType
+ * @param compType
+ * @return
+ */
+ private SWTBotTreeItem getProblem(CDIAnnotationsType annonType, CDIWizardType compType)
{
+ switch (compType) {
+ case STEREOTYPE:
+ validationErrorsProvider = new StereotypeValidationProvider();
+ break;
+ case QUALIFIER:
+ validationErrorsProvider = new QualifierValidationProvider();
+ break;
+ case SCOPE:
+ validationErrorsProvider = new ScopeValidationProvider();
+ break;
+ case BEAN:
+ validationErrorsProvider = new BeanValidationProvider();
+ break;
+ case INTERCEPTOR:
+ validationErrorsProvider = new InterceptorValidationProvider();
+ break;
+ case DECORATOR:
+ validationErrorsProvider = new DecoratorValidationProvider();
+ break;
+ case INTERCEPTOR_BINDING:
+ validationErrorsProvider = new InterceptorBindingValidationProvider();
+ break;
+ }
+ ArrayList<String> validationProblems = null;
+ SWTBotTreeItem[] problemsInProblemsView = null;
+ if (validationErrorsProvider.getAllWarningsAnnotation().contains(annonType)) {
+ validationProblems =
validationErrorsProvider.getAllWarningForAnnotationType(annonType);
+ problemsInProblemsView = getProblems(ProblemsType.WARNINGS);
+ } else {
+ validationProblems =
validationErrorsProvider.getAllErrorsForAnnotationType(annonType);
+ problemsInProblemsView = getProblems(ProblemsType.ERRORS);
+ }
+ for (SWTBotTreeItem ti: problemsInProblemsView) {
+ for (String validationProblem: validationProblems) {
+ if (ti.getText().contains(validationProblem)) {
+ return ti;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Method resolves particular validation problem (parameter ti).
+ * It simply open context menu for param "ti", open menu "Quick Fix"
and
+ * chooses first option and confirms it
+ *
+ * @param ti
+ */
+ private void resolveQuickFix(SWTBotTreeItem ti) {
+ openQuickFix(ti);
+ bot.table(0).click(0, 0);
+ bot.table(1).getTableItem(0).check();
+ bot.clickButton("Finish");
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+ }
+
+
+ public void resolveMultipleBeans() {
+
+ SWTBotTreeItem validationProblem = getProblem(CDIAnnotationsType.INJECT,
+ CDIWizardType.BEAN);
+
+ openQuickFix(validationProblem);
+ int indexOfAnimalBean = 0;
+ if (!bot.table(0).cell(0, 0).contains("Animal")) {
+ indexOfAnimalBean++;
+ }
+
+ bot.table(0).click(indexOfAnimalBean, 0);
+ bot.table(1).getTableItem(0).check();
+ bot.activeShell().bot().button("Finish").click();
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+
+ bot.table(0).click(bot.table(0).indexOf("Q1 - " + getPackageName()), 0);
+ bot.clickButton("Add >");
+ bot.clickButton("Finish");
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+ }
+
+ public void checkMultipleBean() {
+ String code = getEd().toTextEditor().getText();
+ assertTrue(code.contains("@Inject @Q1 private Animal animal;"));
+ code = bot.editorByTitle("Animal.java").toTextEditor().getText();
+ assertTrue(code.contains("@Q1"));
+ }
+
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/ScopeValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/ScopeValidationQuickFixTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/ScopeValidationQuickFixTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * 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.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI components validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class ScopeValidationQuickFixTest extends QuickFixTestBase {
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixScopeTest";
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7633
+ @Test
+ public void testTargetAnnotation() {
+
+ String className = "Scope1";
+
+ wizard.createCDIComponent(CDIWizardType.SCOPE, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Target({ TYPE, METHOD, FIELD })",
+ "@Target({ TYPE, FIELD })");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.SCOPE);
+
+ editResourceUtil.replaceInEditor("@Target({TYPE, METHOD, FIELD})",
"");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.SCOPE);
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7631
+ @Test
+ public void testRetentionAnnotation() {
+
+ String className = "Scope2";
+
+ wizard.createCDIComponent(CDIWizardType.SCOPE, className, getPackageName(), null);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)",
"@Retention(CLASS)");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.SCOPE);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.SCOPE);
+
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/StereotypeValidationQuickFixTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/StereotypeValidationQuickFixTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/StereotypeValidationQuickFixTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * 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.quickfix;
+
+
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+import org.jboss.tools.cdi.bot.test.annotations.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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on quick fixes of CDI stereotype component validation
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class StereotypeValidationQuickFixTest extends QuickFixTestBase {
+
+ @Override
+ public String getProjectName() {
+ return "CDIQuickFixStereotypeTest";
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7630
+ @Test
+ public void testTargetAnnotation() {
+
+ String className = "Stereotype1";
+
+ wizard.createCDIComponent(CDIWizardType.STEREOTYPE, className, getPackageName(),
null);
+
+ editResourceUtil.replaceInEditor("@Target({ TYPE, METHOD, FIELD })",
+ "@Target({ TYPE, FIELD })");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.STEREOTYPE);
+
+ editResourceUtil.replaceInEditor("@Target({TYPE, METHOD, FIELD})",
"");
+
+ checkQuickFix(CDIAnnotationsType.TARGET, CDIWizardType.STEREOTYPE);
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7631
+ @Test
+ public void testRetentionAnnotation() {
+
+ String className = "Stereotype2";
+
+ wizard.createCDIComponent(CDIWizardType.STEREOTYPE, className, getPackageName(),
null);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)",
"@Retention(CLASS)");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.STEREOTYPE);
+
+ editResourceUtil.replaceInEditor("@Retention(RUNTIME)", "");
+
+ checkQuickFix(CDIAnnotationsType.RETENTION, CDIWizardType.STEREOTYPE);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7634
+ @Test
+ public void testNamedAnnotation() {
+
+ String className = "Stereotype3";
+
+ wizard.createCDIComponent(CDIWizardType.STEREOTYPE, className, getPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/stereotype/StereotypeWithNamed.java.cdi"),
false);
+ editResourceUtil.replaceInEditor("StereotypeComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.NAMED, CDIWizardType.STEREOTYPE);
+
+ }
+
+ //
https://issues.jboss.org/browse/JBIDE-7640
+ @Test
+ public void testTypedAnnotation() {
+
+ String className = "Stereotype4";
+
+ wizard.createCDIComponent(CDIWizardType.STEREOTYPE, className, getPackageName(),
null);
+
+ editResourceUtil.replaceClassContentByResource(QuickFixTestBase.class
+ .getResourceAsStream("/resources/quickfix/stereotype/StereotypeWithTyped.java.cdi"),
false);
+ editResourceUtil.replaceInEditor("StereotypeComponent", className);
+
+ checkQuickFix(CDIAnnotationsType.TYPED, CDIWizardType.STEREOTYPE);
+
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/AbstractValidationProvider.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,54 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+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;
+
+ public AbstractValidationProvider() {
+ validationErrors = new LinkedHashMap<String, ArrayList<String>>();
+ warningsForAnnotationType = new ArrayList<String>();
+ errorsForAnnotationType = new ArrayList<String>();
+ warningsAnnotation = new ArrayList<CDIAnnotationsType>();
+ errorsAnnotation = new ArrayList<CDIAnnotationsType>();
+
+ validationErrors.put("Warnings", new ArrayList<String>());
+ validationErrors.put("Errors", new ArrayList<String>());
+
+ init();
+ }
+
+ abstract void init();
+
+ public Map<String, ArrayList<String>> getAllValidationErrors() {
+ return validationErrors;
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ return warningsForAnnotationType;
+ }
+
+ public ArrayList<CDIAnnotationsType> getAllWarningsAnnotation() {
+ return warningsAnnotation;
+ }
+
+ public ArrayList<CDIAnnotationsType> getAllErrorsAnnotation() {
+ return errorsAnnotation;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/BeanValidationProvider.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,81 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class BeanValidationProvider extends AbstractValidationProvider {
+
+ public BeanValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("which declares a passivating scope
SessionScoped " +
+ "must be passivation capable");
+ validationErrors.get("Warnings").add("Multiple beans are eligible for
injection to " +
+ "the injection point");
+ validationErrors.get("Errors").add("Bean constructor cannot have a
parameter annotated " +
+ "@Disposes");
+ validationErrors.get("Errors").add("Bean constructor cannot have a
parameter annotated " +
+ "@Observes");
+ validationErrors.get("Errors").add("Producer method has a parameter
annotated @Disposes");
+ validationErrors.get("Errors").add("Producer method has a parameter
annotated @Observes");
+ validationErrors.get("Errors").add("Disposer method cannot be annotated
@Inject");
+ validationErrors.get("Errors").add("Observer method cannot be annotated
@Inject");
+ validationErrors.get("Errors").add("Observer method has a parameter
annotated @Disposes");
+ validationErrors.get("Errors").add("Producer method or field cannot be
annotated @Inject");
+
+ warningsAnnotation.add(CDIAnnotationsType.SERIALIZABLE);
+ warningsAnnotation.add(CDIAnnotationsType.INJECT);
+
+ errorsAnnotation.add(CDIAnnotationsType.DISPOSES);
+ errorsAnnotation.add(CDIAnnotationsType.OBSERVES);
+ errorsAnnotation.add(CDIAnnotationsType.PRODUCES);
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int errorIndex = 0;
+ switch(annotationType) {
+ case DISPOSES:
+ errorIndex = 0;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 2;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 4;
+ break;
+ case OBSERVES:
+ errorIndex = 1;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 3;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 5;
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ errorIndex = 6;
+ break;
+ case PRODUCES:
+ errorIndex = 7;
+ break;
+ }
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case SERIALIZABLE:
+ warningIndex = 0;
+ break;
+ case INJECT:
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/DecoratorValidationProvider.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,72 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class DecoratorValidationProvider extends AbstractValidationProvider {
+
+ public DecoratorValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Decorator should not have a
name");
+ validationErrors.get("Warnings").add("Decorator should not be annotated
" +
+ "@Specializes");
+ validationErrors.get("Errors").add("Producer cannot be declared in a
" +
+ "decorator");
+ validationErrors.get("Errors").add("Decorator has a method annotated
" +
+ "@Disposes");
+ validationErrors.get("Errors").add("Decorator cannot have a method with
a " +
+ "parameter annotated @Observes");
+ validationErrors.get("Errors").add("Bean class of a session bean cannot
be annotated " +
+ "@Decorator");
+
+ warningsAnnotation.add(CDIAnnotationsType.NAMED);
+ warningsAnnotation.add(CDIAnnotationsType.SPECIALIZES);
+
+ errorsAnnotation.add(CDIAnnotationsType.PRODUCES);
+ errorsAnnotation.add(CDIAnnotationsType.DISPOSES);
+ errorsAnnotation.add(CDIAnnotationsType.OBSERVES);
+ errorsAnnotation.add(CDIAnnotationsType.STATELESS);
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int errorIndex = 0;
+ switch(annotationType) {
+ case PRODUCES:
+ errorIndex = 0;
+ break;
+ case DISPOSES:
+ errorIndex = 1;
+ break;
+ case OBSERVES:
+ errorIndex = 2;
+ break;
+ case STATELESS:
+ errorIndex = 3;
+ break;
+ }
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case NAMED:
+ warningIndex = 0;
+ break;
+ case SPECIALIZES:
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorBindingValidationProvider.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,37 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class InterceptorBindingValidationProvider extends AbstractValidationProvider {
+
+ public InterceptorBindingValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Annotation-valued member of an
interceptor " +
+ "binding type should be annotated @Nonbinding");
+ validationErrors.get("Warnings").add("Array-valued member of an
interceptor " +
+ "binding type must be annotated @Nonbinding");
+
+ warningsAnnotation.add(CDIAnnotationsType.NONBINDING);
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case NONBINDING:
+ warningIndex = 0;
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/InterceptorValidationProvider.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,73 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class InterceptorValidationProvider extends AbstractValidationProvider {
+
+ public InterceptorValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Interceptor should not have a
name");
+ validationErrors.get("Warnings").add("Interceptor should not be
annotated " +
+ "@Specializes");
+ validationErrors.get("Errors").add("Producer cannot be declared in an
" +
+ "interceptor");
+ validationErrors.get("Errors").add("Interceptor has a method annotated
" +
+ "@Disposes");
+ validationErrors.get("Errors").add("Interceptor cannot have a method
with a " +
+ "parameter annotated @Observes");
+ validationErrors.get("Errors").add("Bean class of a session bean cannot
be annotated " +
+ "@Interceptor");
+
+ warningsAnnotation.add(CDIAnnotationsType.NAMED);
+ warningsAnnotation.add(CDIAnnotationsType.SPECIALIZES);
+
+ errorsAnnotation.add(CDIAnnotationsType.PRODUCES);
+ errorsAnnotation.add(CDIAnnotationsType.DISPOSES);
+ errorsAnnotation.add(CDIAnnotationsType.OBSERVES);
+ errorsAnnotation.add(CDIAnnotationsType.STATELESS);
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int errorIndex = 0;
+ switch(annotationType) {
+ case PRODUCES:
+ errorIndex = 0;
+ break;
+ case DISPOSES:
+ errorIndex = 1;
+ break;
+ case OBSERVES:
+ errorIndex = 2;
+ break;
+ case STATELESS:
+ errorIndex = 3;
+ break;
+ }
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case NAMED:
+ warningIndex = 0;
+ break;
+ case SPECIALIZES:
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
+
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/QualifierValidationProvider.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,49 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class QualifierValidationProvider extends AbstractValidationProvider {
+
+ public QualifierValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Qualifier annotation type must be
annotated " +
+ "with @Retention(RUNTIME)");
+ validationErrors.get("Warnings").add("Qualifier annotation type must be
annotated with " +
+ "@Target");
+ validationErrors.get("Warnings").add("Annotation-valued member of a
qualifier type " +
+ "should be annotated @Nonbinding");
+ validationErrors.get("Warnings").add("Array-valued member of a qualifier
type " +
+ "should be annotated @Nonbinding");
+
+ warningsAnnotation.add(CDIAnnotationsType.RETENTION);
+ warningsAnnotation.add(CDIAnnotationsType.TARGET);
+ warningsAnnotation.add(CDIAnnotationsType.NONBINDING);
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case RETENTION:
+ warningIndex = 0;
+ break;
+ case TARGET:
+ warningIndex = 1;
+ break;
+ case NONBINDING:
+ warningIndex = 2;
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ warningIndex = 3;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ScopeValidationProvider.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,39 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class ScopeValidationProvider extends AbstractValidationProvider {
+
+ public ScopeValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Scope annotation type must be
annotated " +
+ "with @Retention(RUNTIME)");
+ validationErrors.get("Warnings").add("Scope annotation type must be
annotated with " +
+ "@Target");
+
+ warningsAnnotation.add(CDIAnnotationsType.RETENTION);
+ warningsAnnotation.add(CDIAnnotationsType.TARGET);
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case RETENTION:
+ warningIndex = 0;
+ break;
+ case TARGET:
+ warningIndex = 1;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/StereotypeValidationProvider.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,58 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import java.util.ArrayList;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+public class StereotypeValidationProvider extends AbstractValidationProvider {
+
+ public StereotypeValidationProvider() {
+ super();
+ }
+
+ @Override
+ void init() {
+ validationErrors.get("Warnings").add("Stereotype annotation type must be
annotated with one of");
+ validationErrors.get("Warnings").add("Stereotype annotation type must be
annotated " +
+ "with @Retention(RUNTIME)");
+ validationErrors.get("Warnings").add("A stereotype should not be
annotated @Typed");
+ validationErrors.get("Errors").add("Stereotype declares a non-empty
@Named annotation");
+
+ warningsAnnotation.add(CDIAnnotationsType.TARGET);
+ warningsAnnotation.add(CDIAnnotationsType.RETENTION);
+ warningsAnnotation.add(CDIAnnotationsType.TYPED);
+
+ errorsAnnotation.add(CDIAnnotationsType.NAMED);
+ }
+
+ public ArrayList<String> getAllErrorsForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int errorIndex = 0;
+ switch (annotationType) {
+ case NAMED:
+ errorIndex = 0;
+ break;
+ }
+ errorsForAnnotationType.add(validationErrors.get("Errors").get(errorIndex));
+ return errorsForAnnotationType;
+ }
+
+ public ArrayList<String> getAllWarningForAnnotationType(
+ CDIAnnotationsType annotationType) {
+ int warningIndex = 0;
+ switch(annotationType) {
+ case TARGET:
+ warningIndex = 0;
+ break;
+ case RETENTION:
+ warningIndex = 1;
+ break;
+ case TYPED:
+ warningIndex = 2;
+ break;
+ }
+ warningsForAnnotationType.add(validationErrors.get("Warnings").get(warningIndex));
+ return warningsForAnnotationType;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/quickfix/validators/ValidationErrorProvider.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,19 @@
+package org.jboss.tools.cdi.bot.test.quickfix.validators;
+
+import org.jboss.tools.cdi.bot.test.annotations.CDIAnnotationsType;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+public interface ValidationErrorProvider {
+
+ Map<String, ArrayList<String>> getAllValidationErrors();
+
+ ArrayList<String> getAllWarningForAnnotationType(CDIAnnotationsType
annotationType);
+
+ ArrayList<String> getAllErrorsForAnnotationType(CDIAnnotationsType
annotationType);
+
+ ArrayList<CDIAnnotationsType> getAllWarningsAnnotation();
+
+ ArrayList<CDIAnnotationsType> getAllErrorsAnnotation();
+}
Deleted:
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-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/CDISeam3Test.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,314 +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.seam3;
-
-
-import java.io.IOException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
-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.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.After;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * Test operates on seam3 features using CDI tools
- *
- * @author Jaroslav Jankovic
- */
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class })
-public class CDISeam3Test extends CDIBase {
-
- private static final Logger LOGGER = Logger.getLogger(CDISeam3Test.class.getName());
- private final String genericPoint1 = "MyExtendedConfiguration ";
- private final String genericPoint2 =
"MyConfigurationProducer.getOneConfig()";
- private final String genericPoint3 =
"MyConfigurationProducer.getSecondConfig()";
-
-
- @Override
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createAndCheckCDIProject(bot, util, projectExplorer,getProjectName());
- addLibrary("seam-solder.jar");
- checkLibrary("seam-solder.jar");
- }
- }
-
- @Override
- public String getProjectName() {
- return "CDISeam3Test";
- }
-
- private String getGenericPackageName() {
- return "org.cdi.generic";
- }
-
- @After
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- }
-
- /*
- *
https://issues.jboss.org/browse/JBIDE-8202
- */
- @Test
- public void testResourceOpenOn() {
-
- createComponent(CDICOMPONENT.BEANSXML, "beans.xml", getProjectName() +
"/WebContent/WEB-INF", null);
-
- createComponent(CDICOMPONENT.BEAN, "B2", getPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDIQuickFixTest.class
- .getResourceAsStream("/resources/cdi/B2.java.cdi"), false);
- LOGGER.info("Content of \"B2.java.cdi\" copied to B2");
- openOn("beansXml", "B2.java", "Open Resource");
- String destinationFile = getEd().getTitle();
- assertTrue("ERROR: redirected to " + destinationFile,
- destinationFile.equals("beans.xml"));
-
- moveFileInProjectExplorer("beans.xml", getProjectName() +
"/WebContent/WEB-INF",
- getProjectName() + "/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"));
-
- }
-
- /*
- *
https://issues.jboss.org/browse/JBIDE-8692
- */
- @Test
- public void testGenericOpenOn() {
-
- prepareGenericOpenOn();
-
- checkMyBeanInjections();
-
- checkMyGenericBean();
-
- checkMyGenericBean2();
- }
-
- private void addLibrary(String libraryName) {
- try {
- addLibraryIntoProject(getProjectName(), libraryName);
- LOGGER.info("Library: \"" + libraryName + "\" copied");
- util.waitForNonIgnoredJobs();
- addLibraryToProjectsClassPath(getProjectName(), libraryName);
- LOGGER.info("Library: \"" + libraryName + "\" on class path
of project\"" + getProjectName() + "\"");
- } catch (IOException exc) {
- LOGGER.log(Level.SEVERE, "Error while adding seam solder library into
project");
- }
- }
-
- private void checkLibrary(String libraryName) {
- isLibraryInProjectClassPath(getProjectName(), libraryName);
- }
-
- /**
- * create all necessary components for this test
- */
- private void prepareGenericOpenOn() {
- /*
- * injectable beans + qualifiers + generic configuration components
- */
- createComponent(CDICOMPONENT.BEAN, "MyBean", getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
- CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyBean");
-
- createComponent(CDICOMPONENT.BEAN, "MyBean2", getGenericPackageName(),
null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
- CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyBean2");
-
- createComponent(CDICOMPONENT.BEAN, "MyBean3", getGenericPackageName(),
null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
- CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX", "MyBean3");
-
- createComponent(CDICOMPONENT.BEAN, "MyConfiguration",
getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
- CDIUtil.replaceInEditor(getEd(), bot, "MyBeanX",
"MyConfiguration");
-
- createComponent(CDICOMPONENT.BEAN, "MyGenericType", getGenericPackageName(),
null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyGenericType.java.cdi"), false);
-
- createComponent(CDICOMPONENT.QUALIFIER, "Qualifier1",
getGenericPackageName(), null);
- createComponent(CDICOMPONENT.QUALIFIER, "Qualifier2",
getGenericPackageName(), null);
-
- createComponent(CDICOMPONENT.BEAN, "MyExtendedConfiguration",
getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyExtendConfig.java.cdi"),
false);
-
- createComponent(CDICOMPONENT.BEAN, "MyConfigurationProducer",
getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyConfigProd.java.cdi"),
false);
-
- /*
- * beans which include atributes suggesting opening all the available
- * generic configurations
- */
-
- createComponent(CDICOMPONENT.BEAN, "MyBeanInjections",
getGenericPackageName(), null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyBeanInjections.java.cdi"),
false);
-
- createComponent(CDICOMPONENT.BEAN, "MyGenericBean", getGenericPackageName(),
null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyGenericBean.java.cdi"), false);
-
- createComponent(CDICOMPONENT.BEAN, "MyGenericBean2", getGenericPackageName(),
null);
- CDIUtil.copyResourceToClass(getEd(), CDISeam3Test.class
- .getResourceAsStream("/resources/generic/MyGenericBean2.java.cdi"),
false);
- }
-
- private void checkMyBeanInjections() {
- checkFirstOpenOnAndGeneric();
- checkSecondOpenOnAndGeneric();
- checkThirdOpenOnAndGeneric();
- }
-
- private void checkMyGenericBean() {
- String parameter = "MyConfiguration config";
- String classTitle = "MyGenericBean.java";
- checkAllGenericPointsForAtribute(parameter, classTitle);
- }
-
- private void checkMyGenericBean2() {
- String classTitle = "MyGenericBean2.java";
-
- checkAllGenericPointsForAtribute("MyConfiguration config", classTitle);
-
- checkAllGenericPointsForAtribute("MyBean c", classTitle);
-
- checkAllGenericPointsForAtribute("MyBean2 c2", classTitle);
-
- checkAllGenericPointsForAtribute("MyBean3 c3", classTitle);
-
- checkAllGenericPointsForAtribute("MyBean parameter1", classTitle);
-
- }
- private void checkFirstOpenOnAndGeneric() {
- checkOpenOnAndGeneric("first1", "MyBeanInjections.java",
"Generic Configuration Point",
- "MyConfigurationProducer.java", "getOneConfig");
- checkOpenOnAndGeneric("first1", "MyBeanInjections.java",
"@Inject Bean",
- "MyGenericBean.java", "createMyFirstBean");
-
- checkOpenOnAndGeneric("first2", "MyBeanInjections.java",
"Generic Configuration Point",
- "MyConfigurationProducer.java", "getSecondConfig");
- checkOpenOnAndGeneric("first2", "MyBeanInjections.java",
"@Inject Bean",
- "MyGenericBean.java", "createMyFirstBean");
-
- checkOpenOnAndGeneric("first3", "MyBeanInjections.java",
"Generic Configuration Point",
- "MyExtendedConfiguration.java", "MyExtendedConfiguration");
- checkOpenOnAndGeneric("first3", "MyBeanInjections.java",
"@Inject Bean",
- "MyGenericBean.java", "createMyFirstBean");
- }
-
- private void checkSecondOpenOnAndGeneric() {
- checkOpenOnAndGeneric("second1", "MyBeanInjections.java",
"Generic Configuration Point",
- "MyConfigurationProducer.java", "getOneConfig");
- checkOpenOnAndGeneric("second1", "MyBeanInjections.java",
"@Inject Bean",
- "MyGenericBean2.java", "createMySecondBean");
-
- checkOpenOnAndGeneric("second2", "MyBeanInjections.java",
"Generic Configuration Point",
- "MyConfigurationProducer.java", "getSecondConfig");
- checkOpenOnAndGeneric("second2", "MyBeanInjections.java",
"@Inject Bean",
- "MyGenericBean2.java", "createMySecondBean");
-
- checkOpenOnAndGeneric("second3", "MyBeanInjections.java",
"Generic Configuration Point",
- "MyExtendedConfiguration.java", "MyExtendedConfiguration");
- checkOpenOnAndGeneric("second3", "MyBeanInjections.java",
"@Inject Bean",
- "MyGenericBean2.java", "createMySecondBean");
- }
-
- private void checkThirdOpenOnAndGeneric() {
- checkOpenOnAndGeneric("third1", "MyBeanInjections.java",
"Generic Configuration Point",
- "MyConfigurationProducer.java", "getOneConfig");
- checkOpenOnAndGeneric("third1", "MyBeanInjections.java",
"@Inject Bean",
- "MyGenericBean.java", "myThirdBean");
-
- checkOpenOnAndGeneric("third2", "MyBeanInjections.java",
"Generic Configuration Point",
- "MyConfigurationProducer.java", "getSecondConfig");
- checkOpenOnAndGeneric("third2", "MyBeanInjections.java",
"@Inject Bean",
- "MyGenericBean.java", "myThirdBean");
-
- checkOpenOnAndGeneric("third3", "MyBeanInjections.java",
"Generic Configuration Point",
- "MyExtendedConfiguration.java", "MyExtendedConfiguration");
- checkOpenOnAndGeneric("third3", "MyBeanInjections.java",
"@Inject Bean",
- "MyGenericBean.java", "myThirdBean");
- }
-
- private void checkOpenOnAndGeneric(String openOnString, String titleName, String
chosenOption,
- String afterOpenOnTitleName, String injectSelectionAtribute) {
- openOn(openOnString, titleName, chosenOption);
- String activeEditor = bot.activeEditor().getTitle();
- String selectedString = bot.activeEditor().toTextEditor().getSelection();
- assertTrue(activeEditor, activeEditor.equals(afterOpenOnTitleName));
- assertTrue(selectedString, selectedString.equals(injectSelectionAtribute));
- }
-
- private void checkAllGenericPointsForAtribute(String parameter, String classTitle) {
- openOn(parameter, classTitle, "Show All Generic Configuration Points...");
- bot.sleep(Timing.time1S());
- SWTBotTable genericPointTable = bot.table(0);
- assertTrue(checkAllGenericConfPoints(genericPointTable));
- getEd().pressShortcut(Keystrokes.ESC);
- bot.sleep(Timing.time2S());
- }
-
- private boolean checkAllGenericConfPoints(SWTBotTable genericPointTable) {
- boolean isGenericPoint1Present = false;
- boolean isGenericPoint2Present = false;
- boolean isGenericPoint3Present = false;
- for (int rowIterator = 0; rowIterator < genericPointTable.rowCount(); rowIterator++)
{
- String itemInTable = genericPointTable.getTableItem(rowIterator).getText();
- if (itemInTable.contains(genericPoint1)) {
- isGenericPoint1Present = true;
- continue;
- }
- if (itemInTable.contains(genericPoint2)) {
- isGenericPoint2Present = true;
- continue;
- }
- if (itemInTable.contains(genericPoint3)) {
- isGenericPoint3Present = true;
- continue;
- }
- }
- return isGenericPoint1Present && isGenericPoint2Present &&
isGenericPoint3Present;
- }
-
-}
-
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/Seam3Test.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/Seam3Test.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/seam3/Seam3Test.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,312 @@
+/*******************************************************************************
+ * 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.seam3;
+
+
+import java.io.IOException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
+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.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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * Test operates on seam3 features using CDI tools
+ *
+ * @author Jaroslav Jankovic
+ */
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class })
+public class Seam3Test extends CDITestBase {
+
+ private static final Logger LOGGER = Logger.getLogger(Seam3Test.class.getName());
+ private final String genericPoint1 = "MyExtendedConfiguration ";
+ private final String genericPoint2 =
"MyConfigurationProducer.getOneConfig()";
+ private final String genericPoint3 =
"MyConfigurationProducer.getSecondConfig()";
+
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createCDIProject(getProjectName());
+ addLibrary("seam-solder.jar");
+ checkLibrary("seam-solder.jar");
+ }
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDISeam3Test";
+ }
+
+ private String getGenericPackageName() {
+ return "org.cdi.generic";
+ }
+
+
+ /**
+ *
https://issues.jboss.org/browse/JBIDE-8202
+ */
+ @Test
+ public void testResourceOpenOn() {
+
+ String className = "Bean1";
+
+ wizard.createComponent(CDIWizardType.BEANS_XML, "beans.xml", getProjectName()
+ "/WebContent/WEB-INF", null);
+
+ wizard.createComponent(CDIWizardType.BEAN, className, getPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/seam3/Bean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("BeanComponent", className);
+
+ openOnUtil.openOnByOption("beansXml", className + ".java",
"Open Resource");
+
+ String destinationFile = getEd().getTitle();
+ assertTrue("ERROR: redirected to " + destinationFile,
+ destinationFile.equals("beans.xml"));
+
+ editResourceUtil.moveFileInProjectExplorer("beans.xml", getProjectName() +
"/WebContent/WEB-INF",
+ getProjectName() + "/WebContent/META-INF");
+ LOGGER.info("bean.xml was moved to META-INF");
+
+ setEd(bot.swtBotEditorExtByTitle(className + ".java"));
+ editResourceUtil.replaceInEditor("WEB", "META");
+ openOnUtil.openOnByOption("beansXml", className + ".java",
"Open Resource");
+
+ destinationFile = getEd().getTitle();
+ assertTrue("ERROR: redirected to " + destinationFile,
+ destinationFile.equals("beans.xml"));
+
+ }
+
+ /**
+ *
https://issues.jboss.org/browse/JBIDE-8692
+ */
+ @Test
+ public void testGenericOpenOn() {
+
+ prepareGenericOpenOn();
+
+ checkMyBeanInjections();
+
+ checkMyGenericBean();
+
+ checkMyGenericBean2();
+ }
+
+ private void addLibrary(String libraryName) {
+ try {
+ libraryUtil.addLibraryIntoProject(getProjectName(), libraryName);
+ LOGGER.info("Library: \"" + libraryName + "\" copied");
+ util.waitForNonIgnoredJobs();
+ libraryUtil.addLibraryToProjectsClassPath(getProjectName(), libraryName);
+ LOGGER.info("Library: \"" + libraryName + "\" on class path
of project\"" + getProjectName() + "\"");
+ } catch (IOException exc) {
+ LOGGER.log(Level.SEVERE, "Error while adding seam solder library into
project");
+ }
+ }
+
+ private void checkLibrary(String libraryName) {
+ assertTrue(libraryUtil.isLibraryInProjectClassPath(getProjectName(), libraryName));
+ }
+
+ /**
+ * wizard.create all necessary components for this test
+ */
+ private void prepareGenericOpenOn() {
+ /**
+ * injectable beans + qualifiers + generic configuration components
+ */
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean", getGenericPackageName(),
null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("MyBeanX", "MyBean");
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean2",
getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("MyBeanX", "MyBean2");
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBean3",
getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("MyBeanX", "MyBean3");
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyConfiguration",
getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBean.java.cdi"), false);
+ editResourceUtil.replaceInEditor("MyBeanX",
"MyConfiguration");
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyGenericType",
getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyGenericType.java.cdi"), false);
+
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Qualifier1",
getGenericPackageName(), null);
+ wizard.createComponent(CDIWizardType.QUALIFIER, "Qualifier2",
getGenericPackageName(), null);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyExtendedConfiguration",
getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyExtendConfig.java.cdi"),
false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyConfigurationProducer",
getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyConfigProd.java.cdi"),
false);
+
+ /**
+ * beans which include atributes suggesting opening all the available
+ * generic configurations
+ */
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyBeanInjections",
getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyBeanInjections.java.cdi"),
false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyGenericBean",
getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyGenericBean.java.cdi"), false);
+
+ wizard.createComponent(CDIWizardType.BEAN, "MyGenericBean2",
getGenericPackageName(), null);
+ editResourceUtil.replaceClassContentByResource(Seam3Test.class
+ .getResourceAsStream("/resources/generic/MyGenericBean2.java.cdi"),
false);
+ }
+
+ private void checkMyBeanInjections() {
+ checkFirstOpenOnAndGeneric();
+ checkSecondOpenOnAndGeneric();
+ checkThirdOpenOnAndGeneric();
+ }
+
+ private void checkMyGenericBean() {
+ String parameter = "MyConfiguration config";
+ String classTitle = "MyGenericBean.java";
+ checkAllGenericPointsForAtribute(parameter, classTitle);
+ }
+
+ private void checkMyGenericBean2() {
+ String classTitle = "MyGenericBean2.java";
+
+ checkAllGenericPointsForAtribute("MyConfiguration config", classTitle);
+
+ checkAllGenericPointsForAtribute("MyBean c", classTitle);
+
+ checkAllGenericPointsForAtribute("MyBean2 c2", classTitle);
+
+ checkAllGenericPointsForAtribute("MyBean3 c3", classTitle);
+
+ checkAllGenericPointsForAtribute("MyBean parameter1", classTitle);
+
+ }
+ private void checkFirstOpenOnAndGeneric() {
+ checkOpenOnAndGeneric("first1", "MyBeanInjections.java",
"Generic Configuration Point",
+ "MyConfigurationProducer.java", "getOneConfig");
+ checkOpenOnAndGeneric("first1", "MyBeanInjections.java",
"@Inject Bean",
+ "MyGenericBean.java", "createMyFirstBean");
+
+ checkOpenOnAndGeneric("first2", "MyBeanInjections.java",
"Generic Configuration Point",
+ "MyConfigurationProducer.java", "getSecondConfig");
+ checkOpenOnAndGeneric("first2", "MyBeanInjections.java",
"@Inject Bean",
+ "MyGenericBean.java", "createMyFirstBean");
+
+ checkOpenOnAndGeneric("first3", "MyBeanInjections.java",
"Generic Configuration Point",
+ "MyExtendedConfiguration.java", "MyExtendedConfiguration");
+ checkOpenOnAndGeneric("first3", "MyBeanInjections.java",
"@Inject Bean",
+ "MyGenericBean.java", "createMyFirstBean");
+ }
+
+ private void checkSecondOpenOnAndGeneric() {
+ checkOpenOnAndGeneric("second1", "MyBeanInjections.java",
"Generic Configuration Point",
+ "MyConfigurationProducer.java", "getOneConfig");
+ checkOpenOnAndGeneric("second1", "MyBeanInjections.java",
"@Inject Bean",
+ "MyGenericBean2.java", "createMySecondBean");
+
+ checkOpenOnAndGeneric("second2", "MyBeanInjections.java",
"Generic Configuration Point",
+ "MyConfigurationProducer.java", "getSecondConfig");
+ checkOpenOnAndGeneric("second2", "MyBeanInjections.java",
"@Inject Bean",
+ "MyGenericBean2.java", "createMySecondBean");
+
+ checkOpenOnAndGeneric("second3", "MyBeanInjections.java",
"Generic Configuration Point",
+ "MyExtendedConfiguration.java", "MyExtendedConfiguration");
+ checkOpenOnAndGeneric("second3", "MyBeanInjections.java",
"@Inject Bean",
+ "MyGenericBean2.java", "createMySecondBean");
+ }
+
+ private void checkThirdOpenOnAndGeneric() {
+ checkOpenOnAndGeneric("third1", "MyBeanInjections.java",
"Generic Configuration Point",
+ "MyConfigurationProducer.java", "getOneConfig");
+ checkOpenOnAndGeneric("third1", "MyBeanInjections.java",
"@Inject Bean",
+ "MyGenericBean.java", "myThirdBean");
+
+ checkOpenOnAndGeneric("third2", "MyBeanInjections.java",
"Generic Configuration Point",
+ "MyConfigurationProducer.java", "getSecondConfig");
+ checkOpenOnAndGeneric("third2", "MyBeanInjections.java",
"@Inject Bean",
+ "MyGenericBean.java", "myThirdBean");
+
+ checkOpenOnAndGeneric("third3", "MyBeanInjections.java",
"Generic Configuration Point",
+ "MyExtendedConfiguration.java", "MyExtendedConfiguration");
+ checkOpenOnAndGeneric("third3", "MyBeanInjections.java",
"@Inject Bean",
+ "MyGenericBean.java", "myThirdBean");
+ }
+
+ private void checkOpenOnAndGeneric(String openOnString, String titleName, String
chosenOption,
+ String afterOpenOnTitleName, String injectSelectionAtribute) {
+ openOnUtil.openOnByOption(openOnString, titleName, chosenOption);
+ String activeEditor = bot.activeEditor().getTitle();
+ String selectedString = bot.activeEditor().toTextEditor().getSelection();
+ assertTrue(activeEditor, activeEditor.equals(afterOpenOnTitleName));
+ assertTrue(selectedString, selectedString.equals(injectSelectionAtribute));
+ }
+
+ private void checkAllGenericPointsForAtribute(String parameter, String classTitle) {
+ openOnUtil.openOnByOption(parameter, classTitle, "Show All Generic Configuration
Points...");
+ bot.sleep(Timing.time1S());
+ SWTBotTable genericPointTable = bot.table(0);
+ assertTrue(checkAllGenericConfPoints(genericPointTable));
+ //getEd().pressShortcut(Keystrokes.ESC);
+ bot.sleep(Timing.time2S());
+ }
+
+ private boolean checkAllGenericConfPoints(SWTBotTable genericPointTable) {
+ boolean isGenericPoint1Present = false;
+ boolean isGenericPoint2Present = false;
+ boolean isGenericPoint3Present = false;
+ for (int rowIterator = 0; rowIterator < genericPointTable.rowCount(); rowIterator++)
{
+ String itemInTable = genericPointTable.getTableItem(rowIterator).getText();
+ if (itemInTable.contains(genericPoint1)) {
+ isGenericPoint1Present = true;
+ continue;
+ }
+ if (itemInTable.contains(genericPoint2)) {
+ isGenericPoint2Present = true;
+ continue;
+ }
+ if (itemInTable.contains(genericPoint3)) {
+ isGenericPoint3Present = true;
+ continue;
+ }
+ }
+ return isGenericPoint1Present && isGenericPoint2Present &&
isGenericPoint3Present;
+ }
+
+}
+
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/CDIProjectHelper.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.uiutils;
+
+import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDIBase;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.NewFileWizardAction;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.DynamicWebProjectWizard;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class CDIProjectHelper extends CDIBase{
+
+
+ public void createCDIProject(String projectName) {
+ createDynamicWebProject(projectName);
+ addCDISupport(projectName);
+ }
+
+ public void createDynamicWebProjectWithCDIPreset(String projectName) {
+ new NewFileWizardAction().run()
+ .selectTemplate("Web", "Dynamic Web Project").next();
+ new DynamicWebProjectWizard().setProjectName(projectName).setCDIPreset().finish();
+ util.waitForNonIgnoredJobs();
+ }
+
+ public void createDynamicWebProjectWithCDIFacets(String projectName) {
+ new NewFileWizardAction().run()
+ .selectTemplate("Web", "Dynamic Web Project").next();
+ new DynamicWebProjectWizard().setProjectName(projectName).setCDIFacet().finish();
+ bot.sleep(Timing.time5S());
+ util.waitForNonIgnoredJobs();
+ }
+
+ public boolean projectExists(String projectName) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+ boolean projectExists = false;
+ try {
+ tree.getTreeItem(projectName);
+ projectExists = true;
+ }catch (WidgetNotFoundException exc) {
+ }
+ return projectExists;
+ }
+
+ private void createDynamicWebProject(String projectName) {
+ new NewFileWizardAction().run()
+ .selectTemplate("Web", "Dynamic Web Project").next();
+ new DynamicWebProjectWizard().setProjectName(projectName).finish();
+ util.waitForNonIgnoredJobs();
+ }
+
+ private void addCDISupport(String projectName) {
+ projectExplorer.selectProject(projectName);
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(projectName);
+ item.expand();
+ NodeContextUtil.nodeContextMenu(tree, item, "Configure",
+ "Add CDI (Context and Dependency Injection) support...")
+ .click();
+ bot.activeShell().bot().button("OK").click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/EditorResourceHelper.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/EditorResourceHelper.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/EditorResourceHelper.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,162 @@
+/*******************************************************************************
+ * 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.uiutils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Scanner;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDIBase;
+import org.jboss.tools.cdi.bot.test.editor.BeansEditorTest;
+import org.jboss.tools.ui.bot.ext.Timing;
+import org.jboss.tools.ui.bot.ext.helper.TreeHelper;
+
+public class EditorResourceHelper extends CDIBase {
+
+ /**
+ * method replaces whole content of class "classEdit" by inputstream resource
+ * If closeEdit param is true, editor is not only saved but closed as well
+ * Prerequisite: editor has been set
+ * @param classEdit
+ * @param resource
+ * @param closeEdit
+ */
+ public void replaceClassContentByResource(InputStream resource, boolean closeEdit) {
+ SWTBotEclipseEditor st = getEd().toTextEditor();
+ st.selectRange(0, 0, st.getText().length());
+ String code = readStream(resource);
+ st.setText(code);
+ getEd().save();
+ if (closeEdit) {
+ getEd().close();
+ }
+ }
+
+ /**
+ * method copies resource from folder "src" param to folder "target"
param
+ * @param src
+ * @param target
+ */
+ public void copyResource(String src, String target) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProjects()[0];
+ IFile f = project.getFile(target);
+ if (f.exists()) {
+ try {
+ f.delete(true, new NullProgressMonitor());
+ } catch (CoreException ce) {
+ }
+ }
+ InputStream is = null;
+ try {
+ is = BeansEditorTest.class.getResourceAsStream(src);
+ f.create(is, true, new NullProgressMonitor());
+ } catch (CoreException ce) {
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (IOException ioe) {
+ //ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Method replaces string "target" by string "replacement.
+ * Prerequisite: editor has been set
+ * @param target
+ * @param replacement
+ */
+ public void replaceInEditor(String target, String replacement) {
+ getEd().selectRange(0, 0, getEd().getText().length());
+ getEd().setText(getEd().getText().replace(
+ target + (replacement.equals("") ? System
+ .getProperty("line.separator") : ""),
+ replacement));
+ bot.sleep(Timing.time1S());
+ getEd().save();
+ }
+
+ /**
+ * Method inserts the string "insertText" on location ("line",
"column")
+ * Prerequisite: editor has been set
+ * @param line
+ * @param column
+ * @param insertText
+ */
+ public void insertInEditor(int line, int column, String insertText) {
+ getEd().toTextEditor().insertText(line, column, insertText);
+ bot.sleep(Timing.time1S());
+ getEd().save();
+ }
+
+ /**
+ * in Project Explorer View, the file which is located in "sourceFolder"
+ * is moved to location "destFolder"
+ * @param file
+ * @param sourceFolder
+ * @param destFolder
+ */
+ public void moveFileInProjectExplorer(String file, String sourceFolder, String
destFolder) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = projectExplorer.selectTreeItem(file,
sourceFolder.split("/"));
+
+ NodeContextUtil.nodeContextMenu(tree, item, "Move...").click();
+
+ tree = bot.tree();
+ tree.collapseNode(destFolder.split("/")[0]);
+
+ TreeHelper.expandNode(bot, destFolder.split("/")).select();
+
+ bot.button("OK").click();
+ }
+
+ /**
+ * Method removes the object which is located in "sourceFolder"
+ * is deleted
+ * @param object
+ * @param sourceFolder
+ */
+ public void removeObjectInProjectExplorer(String object, String sourceFolder) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+ SWTBotTreeItem item = projectExplorer.selectTreeItem(object,
sourceFolder.split("/"));
+
+ NodeContextUtil.nodeContextMenu(tree, item, "Delete").click();
+
+ assertTrue(bot.button("OK").isEnabled());
+
+ bot.button("OK").click();
+
+ bot.sleep(Timing.time2S());
+ }
+
+ /**
+ * Methods converts input stream to string component
+ * @param inputStream
+ * @return String - input stream converted to string
+ */
+ public String readStream(InputStream inputStream) {
+ // we don't care about performance in tests too much, so this should be
+ // OK
+ return new Scanner(inputStream).useDelimiter("\\A").next();
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/LibraryHelper.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/LibraryHelper.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/LibraryHelper.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * 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.uiutils;
+
+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.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.cdi.bot.test.CDIBase;
+import org.jboss.tools.cdi.bot.test.PluginActivator;
+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;
+
+public class LibraryHelper extends CDIBase{
+
+ /**
+ * Method adds library named "libraryName" located in project folder
+ * to project's classpath
+ * @param projectName
+ * @param libraryName
+ */
+ 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(Timing.time500MS());
+ String file = libraryName;
+ bot.tree().expandNode(projectName).expandNode(file).select();
+
+ bot.button(IDELabel.Button.OK).click();
+ bot.sleep(Timing.time1S());
+ bot.button(IDELabel.Button.OK).click();
+ bot.sleep(Timing.time1S());
+ }
+
+ /**
+ * Method copies library named "libraryName" located in
"projectName"/resources/libraries
+ * into project default folder
+ * @param projectName
+ * @param libraryName
+ * @throws IOException
+ */
+ public 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();
+ }
+
+ /**
+ * Method checks if library named "libraryName" is set on classpath
+ * of project named "projectName"
+ * @param projectName
+ * @param libraryName
+ * @return boolean - represents fact if library is/isn't set on project classpath
+ */
+ public boolean isLibraryInProjectClassPath(String projectName, String libraryName) {
+ SWTBotTree tree = projectExplorer.bot().tree();
+
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree);
+ new
SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
+
+ SWTBotShell shell = bot.shell("Properties for " + projectName);
+ SWTBot bot = shell.bot();
+
+ bot.tree().expandNode("Java Build Path").select();
+
+ bot.tabItem("Libraries").activate();
+
+ boolean libraryInProject = false;
+ for (int i = 0; i < bot.tree(1).rowCount(); i++) {
+ if (bot.tree(1).getAllItems()[i].getText().contains(libraryName)) {
+ libraryInProject = true;
+ break;
+ }
+ }
+ bot.button(IDELabel.Button.CANCEL).click();
+ bot.sleep(Timing.time1S());
+ return libraryInProject;
+ }
+
+}
Added:
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
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/NodeContextUtil.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,33 @@
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
+import org.eclipse.swtbot.swt.finder.results.Result;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
+
+public class NodeContextUtil {
+
+ private NodeContextUtil() {
+ throw new AssertionError();
+ }
+
+ public static SWTBotMenu nodeContextMenu(final SWTBotTree tree,
+ SWTBotTreeItem item, final String... menu) {
+ assert menu.length > 0;
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
+ return UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
+
+ public SWTBotMenu run() {
+ SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
+ tree, menu[0], false));
+ for (int i = 1; i < menu.length; i++) {
+ m = m.menu(menu[i]);
+ }
+ return m;
+ }
+ });
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/OpenOnHelper.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.uiutils;
+
+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.jboss.tools.cdi.bot.test.CDIBase;
+import org.jboss.tools.ui.bot.ext.SWTJBTExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class OpenOnHelper extends CDIBase{
+
+ public void openOnByOption(String openOnString, String titleName, String chosenOption)
{
+ selectTextForOpenOn(openOnString, titleName);
+ SWTBotMenu navigateMenu = bot.menu("Navigate");
+ bot.sleep(Timing.time500MS());
+ navigateMenu.menu("Open Hyperlink").click();
+ 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)) {
+ table.click(i, 0);
+ break;
+ }
+ }
+ bot.sleep(Timing.time1S());
+ setEd(bot.activeEditor().toTextEditor());
+ }
+
+ public void openOnDirect(String openOnString, String titleName) {
+ selectTextForOpenOn(openOnString, titleName);
+ bot.sleep(Timing.time3S());
+ getEd().pressShortcut(Keystrokes.F3);
+ setEd(bot.activeEditor().toTextEditor());
+ }
+
+ private void selectTextForOpenOn(String openOnString, String titleName) {
+ 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));
+ }
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/QuickFixHelper.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,63 @@
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.ProblemsType;
+import org.jboss.tools.cdi.bot.test.quickfix.validators.AbstractValidationProvider;
+import org.jboss.tools.ui.bot.ext.view.ProblemsView;
+
+public class QuickFixHelper extends CDITestBase{
+
+ protected AbstractValidationProvider validationErrorsProvider;
+
+ public static SWTBotTreeItem[] problemsTrees;
+
+ /**
+ * Method open context menu for given tree item and opens Quick Fix option
+ * @param item
+ */
+ public void openQuickFix(SWTBotTreeItem item) {
+ NodeContextUtil.nodeContextMenu(bot.tree(), item, "Quick Fix").click();
+ }
+
+ /**
+ * Methods gets all problems of given type
+ * @param problemType
+ * @return array of problems of given type
+ */
+ public SWTBotTreeItem[] getProblems(ProblemsType problemType) {
+ SWTBotTreeItem[] problemsTree = null;
+ if (problemType == ProblemsType.WARNINGS) {
+ problemsTree = ProblemsView.getFilteredWarningsTreeItems(bot, null, "/"
+ + getProjectName(), null, null);
+ }else if (problemType == ProblemsType.ERRORS) {
+ problemsTree = ProblemsView.getFilteredErrorsTreeItems(bot, null, "/"
+ + getProjectName(), null, null);
+ }
+ return problemsTree;
+ }
+
+ public SWTBotTreeItem[] getAllProblems() {
+
+ SWTBotTreeItem[] warningProblemsTree = getProblems(ProblemsType.WARNINGS);
+
+ SWTBotTreeItem[] errorProblemsTree = getProblems(ProblemsType.ERRORS);
+
+ return joinTwoArrays(warningProblemsTree, errorProblemsTree);
+ }
+
+ private SWTBotTreeItem[] joinTwoArrays(SWTBotTreeItem[] aArray, SWTBotTreeItem[] bArray)
{
+
+ SWTBotTreeItem[] bigArray = new SWTBotTreeItem[aArray.length + bArray.length];
+
+ for (int i = 0; i < aArray.length; i++) {
+ bigArray[i] = aArray[i];
+ }
+
+ for (int i = aArray.length; i < aArray.length + bArray.length; i++) {
+ bigArray[i] = bArray[i-aArray.length];
+ }
+
+ return bigArray;
+ }
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/SWTEclipseCDIExtUtil.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,41 @@
+package org.jboss.tools.cdi.bot.test.uiutils;
+
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
+import org.jboss.tools.ui.bot.ext.SWTBotExt;
+import org.jboss.tools.ui.bot.ext.SWTEclipseExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class SWTEclipseCDIExtUtil extends SWTEclipseExt {
+
+ private SWTEclipseCDIExtUtil() {
+ throw new AssertionError();
+ }
+
+ public static void disableFolding(SWTBotExt bot, SWTUtilExt util) {
+ editFolding(bot, util, false);
+ }
+
+ public static void enableFolding(SWTBotExt bot, SWTUtilExt util) {
+ editFolding(bot, util, true);
+ }
+
+ public static void editFolding(SWTBotExt bot, SWTUtilExt util,
+ boolean select) {
+ bot.menu("Window").menu("Preferences").click();
+ bot.shell("Preferences").activate();
+ SWTBotTreeItem item = bot.tree(0).expandNode("Java", "Editor");
+ item.select("Folding");
+ SWTBotCheckBox foldCheckBox = bot.checkBox("Enable folding");
+ if (select) {
+ foldCheckBox.select();
+ } else {
+ foldCheckBox.deselect();
+ }
+ bot.button("OK").click();
+ bot.sleep(Timing.time2S());
+ util.waitForNonIgnoredJobs();
+ }
+
+}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java 2011-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/Action.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -8,6 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.actions;
import org.eclipse.swtbot.swt.finder.SWTBot;
Deleted:
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-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIBase.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,348 +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.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.SWTBot;
-import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
-import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-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.helper.TreeHelper;
-import org.jboss.tools.ui.bot.ext.types.IDELabel;
-import org.jboss.tools.ui.bot.ext.view.ProjectExplorer;
-import org.junit.After;
-import org.junit.Before;
-
-public class CDIBase extends SWTTestExt {
-
- private String projectName = "CDIProject";
- private String packageName = "cdi";
-
- @Before
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createAndCheckCDIProject(bot, util, projectExplorer, getProjectName());
- }
- }
-
- @After
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- }
-
- public String getProjectName() {
- return projectName;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public enum CDICOMPONENT {
- STEREOSCOPE, QUALIFIER, SCOPE, BEAN, INTERBINDING, DECORATOR, INTERCEPTOR, ANNLITERAL,
BEANSXML
- }
- public enum ANNOTATIONS {SERIALIZABLE, TARGET, RETENTION, NAMED, TYPED, DISPOSES,
OBSERVES, INTERCEPTOR,
- SPECIALIZES, DECORATOR, NONBINDING}
- public enum PROBLEM_TYPE {WARNINGS, ERRORS}
-
- private SWTBotEclipseEditor ed;
-
- public SWTBotEclipseEditor getEd() {
- return ed;
- }
-
- public void setEd(SWTBotEclipseEditor ed) {
- this.ed = ed;
- }
-
- public void createComponent(CDICOMPONENT component, String name,
- String packageName, String necessaryParam) {
- if (component == null) {
- CDIUtil.annotation(open, util, packageName, name);
- } else {
- createCDIComponent(component, name, packageName, necessaryParam);
- }
- util.waitForNonIgnoredJobs();
- /*
- * if beans.xml is created as first component in project,
- * it is not opened as default ==> there is no active editor
- */
- if (component != CDICOMPONENT.BEANSXML) {
- setEd(bot.activeEditor().toTextEditor());
- }
- }
-
- private void createCDIComponent(CDICOMPONENT component, String name,
- String packageName, String necessaryParam) {
- switch (component) {
- case STEREOSCOPE:
- 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:
- CDIUtil.qualifier(packageName, name, false, false).finish();
- break;
- case SCOPE:
- CDIUtil.scope(packageName, name, false, false, true, false).finish();
- break;
- case BEAN:
- 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:
- CDIUtil.interceptor(packageName, name, null, null, null, false).finish();
- break;
- case DECORATOR:
- CDIUtil.decorator(packageName, name, necessaryParam, null, true, false, false, false)
- .finish();
- break;
- case ANNLITERAL:
- CDIUtil.annLiteral(packageName, name, true, false, false, false, null).finish();
- break;
- case INTERBINDING:
- CDIUtil.binding(packageName, name, null, true, false).finish();
- break;
- case BEANSXML:
- CDIUtil.beansXML(packageName).finish();
- break;
- }
-
- }
-
- public void createAndCheckCDIProject(SWTBotExt bot, SWTUtilExt util,
- ProjectExplorer projectExplorer, String projectName) {
- createCDIProject(util, projectName);
- projectExplorer.selectProject(projectName);
- SWTBotTree tree = projectExplorer.bot().tree();
- SWTBotTreeItem item = tree.getTreeItem(projectName);
- item.expand();
- addCDISupport(tree, item, bot, util);
- }
-
- public void createCDIProject(SWTUtilExt util, String projectName) {
- new NewFileWizardAction().run()
- .selectTemplate("Web", "Dynamic Web Project").next();
- new DynamicWebProjectWizard().setProjectName(projectName).finish();
- util.waitForNonIgnoredJobs();
- }
-
- public void createCDIProjectWithCDIPreset(SWTUtilExt util, String projectName) {
- new NewFileWizardAction().run()
- .selectTemplate("Web", "Dynamic Web Project").next();
- new DynamicWebProjectWizard().setProjectName(projectName).setCDIPreset().finish();
- util.waitForNonIgnoredJobs();
- }
-
- public void createCDIProjectWithCDIFacets(SWTUtilExt util, String projectName) {
- new NewFileWizardAction().run()
- .selectTemplate("Web", "Dynamic Web Project").next();
- new DynamicWebProjectWizard().setProjectName(projectName).setCDIFacet().finish();
- bot.sleep(Timing.time5S());
- util.waitForNonIgnoredJobs();
- }
-
- public 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());
- util.waitForNonIgnoredJobs();
- }
-
- 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 (chosenOption != null) {
- SWTBotMenu navigateMenu = bot.menu("Navigate");
- bot.sleep(Timing.time500MS());
- navigateMenu.menu("Open Hyperlink").click();
- 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)) {
- table.click(i, 0);
- break;
- }
- }
- } else {
- getEd().setFocus();
- bot.sleep(Timing.time2S());
- 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(Timing.time500MS());
- String file = libraryName;
- bot.tree().expandNode(projectName).expandNode(file).select();
-
- bot.button(IDELabel.Button.OK).click();
- bot.sleep(Timing.time1S());
- bot.button(IDELabel.Button.OK).click();
- bot.sleep(Timing.time1S());
- }
-
- /*
- * copy library located in PROJECT_NAME/resources/libraries into project
- * libraryName must include extension: seam-solder.jar
- */
- public 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();
- }
-
- /*
- * check if library with name libraryName is set on classpath of project with name
- * projectName
- */
- public void isLibraryInProjectClassPath(String projectName, String libraryName) {
- SWTBotTree tree = projectExplorer.bot().tree();
-
- ContextMenuHelper.prepareTreeItemForContextMenu(tree);
- new
SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
-
- SWTBotShell shell = bot.shell("Properties for " + projectName);
- SWTBot bot = shell.bot();
-
- bot.tree().expandNode("Java Build Path").select();
-
- bot.tabItem("Libraries").activate();
-
- boolean libraryInProject = false;
- for (int i = 0; i < bot.tree(1).rowCount(); i++) {
- if (bot.tree(1).getAllItems()[i].getText().contains(libraryName)) {
- libraryInProject = true;
- break;
- }
- }
- assertTrue("Library " + libraryName + "is not on classPath of project
"
- + projectName,libraryInProject);
-
- bot.button(IDELabel.Button.CANCEL).click();
- bot.sleep(Timing.time1S());
- }
-
- public 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();
- }
-
- public void removeObjectInProjectExplorer(String object, String sourceFolder) {
- SWTBotTree tree = projectExplorer.bot().tree();
- SWTBotTreeItem item = projectExplorer.selectTreeItem(object,
sourceFolder.split("/"));
-
- CDIUtil.nodeContextMenu(tree, item, "Delete").click();
-
- assertTrue(bot.button("OK").isEnabled());
-
- bot.button("OK").click();
-
- bot.sleep(Timing.time2S());
- }
-
- public boolean projectExists(String projectName) {
- SWTBotTree tree = projectExplorer.bot().tree();
- boolean projectExists = false;
- try {
- tree.getTreeItem(projectName);
- projectExists = true;
- }catch (WidgetNotFoundException exc) {
- }
- return projectExists;
- }
-
-}
\ No newline at end of file
Deleted:
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-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/CDIUtil.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,286 +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.uiutils.actions;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Scanner;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
-import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.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.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
-import org.jboss.tools.cdi.bot.test.editor.CDIBeansEditorTest;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
-import org.jboss.tools.ui.bot.ext.SWTBotExt;
-import org.jboss.tools.ui.bot.ext.SWTOpenExt;
-import org.jboss.tools.ui.bot.ext.SWTUtilExt;
-import org.jboss.tools.ui.bot.ext.Timing;
-import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.JavaAnnotation;
-import org.jboss.tools.ui.bot.ext.helper.ContextMenuHelper;
-
-public class CDIUtil {
-
- private CDIUtil() {
- // this class servers only for static related methods
- // it should not be instantiated
- throw new AssertionError();
- }
-
- public static void openQuickFix(SWTBotTreeItem item, SWTBotExt bot) {
- nodeContextMenu(bot.tree(), item, "Quick Fix").click();
- }
-
- public static void resolveQuickFix(SWTBotTreeItem item, SWTBotExt bot,
- SWTUtilExt util) {
- openQuickFix(item, bot);
- bot.activeShell().bot().button("Finish").click();
- bot.sleep(Timing.time2S());
- util.waitForNonIgnoredJobs();
- }
-
- public static void copyResourceToClass(SWTBotEditor classEdit,
- InputStream resource, boolean closeEdit) {
- SWTBotEclipseEditor st = classEdit.toTextEditor();
- st.selectRange(0, 0, st.getText().length());
- String code = readStream(resource);
- st.setText(code);
- classEdit.save();
- if (closeEdit) {
- classEdit.close();
- }
- }
-
- public static void copyResource(String src, String target) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProjects()[0];
- IFile f = project.getFile(target);
- if (f.exists()) {
- try {
- f.delete(true, new NullProgressMonitor());
- } catch (CoreException ce) {
- }
- }
- InputStream is = null;
- try {
- is = CDIBeansEditorTest.class.getResourceAsStream(src);
- f.create(is, true, new NullProgressMonitor());
- } catch (CoreException ce) {
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException ioe) {
- //ignore
- }
- }
- }
- }
-
- public static void replaceInEditor(SWTBotEclipseEditor ed, SWTBotExt bot,
- String target, String replacement) {
- ed.selectRange(0, 0, ed.getText().length());
- ed.setText(ed.getText().replace(
- target + (replacement.equals("") ? System
- .getProperty("line.separator") : ""),
- replacement));
- bot.sleep(Timing.time1S());
- ed.save();
- }
-
- public static void insertInEditor(SWTBotEclipseEditor ed, SWTBotExt bot,
- int line, int row, String insertText) {
- ed.toTextEditor().insertText(line, row, insertText);
- bot.sleep(Timing.time1S());
- ed.save();
- }
-
- public static void disableFolding(SWTBotExt bot, SWTUtilExt util) {
- editFolding(bot, util, false);
- }
-
- public static void enableFolding(SWTBotExt bot, SWTUtilExt util) {
- editFolding(bot, util, true);
- }
-
- public static void editFolding(SWTBotExt bot, SWTUtilExt util,
- boolean select) {
- bot.menu("Window").menu("Preferences").click();
- bot.shell("Preferences").activate();
- SWTBotTreeItem item = bot.tree(0).expandNode("Java", "Editor");
- item.select("Folding");
- SWTBotCheckBox foldCheckBox = bot.checkBox("Enable folding");
- if (select) {
- foldCheckBox.select();
- } else {
- foldCheckBox.deselect();
- }
- bot.button("OK").click();
- bot.sleep(Timing.time2S());
- util.waitForNonIgnoredJobs();
- }
-
- public static SWTBotMenu nodeContextMenu(final SWTBotTree tree,
- SWTBotTreeItem item, final String... menu) {
- assert menu.length > 0;
- ContextMenuHelper.prepareTreeItemForContextMenu(tree, item);
- return UIThreadRunnable.syncExec(new Result<SWTBotMenu>() {
-
- public SWTBotMenu run() {
- SWTBotMenu m = new SWTBotMenu(ContextMenuHelper.getContextMenu(
- tree, menu[0], false));
- for (int i = 1; i < menu.length; i++) {
- m = m.menu(menu[i]);
- }
- return m;
- }
- });
- }
-
- public static CDIWizard qualifier(String pkg, String name,
- boolean inherited, boolean comments) {
- return create(CDIWizardType.QUALIFIER, pkg, name, inherited, comments);
- }
-
- public static CDIWizard scope(String pkg, String name, boolean inherited,
- boolean comments, boolean normalScope, boolean passivating) {
- CDIWizard w = create(CDIWizardType.SCOPE, pkg, name, inherited,
- comments);
- w = w.setNormalScope(normalScope);
- return normalScope ? w.setPassivating(passivating) : w;
- }
-
- public static CDIWizard binding(String pkg, String name, String target,
- boolean inherited, boolean comments) {
- CDIWizard w = create(CDIWizardType.INTERCEPTOR_BINDING, pkg, name,
- inherited, comments);
- return target != null ? w.setTarget(target) : w;
- }
-
- public static CDIWizard stereotype(String pkg, String name, String scope,
- String target, boolean inherited, boolean named,
- boolean alternative, boolean 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;
- }
-
- public static CDIWizard decorator(String pkg, String name, String intf,
- String fieldName, boolean isPublic, boolean isAbstract,
- boolean isFinal, boolean comments) {
- CDIWizard w = create(CDIWizardType.DECORATOR, pkg, name, comments);
- w = w.addInterface(intf).setPublic(isPublic).setFinal(isFinal)
- .setAbstract(isAbstract);
- return fieldName != null ? w.setFieldName(fieldName) : w;
- }
-
- public static CDIWizard interceptor(String pkg, String name,
- String ibinding, String superclass, String method, boolean comments) {
- CDIWizard w = create(CDIWizardType.INTERCEPTOR, pkg, name, comments);
- if (superclass != null) {
- w = w.setSuperclass(superclass);
- }
- if (method != null) {
- w = w.setMethodName(method);
- }
- if (ibinding != null) {
- w = w.addIBinding(ibinding);
- }
- return w;
- }
-
- public static CDIWizard bean(String pkg, String name, boolean isPublic,
- 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) {
- w.setNamed(true);
- if (!"".equals(named.trim())) {
- w.setNamedName(named);
- }
- }
- w =
w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract).setAlternative(alternative);
- //w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract);
- if (interfaces != null && !"".equals(interfaces.trim())) {
- w.addInterface(interfaces);
- }
- if (scope != null && !"".equals(scope.trim())) {
- w.setScope(scope);
- }
- if (qualifier != null && !"".equals(qualifier.trim())) {
- w.addQualifier(qualifier);
- }
- if (alternative && registerInBeansXML) {
- w.setRegisterInBeansXml(registerInBeansXML);
- }
- return w;
- }
-
- public static void annotation(SWTOpenExt open, SWTUtilExt util, String pkg,
- String name) {
- SWTBot openWizard = open.newObject(JavaAnnotation.LABEL);
- openWizard.textWithLabel("Name:").setText(name);
- openWizard.textWithLabel("Package:").setText(pkg);
- openWizard.button("Finish").click();
- util.waitForNonIgnoredJobs();
- }
-
- public static CDIWizard annLiteral(String pkg, String name,
- boolean isPublic, boolean isAbstract, boolean isFinal,
- boolean comments, String qualifier) {
- assert qualifier != null && !"".equals(qualifier.trim()) :
"Qualifier has to be set";
- CDIWizard w = create(CDIWizardType.ANNOTATION_LITERAL, pkg, name,
- comments);
- return w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract)
- .addQualifier(qualifier);
- }
-
- public static CDIWizard beansXML(String pkg) {
- CDIWizard w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
- w.setSourceFolder(pkg);
- return w;
- }
-
- public static CDIWizard create(CDIWizardType type, String pkg, String name,
- boolean inherited, boolean comments) {
- return create(type, pkg, name, comments).setInherited(inherited);
- }
-
- public static CDIWizard create(CDIWizardType type, String pkg, String name,
- boolean comments) {
- CDIWizard p = new NewCDIFileWizard(type).run();
- return p.setPackage(pkg).setName(name).setGenerateComments(comments);
- }
-
- public static String readStream(InputStream is) {
- // we don't care about performance in tests too much, so this should be
- // OK
- return new Scanner(is).useDelimiter("\\A").next();
- }
-
-}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java 2011-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewCDIFileWizard.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -8,10 +8,11 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.actions;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizard;
-import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBase;
import org.jboss.tools.cdi.bot.test.uiutils.wizards.Wizard;
public class NewCDIFileWizard extends NewFileWizardAction {
@@ -24,11 +25,11 @@
}
@Override
- public CDIWizard run() {
+ public CDIWizardBase run() {
Wizard w = super.run();
w.selectTemplate("CDI (Context and Dependency Injection)",
type.getAnnotationType());
w.next();
- return new CDIWizard(type);
+ return new CDIWizardBase(type);
}
}
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java 2011-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/actions/NewFileWizardAction.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -8,6 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.actions;
import org.eclipse.swtbot.swt.finder.SWTBot;
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-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizard.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,427 +1,114 @@
/*******************************************************************************
- * Copyright (c) 2010-2011 Red Hat, Inc.
+ * 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.uiutils.wizards;
-import java.util.Arrays;
-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.openon.OpenOnTest;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swtbot.swt.finder.SWTBot;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.jboss.tools.ui.bot.ext.Timing;
-
-public class CDIWizard extends Wizard {
-
- private final CDIWizardType type;
-
- public CDIWizard(CDIWizardType type) {
- super(new SWTBot().activeShell().widget);
- assert ("New " + type).equals(getText());
- this.type = type;
+public class CDIWizard extends CDITestBase{
+
+ private CDIWizardBaseExt wizardExt = new CDIWizardBaseExt();
+
+ public void createAnnotation(String name, String packageName) {
+ wizardExt.annotation(open, util, packageName, name);
}
-
- public CDIWizard setName(String name) {
- if (CDIWizardType.BEANS_XML == type) {
- setText("File name:", name);
- } else {
- setText("Name:", name);
- }
- return this;
- }
-
- public CDIWizard setPackage(String pkg) {
- setText("Package:", pkg);
- return this;
- }
-
- public CDIWizard setSourceFolder(String src) {
- if (CDIWizardType.BEANS_XML == type) {
- setText("Enter or select the parent folder:", src);
- } else {
- setText("Source folder:", src);
- }
- return this;
- }
-
- public CDIWizard setInherited(boolean set) {
- setCheckbox("Add @Inherited", set);
- return this;
- }
-
- public boolean isInherited() {
- return isCheckboxSet("Add @Inherited");
- }
-
- public CDIWizard setGenerateComments(boolean set) {
- setCheckbox("Generate comments", set);
- return this;
- }
-
- public boolean isGenerateComments() {
- return isCheckboxSet("Generate comments");
- }
-
- public CDIWizard setNormalScope(boolean set) {
- switch (type) {
- case SCOPE:
- setCheckbox("is normal scope", set);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public boolean isNormalScope() {
- switch (type) {
- case SCOPE:
- return isCheckboxSet("is normal scope");
- default:
- return true;
- }
- }
-
- public CDIWizard setPassivating(boolean set) {
- switch (type) {
- case SCOPE:
- setCheckbox("is passivating", set);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public boolean isPassivating() {
- switch (type) {
- case SCOPE:
- return isCheckboxSet("is passivating");
- default:
- return false;
- }
- }
-
- public CDIWizard setAlternative(boolean set) {
- switch (type) {
- case STEREOTYPE:
- case BEAN:
- setCheckbox("Add @Alternative", set);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- 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 void createComponent(CDIWizardType component, String name,
+ String packageName, String necessaryParam) {
+ createCDIComponent(component, name, packageName, necessaryParam);
+ util.waitForNonIgnoredJobs();
+ /**
+ * if beans.xml is created as first component in project,
+ * it is not opened as default ==> there is no active editor
+ */
+ if (component != CDIWizardType.BEANS_XML) {
+ setEd(bot.activeEditor().toTextEditor());
+ }
}
- public boolean isRegisteredInBeansXML() {
- switch (type) {
+ public void createCDIComponent(CDIWizardType component, String name,
+ String packageName, String necessaryParam) {
+ switch (component) {
case STEREOTYPE:
- case BEAN:
- return isCheckboxSet("Register in beans.xml");
- default:
- return false;
- }
- }
-
- public CDIWizard setNamed(boolean set) {
- switch (type) {
- case STEREOTYPE:
- case BEAN:
- setCheckbox("Add @Named", set);
+ 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;
+ }
+ }
+ wizardExt.stereotype(packageName, name, null, null, false, false, alternative,
regInBeansXml,
+ false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard setNamedName(String name) {
- if (CDIWizardType.BEAN != type) {
- throw new UnsupportedOperationException();
- }
- setText("Bean Name:", name);
- return this;
- }
-
- public boolean isNamed() {
- switch (type) {
- case STEREOTYPE:
- return isCheckboxSet("Add @Named");
- default:
- return false;
- }
- }
-
- public CDIWizard setTarget(String target) {
- switch (type) {
- case STEREOTYPE:
- case INTERCEPTOR_BINDING:
- setCombo("Target:", target);
+ case QUALIFIER:
+ wizardExt.qualifier(packageName, name, false, false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public List<String> getTargets() {
- setFocus();
- return Arrays.asList(bot().comboBoxWithLabel("Target:").items());
- }
-
- public CDIWizard setScope(String scope) {
- switch (type) {
- case STEREOTYPE:
- case BEAN:
- setCombo("Scope:", scope);
+ case SCOPE:
+ wizardExt.scope(packageName, name, false, false, true, false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public List<String> getScopes() {
- setFocus();
- return Arrays.asList(bot().comboBoxWithLabel("Scope:").items());
- }
-
- public CDIWizard addIBinding(String ib) {
- switch (type) {
- case INTERCEPTOR_BINDING:
- case STEREOTYPE:
- case INTERCEPTOR:
- setFocus();
- bot().button("Add", 0).click();
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(ib);
- sh.bot().button("OK").click();
- setFocus();
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public List<String> getIBindings() {
- setFocus();
- return Arrays.asList(bot().listWithLabel("Interceptor Bindings:")
- .getItems());
- }
-
- public CDIWizard addStereotype(String stereotype) {
- switch (type) {
- case STEREOTYPE:
- setFocus();
- bot().button("Add", 1).click();
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(stereotype);
- sh.bot().button("OK").click();
- setFocus();
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public List<String> getStereotypes() {
- setFocus();
- return Arrays.asList(bot().listWithLabel("Stereotypes:").getItems());
- }
-
- public CDIWizard setPublic(boolean isPublic) {
- switch (type) {
- case DECORATOR:
case BEAN:
- case ANNOTATION_LITERAL:
- setFocus();
- if (isPublic) {
- bot().radio("public").click();
- } else {
- class Radio2 extends SWTBotRadio {
- Radio2(Button b) {
- super(b);
- }
-
- @Override
- public SWTBotRadio click() {
- return (SWTBotRadio) click(true);
- }
+ alternative = false;
+ regInBeansXml = false;
+ if (necessaryParam != null) {
+ if (necessaryParam.equals("alternative+beansxml")) {
+ alternative = true;
+ regInBeansXml = true;
+ } else if (necessaryParam.equals("alternative")) {
+ alternative = true;
}
- final Button b = bot().radio("default").widget;
- new Radio2(b).click();
}
- setFocus();
+ wizardExt.bean(packageName, name, true, false, false, false, alternative,
regInBeansXml, null, null,
+ null, null).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard setFieldName(String name) {
- switch (type) {
- case DECORATOR:
- setText("Delegate Field Name:", name);
+ case INTERCEPTOR:
+ wizardExt.interceptor(packageName, name, null, null, null, false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard addInterface(String intf) {
- switch (type) {
case DECORATOR:
- case BEAN:
- setFocus();
- bot().button("Add...", 0).click();
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(intf);
- sh.bot().sleep(Timing.time3S());
- sh.bot().table().getTableItem(0).select();
- sh.bot().button("OK").click();
- setFocus();
+ wizardExt.decorator(packageName, name, necessaryParam, null, true, false, false,
false)
+ .finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard addQualifier(String qualifier) {
- setFocus();
- switch (type) {
- case BEAN:
- bot().button("Add", 0).click();
- break;
case ANNOTATION_LITERAL:
- bot().button("Browse", 0).click();
+ wizardExt.annLiteral(packageName, name, true, false, false, false, null).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(qualifier);
- sh.bot().sleep(Timing.time2S());
- sh.bot().table().getTableItem(0).select();
- sh.bot().button("OK").click();
- setFocus();
- return this;
- }
-
- public CDIWizard setAbstract(boolean isAbstract) {
- switch (type) {
- case DECORATOR:
- case BEAN:
- case ANNOTATION_LITERAL:
- setCheckbox("abstract", isAbstract);
+ case INTERCEPTOR_BINDING:
+ wizardExt.binding(packageName, name, null, true, false).finish();
break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard setFinal(boolean isFinal) {
- switch (type) {
- case DECORATOR:
- case BEAN:
- case ANNOTATION_LITERAL:
- setCheckbox("final", isFinal);
+ case BEANS_XML:
+ wizardExt.beansXML(packageName).finish();
break;
- default:
- throw new UnsupportedOperationException();
+ }
+ util.waitForNonIgnoredJobs();
+ if (component != CDIWizardType.BEANS_XML) {
+ setEd(bot.activeEditor().toTextEditor());
}
- return this;
}
-
- public CDIWizard setSuperclass(String name) {
- switch (type) {
- case INTERCEPTOR:
- setFocus();
- bot().button("Browse...", 2).click();
- SWTBotShell sh = bot().activeShell();
- sh.bot().text().setText(name);
- sh.bot().table().getTableItem(0).select();
- sh.bot().button("OK").click();
- setFocus();
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- public CDIWizard setMethodName(String name) {
- switch (type) {
- case INTERCEPTOR:
- setText("Around Invoke Method Name:", name);
- break;
- default:
- throw new UnsupportedOperationException();
- }
- return this;
- }
-
- private void setCheckbox(String label, boolean set) {
- setFocus();
- SWTBotCheckBox c = bot().checkBox(label);
- if (c.isChecked() != set) {
- if (set) {
- c.select();
- } else {
- c.deselect();
- }
+ public void createClearBeansXML(String projectName) {
+ if (!projectExplorer.isFilePresent(projectName,
+ "WebContent/META-INF/beans.xml".split("/")) &&
+ !projectExplorer.isFilePresent(projectName,
+ "WebContent/WEB-INF/beans.xml".split("/"))) {
+ createComponent(CDIWizardType.BEANS_XML, null, projectName +
"/WebContent/WEB-INF", null);
}
- }
+ projectExplorer.openFile(projectName,
"WebContent/WEB-INF/beans.xml".split("/"));
+ bot.cTabItem("Source").activate();
+ setEd(bot.activeEditor().toTextEditor());
+ editResourceUtil.replaceClassContentByResource(OpenOnTest.class
+ .getResourceAsStream("/resources/codeCompletion/beans.xml.cdi"), false);
- private boolean isCheckboxSet(String label) {
- setFocus();
- SWTBotCheckBox c = bot().checkBox(label);
- return c.isChecked();
}
- private void setCombo(String label, String value) {
- setFocus();
- SWTBotCombo c = bot().comboBoxWithLabel(label);
- c.setSelection(value);
- }
-
}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBase.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBase.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBase.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,429 @@
+/*******************************************************************************
+ * 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.uiutils.wizards;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.ui.bot.ext.Timing;
+
+public class CDIWizardBase extends Wizard {
+
+ private final CDIWizardType type;
+
+ public CDIWizardBase(CDIWizardType type) {
+ super(new SWTBot().activeShell().widget);
+ assert ("New " + type).equals(getText());
+ this.type = type;
+ }
+
+ public CDIWizardBase setName(String name) {
+ if (CDIWizardType.BEANS_XML == type) {
+ setText("File name:", name);
+ } else {
+ setText("Name:", name);
+ }
+ return this;
+ }
+
+ public CDIWizardBase setPackage(String pkg) {
+ setText("Package:", pkg);
+ return this;
+ }
+
+ public CDIWizardBase setSourceFolder(String src) {
+ if (CDIWizardType.BEANS_XML == type) {
+ setText("Enter or select the parent folder:", src);
+ } else {
+ setText("Source folder:", src);
+ }
+ return this;
+ }
+
+ public CDIWizardBase setInherited(boolean set) {
+ setCheckbox("Add @Inherited", set);
+ return this;
+ }
+
+ public boolean isInherited() {
+ return isCheckboxSet("Add @Inherited");
+ }
+
+ public CDIWizardBase setGenerateComments(boolean set) {
+ setCheckbox("Generate comments", set);
+ return this;
+ }
+
+ public boolean isGenerateComments() {
+ return isCheckboxSet("Generate comments");
+ }
+
+ public CDIWizardBase setNormalScope(boolean set) {
+ switch (type) {
+ case SCOPE:
+ setCheckbox("is normal scope", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isNormalScope() {
+ switch (type) {
+ case SCOPE:
+ return isCheckboxSet("is normal scope");
+ default:
+ return true;
+ }
+ }
+
+ public CDIWizardBase setPassivating(boolean set) {
+ switch (type) {
+ case SCOPE:
+ setCheckbox("is passivating", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isPassivating() {
+ switch (type) {
+ case SCOPE:
+ return isCheckboxSet("is passivating");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizardBase setAlternative(boolean set) {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ setCheckbox("Add @Alternative", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public boolean isAlternative() {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ return isCheckboxSet("Add @Alternative");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizardBase 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 CDIWizardBase setNamed(boolean set) {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ setCheckbox("Add @Named", set);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setNamedName(String name) {
+ if (CDIWizardType.BEAN != type) {
+ throw new UnsupportedOperationException();
+ }
+ setText("Bean Name:", name);
+ return this;
+ }
+
+ public boolean isNamed() {
+ switch (type) {
+ case STEREOTYPE:
+ return isCheckboxSet("Add @Named");
+ default:
+ return false;
+ }
+ }
+
+ public CDIWizardBase setTarget(String target) {
+ switch (type) {
+ case STEREOTYPE:
+ case INTERCEPTOR_BINDING:
+ setCombo("Target:", target);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getTargets() {
+ setFocus();
+ return Arrays.asList(bot().comboBoxWithLabel("Target:").items());
+ }
+
+ public CDIWizardBase setScope(String scope) {
+ switch (type) {
+ case STEREOTYPE:
+ case BEAN:
+ setCombo("Scope:", scope);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getScopes() {
+ setFocus();
+ return Arrays.asList(bot().comboBoxWithLabel("Scope:").items());
+ }
+
+ public CDIWizardBase addIBinding(String ib) {
+ switch (type) {
+ case INTERCEPTOR_BINDING:
+ case STEREOTYPE:
+ case INTERCEPTOR:
+ setFocus();
+ bot().button("Add", 0).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(ib);
+ sh.bot().button("OK").click();
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getIBindings() {
+ setFocus();
+ return Arrays.asList(bot().listWithLabel("Interceptor Bindings:")
+ .getItems());
+ }
+
+ public CDIWizardBase addStereotype(String stereotype) {
+ switch (type) {
+ case STEREOTYPE:
+ setFocus();
+ bot().button("Add", 1).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(stereotype);
+ sh.bot().button("OK").click();
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public List<String> getStereotypes() {
+ setFocus();
+ return Arrays.asList(bot().listWithLabel("Stereotypes:").getItems());
+ }
+
+ public CDIWizardBase setPublic(boolean isPublic) {
+ switch (type) {
+ case DECORATOR:
+ case BEAN:
+ case ANNOTATION_LITERAL:
+ setFocus();
+ if (isPublic) {
+ bot().radio("public").click();
+ } else {
+ class Radio2 extends SWTBotRadio {
+ Radio2(Button b) {
+ super(b);
+ }
+
+ @Override
+ public SWTBotRadio click() {
+ return (SWTBotRadio) click(true);
+ }
+ }
+ final Button b = bot().radio("default").widget;
+ new Radio2(b).click();
+ }
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setFieldName(String name) {
+ switch (type) {
+ case DECORATOR:
+ setText("Delegate Field Name:", name);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase addInterface(String intf) {
+ switch (type) {
+ case DECORATOR:
+ case BEAN:
+ setFocus();
+ bot().button("Add...", 0).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(intf);
+ sh.bot().sleep(Timing.time3S());
+ sh.bot().table().getTableItem(0).select();
+ sh.bot().button("OK").click();
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase addQualifier(String qualifier) {
+ setFocus();
+ switch (type) {
+ case BEAN:
+ bot().button("Add", 0).click();
+ break;
+ case ANNOTATION_LITERAL:
+ bot().button("Browse", 0).click();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(qualifier);
+ sh.bot().sleep(Timing.time2S());
+ sh.bot().table().getTableItem(0).select();
+ sh.bot().button("OK").click();
+ setFocus();
+ return this;
+ }
+
+ public CDIWizardBase setAbstract(boolean isAbstract) {
+ switch (type) {
+ case DECORATOR:
+ case BEAN:
+ case ANNOTATION_LITERAL:
+ setCheckbox("abstract", isAbstract);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setFinal(boolean isFinal) {
+ switch (type) {
+ case DECORATOR:
+ case BEAN:
+ case ANNOTATION_LITERAL:
+ setCheckbox("final", isFinal);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setSuperclass(String name) {
+ switch (type) {
+ case INTERCEPTOR:
+ setFocus();
+ bot().button("Browse...", 2).click();
+ SWTBotShell sh = bot().activeShell();
+ sh.bot().text().setText(name);
+ sh.bot().table().getTableItem(0).select();
+ sh.bot().button("OK").click();
+ setFocus();
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+ public CDIWizardBase setMethodName(String name) {
+ switch (type) {
+ case INTERCEPTOR:
+ setText("Around Invoke Method Name:", name);
+ break;
+ default:
+ throw new UnsupportedOperationException();
+ }
+ return this;
+ }
+
+
+ private void setCheckbox(String label, boolean set) {
+ setFocus();
+ SWTBotCheckBox c = bot().checkBox(label);
+ if (c.isChecked() != set) {
+ if (set) {
+ c.select();
+ } else {
+ c.deselect();
+ }
+ }
+ }
+
+ private boolean isCheckboxSet(String label) {
+ setFocus();
+ SWTBotCheckBox c = bot().checkBox(label);
+ return c.isChecked();
+ }
+
+ private void setCombo(String label, String value) {
+ setFocus();
+ SWTBotCombo c = bot().comboBoxWithLabel(label);
+ c.setSelection(value);
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBaseExt.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBaseExt.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardBaseExt.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,135 @@
+package org.jboss.tools.cdi.bot.test.uiutils.wizards;
+
+import org.eclipse.swtbot.swt.finder.SWTBot;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.NewCDIFileWizard;
+import org.jboss.tools.ui.bot.ext.SWTOpenExt;
+import org.jboss.tools.ui.bot.ext.SWTUtilExt;
+import org.jboss.tools.ui.bot.ext.gen.ActionItem.NewObject.JavaAnnotation;
+
+public class CDIWizardBaseExt {
+
+ public CDIWizardBase qualifier(String pkg, String name,
+ boolean inherited, boolean comments) {
+ return create(CDIWizardType.QUALIFIER, pkg, name, inherited, comments);
+ }
+
+ public CDIWizardBase scope(String pkg, String name, boolean inherited,
+ boolean comments, boolean normalScope, boolean passivating) {
+ CDIWizardBase w = create(CDIWizardType.SCOPE, pkg, name, inherited,
+ comments);
+ w = w.setNormalScope(normalScope);
+ return normalScope ? w.setPassivating(passivating) : w;
+ }
+
+ public CDIWizardBase binding(String pkg, String name, String target,
+ boolean inherited, boolean comments) {
+ CDIWizardBase w = create(CDIWizardType.INTERCEPTOR_BINDING, pkg, name,
+ inherited, comments);
+ return target != null ? w.setTarget(target) : w;
+ }
+
+ public CDIWizardBase stereotype(String pkg, String name, String scope,
+ String target, boolean inherited, boolean named,
+ boolean alternative, boolean regInBeansXML, boolean comments) {
+ CDIWizardBase 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;
+ }
+
+ public CDIWizardBase decorator(String pkg, String name, String intf,
+ String fieldName, boolean isPublic, boolean isAbstract,
+ boolean isFinal, boolean comments) {
+ CDIWizardBase w = create(CDIWizardType.DECORATOR, pkg, name, comments);
+ w = w.addInterface(intf).setPublic(isPublic).setFinal(isFinal)
+ .setAbstract(isAbstract);
+ return fieldName != null ? w.setFieldName(fieldName) : w;
+ }
+
+ public CDIWizardBase interceptor(String pkg, String name,
+ String ibinding, String superclass, String method, boolean comments) {
+ CDIWizardBase w = create(CDIWizardType.INTERCEPTOR, pkg, name, comments);
+ if (superclass != null) {
+ w = w.setSuperclass(superclass);
+ }
+ if (method != null) {
+ w = w.setMethodName(method);
+ }
+ if (ibinding != null) {
+ w = w.addIBinding(ibinding);
+ }
+ return w;
+ }
+
+ public CDIWizardBase bean(String pkg, String name, boolean isPublic,
+ boolean isAbstract, boolean isFinal, boolean comments,
+ boolean alternative, boolean registerInBeansXML,
+ String named, String interfaces, String scope, String qualifier) {
+ CDIWizardBase w = create(CDIWizardType.BEAN, pkg, name, comments);
+ if (named != null) {
+ w.setNamed(true);
+ if (!"".equals(named.trim())) {
+ w.setNamedName(named);
+ }
+ }
+ w =
w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract).setAlternative(alternative);
+ //w = w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract);
+ if (interfaces != null && !"".equals(interfaces.trim())) {
+ w.addInterface(interfaces);
+ }
+ if (scope != null && !"".equals(scope.trim())) {
+ w.setScope(scope);
+ }
+ if (qualifier != null && !"".equals(qualifier.trim())) {
+ w.addQualifier(qualifier);
+ }
+ if (alternative && registerInBeansXML) {
+ w.setRegisterInBeansXml(registerInBeansXML);
+ }
+ return w;
+ }
+
+ public void annotation(SWTOpenExt open, SWTUtilExt util, String pkg,
+ String name) {
+ SWTBot openWizard = open.newObject(JavaAnnotation.LABEL);
+ openWizard.textWithLabel("Name:").setText(name);
+ openWizard.textWithLabel("Package:").setText(pkg);
+ openWizard.button("Finish").click();
+ util.waitForNonIgnoredJobs();
+ }
+
+ public CDIWizardBase annLiteral(String pkg, String name,
+ boolean isPublic, boolean isAbstract, boolean isFinal,
+ boolean comments, String qualifier) {
+ assert qualifier != null && !"".equals(qualifier.trim()) :
"Qualifier has to be set";
+ CDIWizardBase w = create(CDIWizardType.ANNOTATION_LITERAL, pkg, name,
+ comments);
+ return w.setPublic(isPublic).setFinal(isFinal).setAbstract(isAbstract)
+ .addQualifier(qualifier);
+ }
+
+ public CDIWizardBase beansXML(String pkg) {
+ CDIWizardBase w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
+ w.setSourceFolder(pkg);
+ return w;
+ }
+
+ public CDIWizardBase create(CDIWizardType type, String pkg, String name,
+ boolean inherited, boolean comments) {
+ return create(type, pkg, name, comments).setInherited(inherited);
+ }
+
+ public CDIWizardBase create(CDIWizardType type, String pkg, String name,
+ boolean comments) {
+ CDIWizardBase p = new NewCDIFileWizard(type).run();
+ return p.setPackage(pkg).setName(name).setGenerateComments(comments);
+ }
+
+
+}
Deleted:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java 2011-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/CDIWizardType.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,51 +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.uiutils.wizards;
-
-public enum CDIWizardType {
-
- INTERCEPTOR_BINDING, QUALIFIER, SCOPE, STEREOTYPE,
- DECORATOR, INTERCEPTOR, BEAN, ANNOTATION_LITERAL,
- BEANS_XML;
-
- String getName() {
- switch (this) {
- case INTERCEPTOR_BINDING:
- return "Interceptor Binding";
- case QUALIFIER:
- return "Qualifier";
- case SCOPE:
- return "Scope";
- case STEREOTYPE:
- return "Stereotype";
- case DECORATOR:
- return "Decorator";
- case INTERCEPTOR:
- return "Interceptor";
- case BEAN:
- return "Bean";
- case ANNOTATION_LITERAL:
- return "Annotation Literal";
- case BEANS_XML:
- return "File beans.xml";
- default:
- throw new AssertionError("Unknown type");
- }
- }
-
- public String getAnnotationType() {
- return isAnnotation() ? getName() + " Annotation" : getName();
- }
-
- private boolean isAnnotation() {
- return this.ordinal() < DECORATOR.ordinal();
- }
-}
\ No newline at end of file
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-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/DynamicWebProjectWizard.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -8,6 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.wizards;
import org.eclipse.swtbot.swt.finder.SWTBot;
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-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/uiutils/wizards/Wizard.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -8,6 +8,7 @@
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
+
package org.jboss.tools.cdi.bot.test.uiutils.wizards;
import org.eclipse.swt.widgets.Shell;
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-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIATWizardTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,395 +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.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.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
- * @author Lukas Jungmann
- * @author jjankovi
- */
-@Require(clearProjects = true, 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 Logger L = Logger.getLogger(CDIATWizardTest.class.getName());
-
- public String getProjectName() {
- return "CDIWizardTest";
- }
-
- @Override
- public void waitForJobs() {
- util.waitForNonIgnoredJobs();
- /**
- * needed for creating non-dependant components
- */
- projectExplorer.selectProject(getProjectName());
- }
-
- @Test
- public void testQualifier() {
- CDIUtil.qualifier(getPackageName(), "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(getPackageName(), "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(getPackageName(), "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(getPackageName(), "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(getPackageName(), "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(getPackageName(), "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(getPackageName(), "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(getPackageName(), "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(getPackageName(), "B4", "TYPE", true, false);
- w.addIBinding(getPackageName() + ".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(getPackageName(), "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(getPackageName(), "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(getPackageName(), "S3", null, null, false, false,
true, false, false);
- w.addIBinding(getPackageName() + ".B1");
- w.addStereotype(getPackageName() + ".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() {
- bot.sleep(Timing.time1S());
- CDIWizard w = CDIUtil.decorator(getPackageName(), "",
"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(getPackageName(), "", "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(getPackageName(), "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(getPackageName(), "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(getProjectName() + "/WebContent/WEB-INF");
- assertFalse(w.canFinish());
- w.setSourceFolder(getProjectName() + "/src/" +
getPackageName().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(getPackageName(), "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(getPackageName(), "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(getPackageName(), "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(getPackageName(), "AnnL1", true, false,
true, false, getPackageName() + ".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(getPackageName(), "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("/**"));
- }
-}
Deleted:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIConfigurationPresetTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIConfigurationPresetTest.java 2011-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIConfigurationPresetTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,75 +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.wizard;
-
-
-import java.util.logging.Logger;
-
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
-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.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.ContextMenuHelper;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
-* Test checks if CDI configuration preset sets CDI support correctly
-*
-* @author Jaroslav Jankovic
-*/
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class , CDISmokeBotTests.class })
-public class CDIConfigurationPresetTest extends CDIBase {
-
- private static final Logger LOGGER =
Logger.getLogger(CDIConfigurationPresetTest.class.getName());
-
- @Override
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createCDIProjectWithCDIPreset(util, getProjectName());
- }
- }
-
- @Override
- public String getProjectName() {
- return "CDIPresetProject";
- }
-
- @Test
- public void testCDIPreset() {
- LOGGER.info("Dynamic Web Project with CDI Configuration Preset created");
- assertTrue(checkCDISupport(getProjectName()));
- }
-
- private boolean checkCDISupport(String projectName) {
- projectExplorer.selectProject(projectName);
-
- SWTBotTree tree = projectExplorer.bot().tree();
- ContextMenuHelper.prepareTreeItemForContextMenu(tree);
- new
SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
-
- bot.tree().expandNode("CDI (Context and Dependency Injection)
Settings").select();
- boolean isCDISupported = bot.checkBox().isChecked();
- bot.button("Cancel").click();
- return isCDISupported;
- }
-
-
-}
Deleted:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIFacetTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIFacetTest.java 2011-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIFacetTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,53 +0,0 @@
-package org.jboss.tools.cdi.bot.test.wizard;
-
-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.uiutils.actions.CDIBase;
-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.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
-* Test checks if beans.xml is created when selectin CDI Facet
-*
-* @author Jaroslav Jankovic
-*/
-
-@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
-(a)RunWith(RequirementAwareSuite.class)
-@SuiteClasses({ CDIAllBotTests.class , CDISmokeBotTests.class })
-public class CDIFacetTest extends CDIBase {
-
- private static final Logger LOGGER = Logger.getLogger(CDIFacetTest.class.getName());
-
-
- @Override
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createCDIProjectWithCDIFacets(util, getProjectName());
- }
- }
-
- @Override
- public String getProjectName() {
- return "CDIFacetsProject";
- }
-
- @Test
- public void testCDIFacet() {
- LOGGER.info("Dynamic Web Project with CDI Facet created");
- assertTrue("Error: beans.xml should be created when selecting CDI Facet",
- projectExplorer.isFilePresent(getProjectName(),
getBeansXmlLocation().split("/")));
- }
-
- private String getBeansXmlLocation() {
- return "WebContent/WEB-INF/beans.xml";
- }
-
-}
Deleted:
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 2011-11-19
09:55:17 UTC (rev 36467)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/CDIPerspectiveTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -1,150 +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.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.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite.SuiteClasses;
-
-/**
-* Test operates on CDI perspective
-*
-* @author Jaroslav Jankovic
-*/
-
-@Require(clearProjects = true, 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 enum CDIARTIFACTS {
- BEAN, QUALIFIER, STEREOTYPE, SCOPE, INTERBINDING, INTERCEPTOR, DECORATOR, ANNOTLITERAL,
BEANSXML
- }
-
- @Override
- public void checkAndCreateProject() {
- if (!projectExists(getProjectName())) {
- createAndCheckCDIProject(bot, util, projectExplorer, getProjectName());
- eclipse.openPerspective(PerspectiveType.CDI);
- LOGGER.info("CDI perspective selected");
- bot.sleep(Timing.time2S());
- }
- }
-
- @Override
- public String getProjectName() {
- return "CDIPerspectiveTest";
- }
-
- @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(getProjectName());
- 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;
- }
- }
-
-}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/ConfigurationPresetTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/ConfigurationPresetTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/ConfigurationPresetTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.swtbot.swt.finder.widgets.SWTBotMenu;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+import org.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+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.ContextMenuHelper;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+* Test checks if CDI configuration preset sets CDI support correctly
+*
+* @author Jaroslav Jankovic
+*/
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class , CDISmokeBotTests.class })
+public class ConfigurationPresetTest extends CDITestBase {
+
+ private static final Logger LOGGER =
Logger.getLogger(ConfigurationPresetTest.class.getName());
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createDynamicWebProjectWithCDIPreset(getProjectName());
+ }
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDIPresetProject";
+ }
+
+ @Test
+ public void testCDIPreset() {
+ LOGGER.info("Dynamic Web Project with CDI Configuration Preset created");
+ assertTrue(checkCDISupport(getProjectName()));
+ }
+
+ private boolean checkCDISupport(String projectName) {
+ projectExplorer.selectProject(projectName);
+
+ SWTBotTree tree = projectExplorer.bot().tree();
+ ContextMenuHelper.prepareTreeItemForContextMenu(tree);
+ new
SWTBotMenu(ContextMenuHelper.getContextMenu(tree,"Properties",false)).click();
+
+ bot.tree().expandNode("CDI (Context and Dependency Injection)
Settings").select();
+ boolean isCDISupported = bot.checkBox().isChecked();
+ bot.button("Cancel").click();
+ return isCDISupported;
+ }
+
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/FacetTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/FacetTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/FacetTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.jboss.tools.cdi.bot.test.CDIAllBotTests;
+import org.jboss.tools.cdi.bot.test.CDISmokeBotTests;
+import org.jboss.tools.cdi.bot.test.CDITestBase;
+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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+* Test checks if beans.xml is created when selectin CDI Facet
+*
+* @author Jaroslav Jankovic
+*/
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class , CDISmokeBotTests.class })
+public class FacetTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger.getLogger(FacetTest.class.getName());
+
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createDynamicWebProjectWithCDIFacets(getProjectName());
+ }
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDIFacetsProject";
+ }
+
+ @Test
+ public void testCDIFacet() {
+ LOGGER.info("Dynamic Web Project with CDI Facet created");
+ assertTrue("Error: beans.xml should be created when selecting CDI Facet",
+ projectExplorer.isFilePresent(getProjectName(),
"WebContent/WEB-INF/beans.xml".split("/")));
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/PerspectiveTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/PerspectiveTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/PerspectiveTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,124 @@
+/*******************************************************************************
+ * 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.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.NodeContextUtil;
+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.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+* Test operates on CDI perspective
+*
+* @author Jaroslav Jankovic
+*/
+
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
+public class PerspectiveTest extends CDITestBase {
+
+ private static final Logger LOGGER = Logger.getLogger(PerspectiveTest.class.getName());
+
+ @Override
+ public void checkAndCreateProject() {
+ if (!projectHelper.projectExists(getProjectName())) {
+ projectHelper.createCDIProject(getProjectName());
+ eclipse.openPerspective(PerspectiveType.CDI);
+ LOGGER.info("CDI perspective selected");
+ bot.sleep(Timing.time2S());
+ }
+ }
+
+ @Override
+ public String getProjectName() {
+ return "CDIPerspectiveTest";
+ }
+
+ @Test
+ public void testCDIArtifactBeanWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.BEAN));
+ }
+
+ @Test
+ public void testCDIArtifactAnnotationLiteralWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.ANNOTATION_LITERAL));
+ }
+
+ @Test
+ public void testCDIArtifactBeanXMLWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.BEANS_XML));
+ }
+
+ @Test
+ public void testCDIArtifactDecoratorWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.DECORATOR));
+ }
+
+ @Test
+ public void testCDIArtifactQualifierWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.QUALIFIER));
+ }
+
+ @Test
+ public void testCDIArtifactScopeWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.SCOPE));
+ }
+
+ @Test
+ public void testCDIArtifactStereoscopeWizard() {
+
+ assertTrue(openCDIArtifactsWizard(CDIWizardType.STEREOTYPE));
+ }
+
+ private boolean openCDIArtifactsWizard(CDIWizardType wizardType) {
+
+ SWTBotTree tree = packageExplorer.bot().tree();
+ SWTBotTreeItem item = tree.getTreeItem(getProjectName());
+ item.expand();
+ boolean artifactWizardExists = true;
+ try {
+ NodeContextUtil.nodeContextMenu(tree, item, "New",
wizardType.getAnnotationType()).click();
+ bot.sleep(Timing.time500MS());
+ bot.activeShell().bot().button("Cancel").click();
+
+ } catch (SWTException exc) {
+ artifactWizardExists = false;
+ }
+ bot.sleep(Timing.time1S());
+ util.waitForNonIgnoredJobs();
+ return artifactWizardExists;
+ }
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.bot.test/src/org/jboss/tools/cdi/bot/test/wizard/WizardTest.java 2011-11-21
09:33:15 UTC (rev 36468)
@@ -0,0 +1,397 @@
+/*******************************************************************************
+ * 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.CDITestBase;
+import org.jboss.tools.cdi.bot.test.annotations.CDIWizardType;
+import org.jboss.tools.cdi.bot.test.uiutils.actions.NewCDIFileWizard;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBase;
+import org.jboss.tools.cdi.bot.test.uiutils.wizards.CDIWizardBaseExt;
+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.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ * @author Lukas Jungmann
+ * @author jjankovi
+ */
+@Require(clearProjects = true, perspective = "Java EE", server = @Server(state
= ServerState.NotRunning, version = "6.0", operator = ">="))
+(a)RunWith(RequirementAwareSuite.class)
+@SuiteClasses({ CDIAllBotTests.class, CDISmokeBotTests.class })
+public class WizardTest extends CDITestBase {
+
+ private static final Logger L = Logger.getLogger(WizardTest.class.getName());
+ private final CDIWizardBaseExt wizard = new CDIWizardBaseExt();
+
+ public String getProjectName() {
+ return "CDIWizardTest";
+ }
+
+ @Override
+ public void waitForJobs() {
+ util.waitForNonIgnoredJobs();
+ /**
+ * needed for creating non-dependant components
+ */
+ projectExplorer.selectProject(getProjectName());
+ }
+
+ @Test
+ public void testQualifier() {
+ wizard.qualifier(getPackageName(), "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("/**"));
+
+ wizard.qualifier(getPackageName(), "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() {
+ wizard.scope(getPackageName(), "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("/**"));
+
+ wizard.scope(getPackageName(), "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("/**"));
+
+ wizard.scope(getPackageName(), "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() {
+ CDIWizardBase w = wizard.binding(getPackageName(), "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("/**"));
+
+ wizard.binding(getPackageName(), "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("/**"));
+
+ wizard.binding(getPackageName(), "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 = wizard.binding(getPackageName(), "B4", "TYPE", true, false);
+ w.addIBinding(getPackageName() + ".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() {
+ CDIWizardBase w = wizard.stereotype(getPackageName(), "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("/**"));
+
+ wizard.stereotype(getPackageName(), "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 = wizard.stereotype(getPackageName(), "S3", null, null, false, false, true,
false, false);
+ w.addIBinding(getPackageName() + ".B1");
+ w.addStereotype(getPackageName() + ".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() {
+ bot.sleep(Timing.time1S());
+ CDIWizardBase w = wizard.decorator(getPackageName(), "",
"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 = wizard.decorator(getPackageName(), "", "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() {
+ CDIWizardBase w = wizard.interceptor(getPackageName(), "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 = wizard.interceptor(getPackageName(), "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() {
+ CDIWizardBase w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
+ w.setSourceFolder(getProjectName() + "/WebContent/WEB-INF");
+ assertFalse(w.canFinish());
+ w.setSourceFolder(getProjectName() + "/src/" +
getPackageName().replaceAll(".", "/"));
+ assertTrue(w.canFinish());
+ w.cancel();
+ w = new NewCDIFileWizard(CDIWizardType.BEANS_XML).run();
+ assertFalse(w.canFinish());
+ w.cancel();
+ }
+
+ @Test
+ public void testBean() {
+ CDIWizardBase w = wizard.bean(getPackageName(), "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 = wizard.bean(getPackageName(), "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 = wizard.bean(getPackageName(), "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() {
+ CDIWizardBase w = wizard.annLiteral(getPackageName(), "AnnL1", true, false,
true, false, getPackageName() + ".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 = wizard.annLiteral(getPackageName(), "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("/**"));
+ }
+}
Modified: trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt 2011-11-19 09:55:17 UTC (rev
36467)
+++ trunk/cdi/tests/org.jboss.tools.cdi.bot.test/todo.txt 2011-11-21 09:33:15 UTC (rev
36468)
@@ -1,7 +1,7 @@
/**
* what tests have to be done(JBDS50_0010):
- * 1. Classes indication for Open Injected Class works
- * 2. CDI Facets can create beans.xml file when selected
+ * 1. Validations works good for Inconsistent specialization,
+ Ambiguous EL names, Unproxyable bean types, Decorator resolution
* 3. Code completion works in beans.xml
* 4. Classes in beans.xml are validated
* 5. Complex test from Weld is working in JBDS and CDI functionality works without
errors