Author: akazakov
Date: 2010-03-15 17:15:03 -0400 (Mon, 15 Mar 2010)
New Revision: 20837
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-5808
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-03-15
21:11:04 UTC (rev 20836)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.core/src/org/jboss/tools/cdi/internal/core/impl/CDIProject.java 2010-03-15
21:15:03 UTC (rev 20837)
@@ -31,6 +31,7 @@
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDICoreNature;
+import org.jboss.tools.cdi.core.CDICorePlugin;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
@@ -178,7 +179,7 @@
public Set<IBean> getBeans(boolean attemptToResolveAmbiguousDependency,
IType beanType, IAnnotationDeclaration... qualifiers) {
// TODO
- return null;
+ return Collections.emptySet();
}
public Set<IBean> getBeans(IInjectionPoint injectionPoints) {
@@ -203,7 +204,7 @@
result.add(b);
}
} catch (CoreException e) {
-
+ CDICorePlugin.getDefault().logError(e);
}
}
}
@@ -397,7 +398,7 @@
}
}
} catch (JavaModelException e) {
-
+ CDICorePlugin.getDefault().logError(e);
}
return true;
}
@@ -596,12 +597,12 @@
addBean(bean);
}
- System.out.println("Project=" + getNature().getProject());
- System.out.println("Qualifiers=" + qualifiers.size());
- System.out.println("Stereotypes=" + stereotypes.size());
- System.out.println("Scopes=" + scopes.size());
- System.out.println("Named beans=" + beansByName.size());
- System.out.println("Bean paths=" + beansByPath.size());
+// System.out.println("Project=" + getNature().getProject());
+// System.out.println("Qualifiers=" + qualifiers.size());
+// System.out.println("Stereotypes=" + stereotypes.size());
+// System.out.println("Scopes=" + scopes.size());
+// System.out.println("Named beans=" + beansByName.size());
+// System.out.println("Bean paths=" + beansByPath.size());
}
void addBean(IBean bean) {
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java 2010-03-15
21:11:04 UTC (rev 20836)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/QualifierDefinitionTest.java 2010-03-15
21:15:03 UTC (rev 20837)
@@ -12,6 +12,7 @@
import java.util.Set;
+import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IBean;
@@ -86,4 +87,19 @@
// TODO use correct start position instead of 0.
assertLocationEquals(declarations, 0, 12);
}
+
+ /**
+ * section 2.3.3 d)
+ * @throws JavaModelException
+ */
+ public void testMultipleQualifiers() throws JavaModelException {
+ IAnnotationDeclaration chunky =
getAnnotationDeclarationFromBean("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/Cod.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Chunky");
+ IAnnotationDeclaration whitefish =
getAnnotationDeclarationFromBean("JavaSource/org/jboss/jsr299/tck/tests/definition/qualifier/Cod.java",
"org.jboss.jsr299.tck.tests.definition.qualifier.Whitefish");
+ IType type = getType("org.jboss.jsr299.tck.tests.definition.qualifier.Cod");
+ Set<IBean> beans = cdiProject.getBeans(true, type, chunky, whitefish);
+ assertEquals("Wrong number of beans.", 1, beans.size());
+ IBean bean = beans.iterator().next();
+ Set<IQualifier> qualifiers = bean.getQualifiers();
+ assertEquals("Wrong number of qualifiers.", 4, qualifiers.size());
+ }
}
\ No newline at end of file
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-03-15
21:11:04 UTC (rev 20836)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/tck/TCKTest.java 2010-03-15
21:15:03 UTC (rev 20837)
@@ -6,15 +6,19 @@
import junit.framework.TestCase;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.jboss.tools.cdi.core.CDICorePlugin;
+import org.jboss.tools.cdi.core.IAnnotationDeclaration;
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IParametedType;
@@ -107,6 +111,37 @@
return beans;
}
+ protected IAnnotationDeclaration getAnnotationDeclarationFromBean(String
beanClassFilePath, String annotationTypeName) throws JavaModelException {
+ IFile file = tckProject.getFile(beanClassFilePath);
+ Set<IBean> beans = cdiProject.getBeans(file.getFullPath());
+ IBean bean = beans.iterator().next();
+ final IType beanClass = bean.getBeanClass();
+ final IType type = getType(annotationTypeName);
+ final IAnnotation annotation = beanClass.getAnnotation(type.getElementName());
+ IAnnotationDeclaration annotationDeclaration = new IAnnotationDeclaration() {
+ public IAnnotation getDeclaration() {
+ return annotation;
+ }
+
+ public IMember getParentMember() {
+ return beanClass;
+ }
+
+ public IType getType() {
+ return type;
+ }
+
+ public int getLength() {
+ return 0;
+ }
+
+ public int getStartPosition() {
+ return 0;
+ }
+ };
+ return annotationDeclaration;
+ }
+
protected void assertTheOnlyBean(String typeName) throws JavaModelException {
Set<IBean> beans = getBeans(typeName);
assertEquals("There should be the only bean with " + typeName + "
type", 1, beans.size());