Author: scabanovich
Date: 2011-05-06 20:46:33 -0400 (Fri, 06 May 2011)
New Revision: 31136
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/lib/example.jar
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/MyExampleFactory.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/lib/example.jar
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/test/MyExampleInjection.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/DependentProjectsTestSetup.java
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/.classpath
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/.classpath
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/DependentProjectTest.java
Log:
JBIDE-8872
https://issues.jboss.org/browse/JBIDE-8872
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/.classpath
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/.classpath 2011-05-06
23:10:27 UTC (rev 31135)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/.classpath 2011-05-07
00:46:33 UTC (rev 31136)
@@ -9,5 +9,6 @@
<classpathentry kind="lib" path="lib/weld-se.jar"/>
<classpathentry kind="lib" path="lib/weld-servlet.jar"/>
<classpathentry kind="lib" path="lib/some-weld.jar"/>
+ <classpathentry kind="lib" path="lib/example.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/lib/example.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/lib/example.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/MyExampleFactory.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/MyExampleFactory.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/MyExampleFactory.java 2011-05-07
00:46:33 UTC (rev 31136)
@@ -0,0 +1,13 @@
+package cdi.test;
+
+import javax.enterprise.inject.Produces;
+
+import org.jboss.cdi.test.example.Example;
+
+public class MyExampleFactory {
+
+ @Produces
+ public Example createExample() {
+ return new Example();
+ }
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest1/src/cdi/test/MyExampleFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/.classpath
===================================================================
--- trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/.classpath 2011-05-06
23:10:27 UTC (rev 31135)
+++ trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/.classpath 2011-05-07
00:46:33 UTC (rev 31136)
@@ -4,6 +4,7 @@
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry exported="true" kind="lib"
path="lib/cdi-api.jar"/>
<classpathentry exported="true" kind="lib"
path="lib/javax.inject.jar"/>
+ <classpathentry kind="lib" path="lib/example.jar"/>
<classpathentry combineaccessrules="false" exported="true"
kind="src" path="/CDITest1"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Added: trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/lib/example.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/lib/example.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/test/MyExampleInjection.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/test/MyExampleInjection.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/test/MyExampleInjection.java 2011-05-07
00:46:33 UTC (rev 31136)
@@ -0,0 +1,11 @@
+package test;
+
+import javax.inject.Inject;
+
+import org.jboss.cdi.test.example.Example;
+
+public class MyExampleInjection {
+
+ @Inject
+ Example example1;
+}
Property changes on:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/projects/CDITest2/src/test/MyExampleInjection.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2011-05-06
23:10:27 UTC (rev 31135)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/CDICoreAllTests.java 2011-05-07
00:46:33 UTC (rev 31136)
@@ -99,7 +99,10 @@
suiteAll.addTestSuite(ExtensionFactoryTest.class);
suiteAll.addTestSuite(WeldJarTest.class);
suiteAll.addTestSuite(BeansXMLTest.class);
- suiteAll.addTestSuite(DependentProjectTest.class);
+ TestSuite dependentSuite = new TestSuite("Dependent Projects Tests");
+ dependentSuite.addTestSuite(DependentProjectTest.class);
+ DependentProjectsTestSetup dependent = new DependentProjectsTestSetup(dependentSuite);
+ suiteAll.addTest(dependent);
suiteAll.addTestSuite(EnableCDISupportForWarTest.class);
suiteAll.addTestSuite(EnableCDISupportForJarTest.class);
suiteAll.addTestSuite(DependentProjectValidationTest.class);
Modified:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/DependentProjectTest.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/DependentProjectTest.java 2011-05-06
23:10:27 UTC (rev 31135)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/DependentProjectTest.java 2011-05-07
00:46:33 UTC (rev 31136)
@@ -10,9 +10,11 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IType;
import org.jboss.tools.cdi.core.CDIConstants;
import org.jboss.tools.cdi.core.CDICoreNature;
import org.jboss.tools.cdi.core.CDICorePlugin;
@@ -20,12 +22,15 @@
import org.jboss.tools.cdi.core.IBean;
import org.jboss.tools.cdi.core.ICDIProject;
import org.jboss.tools.cdi.core.IClassBean;
+import org.jboss.tools.cdi.core.IInjectionPoint;
+import org.jboss.tools.cdi.core.IInjectionPointField;
import org.jboss.tools.cdi.core.IProducer;
+import org.jboss.tools.cdi.core.IProducerMethod;
import org.jboss.tools.cdi.core.IQualifier;
import org.jboss.tools.cdi.core.IScope;
+import org.jboss.tools.cdi.internal.core.impl.ProducerMethod;
import org.jboss.tools.jst.web.kb.IKbProject;
import org.jboss.tools.jst.web.kb.KbProjectFactory;
-import org.jboss.tools.jst.web.kb.WebKbPlugin;
import org.jboss.tools.jst.web.kb.internal.KbProject;
import org.jboss.tools.test.util.JobUtils;
import org.jboss.tools.test.util.ResourcesUtils;
@@ -41,20 +46,46 @@
IProject project2 = null;
IProject project3 = null;
- public DependentProjectTest() {}
+ public DependentProjectTest() {
+ project1 = getTestProject(project1, "/projects/CDITest1",
"CDITest1");
+ project2 = getTestProject(project2, "/projects/CDITest2",
"CDITest2");
+ project3 = getTestProject(project3, "/projects/CDITest3",
"CDITest3");
+ }
+
+ public static IProject getTestProject(IProject project, String projectPath, String
projectName) {
+ if(project==null) {
+ try {
+ project = findTestProject(projectName);
+ if(project==null || !project.exists()) {
+ project = ResourcesUtils.importProject(PLUGIN_ID, projectPath);
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ JobUtils.waitForIdle();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Can't import CDI test project: " + e.getMessage());
+ }
+ }
+ return project;
+ }
- public void setUp() throws Exception {
- project1 = ResourcesUtils.importProject(PLUGIN_ID, "/projects/CDITest1");
- project1.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- JobUtils.waitForIdle();
+ public static IProject findTestProject(String projectName) {
+ return ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ }
- project2 = ResourcesUtils.importProject(PLUGIN_ID, "/projects/CDITest2");
- project2.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- JobUtils.waitForIdle();
-
- project3 = ResourcesUtils.importProject(PLUGIN_ID, "/projects/CDITest3");
- project3.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- JobUtils.waitForIdle();
+ public void testProjectDependencyLoading() throws CoreException, IOException {
+ IKbProject kb2 = KbProjectFactory.getKbProject(project2, true);
+ ((KbProject)kb2).store();
+ CDICoreNature cdi2 = CDICorePlugin.getCDI(project2, true);
+ Set<CDICoreNature> dependsOn = cdi2.getCDIProjects();
+ Set<CDICoreNature> usedBy = cdi2.getDependentProjects();
+ assertEquals(1, dependsOn.size());
+ assertEquals(1, usedBy.size());
+ cdi2.reloadProjectDependencies();
+ dependsOn = cdi2.getCDIProjects();
+ usedBy = cdi2.getDependentProjects();
+ assertEquals(1, dependsOn.size());
+ assertEquals(1, usedBy.size());
}
public void testDependentProject() throws CoreException, IOException {
@@ -80,22 +111,6 @@
}
}
- public void testCleanDependentProject() throws CoreException, IOException {
- ICDIProject cdi2 = CDICorePlugin.getCDIProject(project2, true);
- boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
- JobUtils.waitForIdle();
-
- cdi2.getNature().getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, new
NullProgressMonitor());
- JobUtils.waitForIdle();
- assertBeanIsPresent(cdi2, "cdi.test.MyBean", true);
-
- ResourcesUtils.setBuildAutomatically(true);
- JobUtils.waitForIdle();
- assertBeanIsPresent(cdi2, "cdi.test.MyBean", true);
-
- ResourcesUtils.setBuildAutomatically(saveAutoBuild);
- }
-
public void testScopeFromParentProject() throws CoreException, IOException {
IProducer producer = getProducer("/CDITest2/src/test/Test1.java");
@@ -146,28 +161,40 @@
assertNotNull(q);
}
- public void testProjectDependencyLoading() throws CoreException, IOException {
- IKbProject kb2 = KbProjectFactory.getKbProject(project2, true);
- ((KbProject)kb2).store();
- CDICoreNature cdi2 = CDICorePlugin.getCDI(project2, true);
- Set<CDICoreNature> dependsOn = cdi2.getCDIProjects();
- Set<CDICoreNature> usedBy = cdi2.getDependentProjects();
- assertEquals(1, dependsOn.size());
- assertEquals(1, usedBy.size());
- cdi2.reloadProjectDependencies();
- dependsOn = cdi2.getCDIProjects();
- usedBy = cdi2.getDependentProjects();
- assertEquals(1, dependsOn.size());
- assertEquals(1, usedBy.size());
+ public void testInjectionOfTypeRepeatedInJarCopies() throws CoreException {
+ ICDIProject cdi2 = CDICorePlugin.getCDIProject(project2, true);
+ Set<IBean> bs = cdi2.getBeans(new
Path("/CDITest2/src/test/MyExampleInjection.java"));
+ assertEquals(1, bs.size());
+ IBean b = bs.iterator().next();
+ Set<IInjectionPoint> ps = b.getInjectionPoints();
+ assertEquals(1, ps.size());
+ IInjectionPoint p = ps.iterator().next();
+ Set<IBean> injected = cdi2.getBeans(false, p);
+ assertEquals(1, injected.size());
+ IBean i = injected.iterator().next();
+ assertTrue(i instanceof IProducerMethod);
+ IProducerMethod f = (IProducerMethod)i;
+ IType producerType = ((ProducerMethod)f).getType().getType();
+ IType injectionType = ((IInjectionPointField)p).getMemberType().getType();
+ assertEquals("org.jboss.cdi.test.example.Example",
producerType.getFullyQualifiedName());
+ assertEquals("org.jboss.cdi.test.example.Example",
injectionType.getFullyQualifiedName());
+ assertFalse(producerType.equals(injectionType));
}
- public void tearDown() throws Exception {
+ public void testCleanDependentProject() throws CoreException, IOException {
+ ICDIProject cdi2 = CDICorePlugin.getCDIProject(project2, true);
boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
JobUtils.waitForIdle();
- project1.delete(true, true, null);
- project2.delete(true, true, null);
- project3.delete(true, true, null);
+
+ cdi2.getNature().getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, new
NullProgressMonitor());
JobUtils.waitForIdle();
+ assertBeanIsPresent(cdi2, "cdi.test.MyBean", true);
+
+ ResourcesUtils.setBuildAutomatically(true);
+ JobUtils.waitForIdle();
+ assertBeanIsPresent(cdi2, "cdi.test.MyBean", true);
+
ResourcesUtils.setBuildAutomatically(saveAutoBuild);
}
-}
\ No newline at end of file
+
+}
Added:
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/DependentProjectsTestSetup.java
===================================================================
---
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/DependentProjectsTestSetup.java
(rev 0)
+++
trunk/cdi/tests/org.jboss.tools.cdi.core.test/src/org/jboss/tools/cdi/core/test/DependentProjectsTestSetup.java 2011-05-07
00:46:33 UTC (rev 31136)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * 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.core.test;
+
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.jboss.tools.test.util.JobUtils;
+import org.jboss.tools.test.util.ResourcesUtils;
+
+/**
+ * @author Viacheslav Kabanovich
+ */
+public class DependentProjectsTestSetup extends TestSetup {
+ protected static String PLUGIN_ID = "org.jboss.tools.cdi.core.test";
+ IProject project1 = null;
+ IProject project2 = null;
+ IProject project3 = null;
+
+ public DependentProjectsTestSetup(Test test) {
+ super(test);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ project1 = DependentProjectTest.getTestProject(project1,
"/projects/CDITest1", "CDITest1");
+ project2 = DependentProjectTest.getTestProject(project2,
"/projects/CDITest2", "CDITest2");
+ project3 = DependentProjectTest.getTestProject(project3,
"/projects/CDITest3", "CDITest3");
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ boolean saveAutoBuild = ResourcesUtils.setBuildAutomatically(false);
+ JobUtils.waitForIdle();
+ project1.delete(true, true, null);
+ project2.delete(true, true, null);
+ project3.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.core.test/src/org/jboss/tools/cdi/core/test/DependentProjectsTestSetup.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain