Author: dazarov
Date: 2011-11-10 16:00:49 -0500 (Thu, 10 Nov 2011)
New Revision: 36285
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Base1.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/BaseDecoratedInterface.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Bean1.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Base2.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Bean2.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/TestBean.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Base3.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Bean3.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Base4.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Bean4.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Base5.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Bean5.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsSearchParticipantTest.java
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsTestSetup.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
Log:
CDI Searcher doesn't look for beans in dependent projects
https://issues.jboss.org/browse/JBIDE-9801
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Base1.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Base1.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Base1.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,13 @@
+package cdi.test.search1;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+public class Base1 implements BaseDecoratedInterface{
+
+ public Base1() {
+ }
+
+ @Inject
+ Event<Base1> event1;
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Base1.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/BaseDecoratedInterface.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/BaseDecoratedInterface.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/BaseDecoratedInterface.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,5 @@
+package cdi.test.search1;
+
+public interface BaseDecoratedInterface {
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/BaseDecoratedInterface.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Bean1.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Bean1.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Bean1.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,19 @@
+package cdi.test.search1;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+public class Bean1 {
+ @Inject
+ @Any
+ private BaseDecoratedInterface field1;
+
+ public void method1(@Observes BaseDecoratedInterface event) {
+
+ }
+
+ @Inject public void method_1(BaseDecoratedInterface param1){
+
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/search1/Bean1.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Base2.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Base2.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Base2.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,11 @@
+package cdi.test.search2;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+import cdi.test.search1.Base1;
+
+public class Base2 extends Base1 {
+ @Inject
+ Event<Base1> event2;
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Base2.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Bean2.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Bean2.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Bean2.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,23 @@
+package cdi.test.search2;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+import cdi.test.search1.BaseDecoratedInterface;
+
+
+public class Bean2 {
+ @Inject
+ @Any
+ private BaseDecoratedInterface field2;
+
+ public void method2(@Observes BaseDecoratedInterface event) {
+
+ }
+
+ @Inject public void method_2(BaseDecoratedInterface param2){
+
+ }
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/Bean2.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/TestBean.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/TestBean.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/TestBean.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,5 @@
+package cdi.test.search2;
+
+public class TestBean {
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/cdi/test/search2/TestBean.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Base3.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Base3.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Base3.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,12 @@
+package cdi.test.search3;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+import cdi.test.search1.Base1;
+import cdi.test.search2.Base2;
+
+public class Base3 extends Base2 {
+ @Inject
+ Event<Base1> event3;
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Base3.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Bean3.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Bean3.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Bean3.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,22 @@
+package cdi.test.search3;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+import cdi.test.search1.BaseDecoratedInterface;
+
+
+public class Bean3 {
+ @Inject
+ @Any
+ private BaseDecoratedInterface field3;
+
+ public void method3(@Observes BaseDecoratedInterface event) {
+
+ }
+
+ @Inject public void method_3(BaseDecoratedInterface param3){
+
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest3/src/cdi/test/search3/Bean3.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Base4.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Base4.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Base4.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,12 @@
+package cdi.test.search4;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+import cdi.test.search1.Base1;
+import cdi.test.search2.Base2;
+
+public class Base4 extends Base2 {
+ @Inject
+ Event<Base1> event4;
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Base4.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Bean4.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Bean4.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Bean4.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,22 @@
+package cdi.test.search4;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+import cdi.test.search1.BaseDecoratedInterface;
+
+public class Bean4 {
+ @Inject
+ @Any
+ private BaseDecoratedInterface field4;
+
+ public void method4(@Observes BaseDecoratedInterface event) {
+
+ }
+
+ @Inject public void method_4(BaseDecoratedInterface param4){
+
+ }
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest4/src/cdi/test/search4/Bean4.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Base5.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Base5.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Base5.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,14 @@
+package cdi.test.search5;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+import cdi.test.search1.Base1;
+import cdi.test.search4.Base4;
+import javax.inject.Named;
+
+@Named("abcd")
+public class Base5 extends Base4 {
+ @Inject
+ Event<Base1> event5;
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Base5.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Bean5.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Bean5.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Bean5.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,22 @@
+package cdi.test.search5;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Any;
+import javax.inject.Inject;
+
+import cdi.test.search1.BaseDecoratedInterface;
+import javax.inject.Named;
+
+public class Bean5 {
+ @Inject
+ @Any
+ private BaseDecoratedInterface field5;
+
+ public void method5(@Observes BaseDecoratedInterface event) {
+
+ }
+
+ @Inject public void method_5(BaseDecoratedInterface param5){
+
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest5/src/cdi/test/search5/Bean5.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-11-10
20:47:37 UTC (rev 36284)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/CDIUIAllTests.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -22,6 +22,8 @@
import org.jboss.tools.cdi.ui.test.preferences.CDIPreferencePageTest;
import org.jboss.tools.cdi.ui.test.search.CDISearchParticipantTest;
import org.jboss.tools.cdi.ui.test.search.ELReferencesQueryParticipantTest;
+import org.jboss.tools.cdi.ui.test.search.FiveDependentProjectsSearchParticipantTest;
+import org.jboss.tools.cdi.ui.test.search.FiveDependentProjectsTestSetup;
import org.jboss.tools.cdi.ui.test.wizard.AddQualifiersToBeanWizardTest;
import org.jboss.tools.cdi.ui.test.wizard.NewCDIClassWizardFactoryTest;
import org.jboss.tools.cdi.ui.test.wizard.NewCDIWebProjectWizardTest;
@@ -65,6 +67,11 @@
suiteAll.addTestSuite(AddQualifiersToBeanWizardTest.class);
suiteAll.addTestSuite(CDIRefactoringTest.class);
+
+ TestSuite dependentSuite = new TestSuite("Dependent Projects Tests");
+ dependentSuite.addTestSuite(FiveDependentProjectsSearchParticipantTest.class);
+ FiveDependentProjectsTestSetup dependent = new
FiveDependentProjectsTestSetup(dependentSuite);
+ suiteAll.addTest(dependent);
return suiteAll;
}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsSearchParticipantTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsSearchParticipantTest.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsSearchParticipantTest.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,272 @@
+package org.jboss.tools.cdi.ui.test.search;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+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.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.search.IJavaSearchConstants;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
+import org.eclipse.jdt.ui.search.ElementQuerySpecification;
+import org.eclipse.jdt.ui.search.IQueryParticipant;
+import org.eclipse.jdt.ui.search.ISearchRequestor;
+import org.eclipse.jdt.ui.search.QuerySpecification;
+import org.eclipse.search.ui.text.Match;
+import org.jboss.tools.cdi.core.CDIUtil;
+import org.jboss.tools.cdi.core.ICDIElement;
+import org.jboss.tools.cdi.core.test.tck.TCKTest;
+import org.jboss.tools.cdi.internal.core.impl.ClassBean;
+import org.jboss.tools.cdi.internal.core.impl.EventBean;
+import org.jboss.tools.cdi.internal.core.impl.InjectionPointField;
+import org.jboss.tools.cdi.internal.core.impl.InjectionPointParameter;
+import org.jboss.tools.cdi.internal.core.impl.ObserverMethod;
+import org.jboss.tools.cdi.ui.search.CDIBeanQueryParticipant;
+import org.jboss.tools.cdi.ui.search.CDIMatch;
+import org.jboss.tools.cdi.ui.search.InjectionPointQueryParticipant;
+import org.jboss.tools.common.EclipseUtil;
+
+public class FiveDependentProjectsSearchParticipantTest extends TestCase {
+ IProject project1 = null;
+ IProject project2 = null;
+ IProject project3 = null;
+ IProject project4 = null;
+ IProject project5 = null;
+
+ @Override
+ protected void setUp() throws Exception {
+ project1 = ResourcesPlugin.getWorkspace().getRoot().getProject("CDITest1");
+ project2 = ResourcesPlugin.getWorkspace().getRoot().getProject("CDITest2");
+ project3 = ResourcesPlugin.getWorkspace().getRoot().getProject("CDITest3");
+ project4 = ResourcesPlugin.getWorkspace().getRoot().getProject("CDITest4");
+ project5 = ResourcesPlugin.getWorkspace().getRoot().getProject("CDITest5");
+ }
+ private static final int FIELD_SEARCH = 1;
+ private static final int METHOD_SEARCH = 2;
+ private static final int TYPE_SEARCH = 3;
+ private static final int PARAMETER_SEARCH = 4;
+
+ private void testSearchParticipant(IProject project, String fileName, int searchType,
String elementName, String parameterName, IQueryParticipant participant,
List<MatchStructure> matches){
+ IFile file = project.getFile(fileName);
+ assertNotNull("File - "+fileName+" not found", file);
+ try{
+ ICompilationUnit compilationUnit = EclipseUtil.getCompilationUnit(file);
+ IJavaElement element = null;
+
+ IType type = compilationUnit.findPrimaryType();
+
+ if(searchType == FIELD_SEARCH){
+ element = type.getField(elementName);
+ }else if(searchType == METHOD_SEARCH){
+ element = getMethod(type, elementName);
+ }else if(searchType == TYPE_SEARCH){
+ element = type;
+ }else if(searchType == PARAMETER_SEARCH){
+ IMethod method = getMethod(type, elementName);
+ element = CDIUtil.getParameter(method, parameterName);
+ }
+
+ if(element != null){
+ CDISearchRequestor requestor = new CDISearchRequestor();
+
+ JavaSearchScopeFactory factory= JavaSearchScopeFactory.getInstance();
+ IJavaSearchScope scope= factory.createWorkspaceScope(true);
+ String description= factory.getWorkspaceScopeDescription(true);
+ QuerySpecification specification = new ElementQuerySpecification(element,
IJavaSearchConstants.REFERENCES, scope, description);
+
+ participant.search(requestor, specification, new NullProgressMonitor());
+
+ List<Match> matchesForCheck = requestor.getMatches();
+
+ checkMatches(matchesForCheck, matches);
+ }else
+ fail("Java Element not found");
+ }catch(CoreException ex){
+ fail("Core exception");
+ }
+ }
+
+ private IMethod getMethod(IType type, String name) throws JavaModelException{
+ IMethod[] methods = type.getMethods();
+ for(IMethod method : methods){
+ if(method.getElementName().equals(name))
+ return method;
+ }
+ return null;
+ }
+
+ private void checkMatches(List<Match> matchesForCheck, List<MatchStructure>
matchList) throws CoreException {
+// for(Match match : matchesForCheck){
+// System.out.println(("Match found (class -
"+((CDIMatch)match).getCDIElement().getClass()+" name -
"+((CDIMatch)match).getLabel()+")"));
+// }
+
+ for(Match match : matchesForCheck){
+ assertTrue("Match must be CDIMatch", match instanceof CDIMatch);
+ MatchStructure ms = findMatch(matchList, (CDIMatch)match);
+ assertNotNull("Unexpected match found (class -
"+((CDIMatch)match).getCDIElement().getClass()+" name -
"+((CDIMatch)match).getLabel()+")", ms);
+ ms.checked = true;
+ }
+
+ for(MatchStructure ms : matchList){
+ assertTrue("Match not found (class - "+ms.type+" name - "+ms.name,
ms.checked);
+ }
+ }
+
+ protected MatchStructure findMatch(List<MatchStructure> matchList, CDIMatch
match){
+ for(MatchStructure ms : matchList){
+ if(!ms.checked && ms.type.equals(match.getCDIElement().getClass()) &&
ms.name.equals(match.getLabel()))
+ return ms;
+ }
+ return null;
+ }
+
+
+ class CDISearchRequestor implements ISearchRequestor{
+ ArrayList<Match> matches = new ArrayList<Match>();
+
+ public void reportMatch(Match match){
+ matches.add(match);
+ }
+
+ public List<Match> getMatches(){
+ return matches;
+ }
+ }
+
+ class MatchStructure{
+ Class<? extends ICDIElement> type;
+ String name; // label
+ boolean checked;
+
+ public MatchStructure(Class<? extends ICDIElement> type, String name){
+ this.type = type;
+ this.name = name;
+ checked = false;
+ }
+ }
+
+ public void testInjectionPointQueryParticipantInProject1(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(ClassBean.class, "Base1"));
+
+ testSearchParticipant(project1, "src/cdi/test/search1/Bean1.java",
FIELD_SEARCH, "field1", "", new InjectionPointQueryParticipant(),
matches);
+ }
+
+ public void testInjectionPointQueryParticipantInProject2(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(ClassBean.class, "Base1"));
+ matches.add(new MatchStructure(ClassBean.class, "Base2"));
+
+ testSearchParticipant(project2, "src/cdi/test/search2/Bean2.java",
FIELD_SEARCH, "field2", "", new InjectionPointQueryParticipant(),
matches);
+ }
+
+ public void testInjectionPointQueryParticipantInProject3(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(ClassBean.class, "Base1"));
+ matches.add(new MatchStructure(ClassBean.class, "Base2"));
+ matches.add(new MatchStructure(ClassBean.class, "Base3"));
+
+ testSearchParticipant(project3, "src/cdi/test/search3/Bean3.java",
FIELD_SEARCH, "field3", "", new InjectionPointQueryParticipant(),
matches);
+ }
+
+ public void testInjectionPointQueryParticipantInProject4(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(ClassBean.class, "Base1"));
+ matches.add(new MatchStructure(ClassBean.class, "Base2"));
+ matches.add(new MatchStructure(ClassBean.class, "Base4"));
+
+ testSearchParticipant(project4, "src/cdi/test/search4/Bean4.java",
FIELD_SEARCH, "field4", "", new InjectionPointQueryParticipant(),
matches);
+ }
+
+ public void testInjectionPointQueryParticipantInProject5(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(ClassBean.class, "Base1"));
+ matches.add(new MatchStructure(ClassBean.class, "Base2"));
+ matches.add(new MatchStructure(ClassBean.class, "Base4"));
+ matches.add(new MatchStructure(ClassBean.class, "Base5"));
+
+ testSearchParticipant(project5, "src/cdi/test/search5/Bean5.java",
FIELD_SEARCH, "field5", "", new InjectionPointQueryParticipant(),
matches);
+ }
+
+ public void testCDIBeanQueryParticipantInProject1(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean1.field1"));
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean2.field2"));
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean3.field3"));
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean4.field4"));
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean5.field5"));
+
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean1.method_1(BaseDecoratedInterface param1)"));
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean2.method_2(BaseDecoratedInterface param2)"));
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean3.method_3(BaseDecoratedInterface param3)"));
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean4.method_4(BaseDecoratedInterface param4)"));
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean5.method_5(BaseDecoratedInterface param5)"));
+
+ testSearchParticipant(project1, "src/cdi/test/search1/Base1.java",
TYPE_SEARCH, "Base1", "", new CDIBeanQueryParticipant(), matches);
+ }
+
+ public void testCDIBeanQueryParticipantInProject2(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean2.field2"));
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean3.field3"));
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean4.field4"));
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean5.field5"));
+
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean2.method_2(BaseDecoratedInterface param2)"));
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean3.method_3(BaseDecoratedInterface param3)"));
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean4.method_4(BaseDecoratedInterface param4)"));
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean5.method_5(BaseDecoratedInterface param5)"));
+
+ testSearchParticipant(project2, "src/cdi/test/search2/Base2.java",
TYPE_SEARCH, "Base2", "", new CDIBeanQueryParticipant(), matches);
+ }
+
+ public void testCDIBeanQueryParticipantInProject3(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean3.field3"));
+
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean3.method_3(BaseDecoratedInterface param3)"));
+
+ testSearchParticipant(project3, "src/cdi/test/search3/Base3.java",
TYPE_SEARCH, "Base3", "", new CDIBeanQueryParticipant(), matches);
+ }
+
+ public void testCDIBeanQueryParticipantInProject4(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean4.field4"));
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean5.field5"));
+
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean4.method_4(BaseDecoratedInterface param4)"));
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean5.method_5(BaseDecoratedInterface param5)"));
+
+ testSearchParticipant(project4, "src/cdi/test/search4/Base4.java",
TYPE_SEARCH, "Base4", "", new CDIBeanQueryParticipant(), matches);
+ }
+
+ public void testCDIBeanQueryParticipantInProject5(){
+ ArrayList<MatchStructure> matches = new ArrayList<MatchStructure>();
+
+ matches.add(new MatchStructure(InjectionPointField.class, "Bean5.field5"));
+
+ matches.add(new MatchStructure(InjectionPointParameter.class,
"Bean5.method_5(BaseDecoratedInterface param5)"));
+
+ testSearchParticipant(project5, "src/cdi/test/search5/Base5.java",
TYPE_SEARCH, "Base5", "", new CDIBeanQueryParticipant(), matches);
+ }
+
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsSearchParticipantTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsTestSetup.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsTestSetup.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsTestSetup.java 2011-11-10
21:00:49 UTC (rev 36285)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 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.ui.test.search;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class FiveDependentProjectsTestSetup extends TestSetup {
+ protected static String PLUGIN_ID = "org.jboss.tools.cdi.core.test";
+ IProject project1 = null;
+ IProject project2 = null;
+ IProject project3 = null;
+ IProject project4 = null;
+ IProject project5 = null;
+
+ public FiveDependentProjectsTestSetup(Test test) {
+ super(test);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ project1 = getTestProject("/projects/CDITest1", "CDITest1");
+ project2 = getTestProject("/projects/CDITest2", "CDITest2");
+ project3 = getTestProject("/projects/CDITest3", "CDITest3");
+ project4 = getTestProject("/projects/CDITest4", "CDITest4");
+ project5 = getTestProject("/projects/CDITest5", "CDITest5");
+ }
+
+ private static IProject getTestProject(String projectPath, String projectName) throws
IOException, CoreException, InvocationTargetException, InterruptedException {
+ IProject project = ResourcesUtils.importProject(PLUGIN_ID, projectPath);
+ project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
+ return project;
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
+ project1.delete(true, true, null);
+ project2.delete(true, true, null);
+ project3.delete(true, true, null);
+ project4.delete(true, true, null);
+ project5.delete(true, true, null);
+ JobUtils.waitForIdle();
+ ResourcesUtils.setBuildAutomatically(saveAutoBuild);
+ }
+}
\ No newline at end of file
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.ui.test/src/org/jboss/tools/cdi/ui/test/search/FiveDependentProjectsTestSetup.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain