Author: akazakov
Date: 2011-01-24 17:34:57 -0500 (Mon, 24 Jan 2011)
New Revision: 28586
Modified:
trunk/seam/plugins/org.jboss.tools.seam.base.test/src/org/jboss/tools/seam/core/test/project/facet/Seam2FacetInstallDelegateTest.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
Log:
https://issues.jboss.org/browse/JBIDE-8076 Fixed seam test project class path.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.base.test/src/org/jboss/tools/seam/core/test/project/facet/Seam2FacetInstallDelegateTest.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.base.test/src/org/jboss/tools/seam/core/test/project/facet/Seam2FacetInstallDelegateTest.java 2011-01-24
22:28:56 UTC (rev 28585)
+++
trunk/seam/plugins/org.jboss.tools.seam.base.test/src/org/jboss/tools/seam/core/test/project/facet/Seam2FacetInstallDelegateTest.java 2011-01-24
22:34:57 UTC (rev 28586)
@@ -26,6 +26,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
@@ -37,6 +38,7 @@
import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.core.project.facet.SeamVersion;
import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.internal.core.project.facet.SeamProjectCreator;
public class Seam2FacetInstallDelegateTest extends AbstractSeamFacetTest {
@@ -414,6 +416,27 @@
*/
}
+ /**
+ * See
https://issues.jboss.org/browse/JBIDE-8076
+ *
+ * @throws CoreException
+ * @throws IOException
+ */
+ public void testTestProjectClassPath() throws CoreException, IOException {
+ SeamProjectsSet warPs = new SeamProjectsSet(warProject.getProject());
+
+ IProject testProject = warPs.getTestProject();
+ assertTrue(testProject.exists());
+
+ IClasspathEntry warCpe = SeamProjectCreator.getJreContainer(warProject.getProject());
+ assertNotNull(warCpe);
+
+ IClasspathEntry testCpe = SeamProjectCreator.getJreContainer(testProject);
+ assertNotNull(testCpe);
+
+ assertEquals(warCpe.getPath(), testCpe.getPath());
+ }
+
public void testSeamProperties() {
SeamProjectsSet warPs = new SeamProjectsSet(warProject.getProject());
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2011-01-24
22:28:56 UTC (rev 28585)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamProjectCreator.java 2011-01-24
22:34:57 UTC (rev 28586)
@@ -373,11 +373,15 @@
final IVMInstall vm = JavaRuntime.getDefaultVMInstall();
if (vm != null) {
- int jreIndex = getJreContainer(testProjectToBeImported);
- final IPath path =
CPE_PREFIX_FOR_EXEC_ENV.append(getCorrespondingExecutionEnvironment(level));
- final IClasspathEntry cpe = JavaCore.newContainerEntry(path);
+ // See
https://issues.jboss.org/browse/JBIDE-8076
+ IClasspathEntry cpe = getJreContainer(seamWebProject);
+ if (cpe == null) {
+ final IPath path =
CPE_PREFIX_FOR_EXEC_ENV.append(getCorrespondingExecutionEnvironment(level));
+ cpe = JavaCore.newContainerEntry(path);
+ }
IJavaProject javaProject = JavaCore.create(testProjectToBeImported);
IClasspathEntry[] entries = javaProject.getRawClasspath();
+ int jreIndex = getJreContainerIndex(testProjectToBeImported);
if (jreIndex == -1) {
IClasspathEntry[] newEntries = new IClasspathEntry[entries.length+1];
System.arraycopy( entries, 0, newEntries, 1, entries.length );
@@ -413,7 +417,7 @@
return res;
}
- private static int getJreContainer(final IProject proj)
+ public static int getJreContainerIndex(final IProject proj)
throws CoreException {
final IJavaProject jproj = JavaCore.create(proj);
final IClasspathEntry[] cp = jproj.getRawClasspath();
@@ -425,7 +429,22 @@
}
return -1;
}
-
+
+ public static IClasspathEntry getJreContainer(final IProject proj)
+ throws CoreException {
+ final IJavaProject jproj = JavaCore.create(proj);
+ final IClasspathEntry[] cp = jproj.getRawClasspath();
+ for (int i = 0; i < cp.length; i++) {
+ final IClasspathEntry cpe = cp[i];
+ if (cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER
+ && cpe.getPath().segment(0)
+ .equals(JavaRuntime.JRE_CONTAINER)) {
+ return cpe;
+ }
+ }
+ return null;
+ }
+
/**
* Creates test project for given seam web project.
*/