Author: rob.stryker(a)jboss.com
Date: 2008-06-06 14:31:05 -0400 (Fri, 06 Jun 2008)
New Revision: 8619
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JEEClasspathContainerTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java
Removed:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JEEClasspathContainerTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
Log:
Renaming package
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2008-06-06
18:29:51 UTC (rev 8618)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2008-06-06
18:31:05 UTC (rev 8619)
@@ -24,10 +24,10 @@
import junit.framework.Test;
import junit.framework.TestSuite;
-import org.jboss.ide.eclipse.as.test.model.JBIDE1657Test;
-import org.jboss.ide.eclipse.as.test.model.JEEClasspathContainerTest;
-import org.jboss.ide.eclipse.as.test.model.ProjectRuntimeTest;
-import org.jboss.ide.eclipse.as.test.model.RuntimeServerModelTest;
+import org.jboss.ide.eclipse.as.test.classpath.JBIDE1657Test;
+import org.jboss.ide.eclipse.as.test.classpath.JEEClasspathContainerTest;
+import org.jboss.ide.eclipse.as.test.classpath.ProjectRuntimeTest;
+import org.jboss.ide.eclipse.as.test.classpath.RuntimeServerModelTest;
public class ASTestSuite extends TestSuite {
public static Test suite() {
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath
(from rev 8584,
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model)
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/JBIDE1657Test.java 2008-06-05
14:44:36 UTC (rev 8584)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java 2008-06-06
18:31:05 UTC (rev 8619)
@@ -1,91 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.test.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.wst.server.core.IRuntime;
-import org.jboss.ide.eclipse.as.test.ASTest;
-import org.jboss.ide.eclipse.as.test.util.ProjectRuntimeUtil;
-import org.jboss.tools.common.test.util.TestProjectProvider;
-
-/**
- * This test will test whether the old classpath container,
- * org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer
- * which used to be automatically assigned to WTP projects, still works
- * and will not fail to resolve.
- *
- * @author rob.stryker <rob.stryker(a)redhat.com>
- */
-public class JBIDE1657Test extends TestCase {
- private TestProjectProvider provider;
- private IProject project;
-
- protected void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null,
"basicwebproject", true);
- project = provider.getProject();
- project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- }
-
- protected void tearDown() throws Exception {
- provider.dispose();
- }
-
- public void testJBIDE1657() {
- try {
- IJavaProject jp = JavaCore.create(project);
-
- // lets try a runtime
- IRuntime createdRuntime = ProjectRuntimeUtil.createRuntime("runtime1",
ASTest.JBOSS_RUNTIME_42, ASTest.JBOSS_AS_HOME);
- ProjectRuntimeUtil.setTargetRuntime(createdRuntime, project);
- IClasspathEntry[] raw1 = jp.getRawClasspath();
- IClasspathEntry[] resolved1 = jp.getResolvedClasspath(false);
- IClasspathEntry[] raw2 = new IClasspathEntry[raw1.length];
- for( int i = 0; i < raw1.length; i++ ) {
- if(
!raw1[i].getPath().segment(0).equals("org.eclipse.jst.server.core.container"))
{
- raw2[i]=raw1[i];
- } else {
- IPath containerPath = new
Path("org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer");
- containerPath = containerPath.append("runtime1");
- raw2[i] = JavaCore.newContainerEntry(containerPath);
- }
- }
- jp.setRawClasspath(raw2, new NullProgressMonitor());
- IClasspathEntry[] resolved2 = jp.getResolvedClasspath(false);
- assertEquals("New classpath container path should return the same classpath
entries as the old. ",
- resolved1.length , resolved2.length);
- assertTrue("Should be more than one classpath entry", resolved1.length >
0);
- } catch( CoreException ce ) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
- }
-}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java
(from rev 8618,
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/JBIDE1657Test.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JBIDE1657Test.java 2008-06-06
18:31:05 UTC (rev 8619)
@@ -0,0 +1,91 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.test.classpath;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.wst.server.core.IRuntime;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.ProjectRuntimeUtil;
+import org.jboss.tools.common.test.util.TestProjectProvider;
+
+/**
+ * This test will test whether the old classpath container,
+ * org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer
+ * which used to be automatically assigned to WTP projects, still works
+ * and will not fail to resolve.
+ *
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ */
+public class JBIDE1657Test extends TestCase {
+ private TestProjectProvider provider;
+ private IProject project;
+
+ protected void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null,
"basicwebproject", true);
+ project = provider.getProject();
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ protected void tearDown() throws Exception {
+ provider.dispose();
+ }
+
+ public void testJBIDE1657() {
+ try {
+ IJavaProject jp = JavaCore.create(project);
+
+ // lets try a runtime
+ IRuntime createdRuntime = ProjectRuntimeUtil.createRuntime("runtime1",
ASTest.JBOSS_RUNTIME_42, ASTest.JBOSS_AS_HOME);
+ ProjectRuntimeUtil.setTargetRuntime(createdRuntime, project);
+ IClasspathEntry[] raw1 = jp.getRawClasspath();
+ IClasspathEntry[] resolved1 = jp.getResolvedClasspath(false);
+ IClasspathEntry[] raw2 = new IClasspathEntry[raw1.length];
+ for( int i = 0; i < raw1.length; i++ ) {
+ if(
!raw1[i].getPath().segment(0).equals("org.eclipse.jst.server.core.container"))
{
+ raw2[i]=raw1[i];
+ } else {
+ IPath containerPath = new
Path("org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer");
+ containerPath = containerPath.append("runtime1");
+ raw2[i] = JavaCore.newContainerEntry(containerPath);
+ }
+ }
+ jp.setRawClasspath(raw2, new NullProgressMonitor());
+ IClasspathEntry[] resolved2 = jp.getResolvedClasspath(false);
+ assertEquals("New classpath container path should return the same classpath
entries as the old. ",
+ resolved1.length , resolved2.length);
+ assertTrue("Should be more than one classpath entry", resolved1.length >
0);
+ } catch( CoreException ce ) {
+ ce.printStackTrace();
+ fail(ce.getMessage());
+ }
+ }
+}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JEEClasspathContainerTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/JEEClasspathContainerTest.java 2008-06-05
14:44:36 UTC (rev 8584)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JEEClasspathContainerTest.java 2008-06-06
18:31:05 UTC (rev 8619)
@@ -1,137 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.test.model;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.jboss.tools.common.test.util.TestProjectProvider;
-
-/**
- * This class tests the jee classpath containers
- * to make sure they're returning live jars that exist.
- *
- * @author rob.stryker <rob.stryker(a)redhat.com>
- */
-public class JEEClasspathContainerTest extends TestCase {
-
- private static final int ORIGINAL_ENTRIES = 2;
-
- private TestProjectProvider provider;
- private IProject project;
-
- protected void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null,
"basicwebproject", true);
- project = provider.getProject();
- project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- }
-
- protected void tearDown() throws Exception {
- provider.dispose();
- }
-
- public void testJEE13ClasspathContainer() {
- testGenericClasspathContainer("org.jboss.ide.eclipse.as.classpath.core.j2ee-1.3",
7);
- }
-
- public void testJEE14ClasspathContainer() {
- testGenericClasspathContainer("org.jboss.ide.eclipse.as.classpath.core.j2ee-1.4",
8);
- }
-
- public void testJEE50ClasspathContainer() {
- testGenericClasspathContainer("org.jboss.ide.eclipse.as.classpath.core.javaee-5.0",
1);
- }
-
-
- protected void testGenericClasspathContainer(String containerPath, int expectedEntries)
{
- try {
- IJavaProject jproject = JavaCore.create(project);
- IPath path = new Path(containerPath);
- verifyContainerEntries(path, jproject, expectedEntries);
- verifyRawClasspathCount(jproject, ORIGINAL_ENTRIES);
- verifyNotIncludedEntry(jproject, path);
- int beforeRawCount = jproject.getRawClasspath().length;
- int beforeResolvedCount = jproject.getResolvedClasspath(true).length;
- addContainer(jproject, path);
- assertEquals(beforeRawCount+1, jproject.getRawClasspath().length);
- assertEquals(beforeResolvedCount+expectedEntries,
jproject.getResolvedClasspath(true).length);
- beforeRawCount = jproject.getRawClasspath().length;
- beforeResolvedCount = jproject.getResolvedClasspath(true).length;
- removeContainer(jproject, path);
- assertEquals(beforeRawCount-1, jproject.getRawClasspath().length);
- assertEquals(beforeResolvedCount-expectedEntries,
jproject.getResolvedClasspath(true).length);
-
- } catch( JavaModelException jme ) {
- fail("Exception: " + jme.getMessage());
- } catch( CoreException ce ) {
- fail("Exception: " + ce.getMessage());
- }
-
- }
-
- protected void verifyContainerEntries(IPath path, IJavaProject jproject, int expected)
throws JavaModelException {
- IClasspathContainer cpc = JavaCore.getClasspathContainer(path, jproject);
- IClasspathEntry[] entries = cpc.getClasspathEntries();
- assertEquals("Received unexpected number of entries", expected,
entries.length );
- }
-
- protected void verifyRawClasspathCount(IJavaProject jproject, int count) throws
JavaModelException {
- IClasspathEntry[] projectEntry = jproject.getRawClasspath();
- assertEquals("Project should start with only " + count + " classpath
entries", count, projectEntry.length);
- }
-
- protected void verifyNotIncludedEntry(IJavaProject jproject, IPath path) throws
JavaModelException {
- IClasspathEntry[] projectEntry = jproject.getRawClasspath();
- for( int i = 0; i < projectEntry.length; i++ ) {
- if( projectEntry[i].getPath().toOSString().startsWith(path.toOSString())) {
- assertFalse("Project prematurely includes classpath", true);
- }
- }
- }
-
- protected void addContainer(IJavaProject jproject, IPath path) throws JavaModelException
{
- ArrayList tmp = new ArrayList();
- tmp.addAll(Arrays.asList(jproject.getRawClasspath()));
- tmp.add(JavaCore.newContainerEntry(path));
- jproject.setRawClasspath((IClasspathEntry[]) tmp.toArray(new
IClasspathEntry[tmp.size()]), null);
- }
-
- protected void removeContainer(IJavaProject jproject, IPath path) throws
JavaModelException {
- ArrayList tmp = new ArrayList();
- tmp.addAll(Arrays.asList(jproject.getRawClasspath()));
- tmp.remove(JavaCore.newContainerEntry(path));
- jproject.setRawClasspath((IClasspathEntry[]) tmp.toArray(new
IClasspathEntry[tmp.size()]), null);
- }
-}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JEEClasspathContainerTest.java
(from rev 8618,
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/JEEClasspathContainerTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JEEClasspathContainerTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/JEEClasspathContainerTest.java 2008-06-06
18:31:05 UTC (rev 8619)
@@ -0,0 +1,137 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.test.classpath;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.jboss.tools.common.test.util.TestProjectProvider;
+
+/**
+ * This class tests the jee classpath containers
+ * to make sure they're returning live jars that exist.
+ *
+ * @author rob.stryker <rob.stryker(a)redhat.com>
+ */
+public class JEEClasspathContainerTest extends TestCase {
+
+ private static final int ORIGINAL_ENTRIES = 2;
+
+ private TestProjectProvider provider;
+ private IProject project;
+
+ protected void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null,
"basicwebproject", true);
+ project = provider.getProject();
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ protected void tearDown() throws Exception {
+ provider.dispose();
+ }
+
+ public void testJEE13ClasspathContainer() {
+ testGenericClasspathContainer("org.jboss.ide.eclipse.as.classpath.core.j2ee-1.3",
7);
+ }
+
+ public void testJEE14ClasspathContainer() {
+ testGenericClasspathContainer("org.jboss.ide.eclipse.as.classpath.core.j2ee-1.4",
8);
+ }
+
+ public void testJEE50ClasspathContainer() {
+ testGenericClasspathContainer("org.jboss.ide.eclipse.as.classpath.core.javaee-5.0",
1);
+ }
+
+
+ protected void testGenericClasspathContainer(String containerPath, int expectedEntries)
{
+ try {
+ IJavaProject jproject = JavaCore.create(project);
+ IPath path = new Path(containerPath);
+ verifyContainerEntries(path, jproject, expectedEntries);
+ verifyRawClasspathCount(jproject, ORIGINAL_ENTRIES);
+ verifyNotIncludedEntry(jproject, path);
+ int beforeRawCount = jproject.getRawClasspath().length;
+ int beforeResolvedCount = jproject.getResolvedClasspath(true).length;
+ addContainer(jproject, path);
+ assertEquals(beforeRawCount+1, jproject.getRawClasspath().length);
+ assertEquals(beforeResolvedCount+expectedEntries,
jproject.getResolvedClasspath(true).length);
+ beforeRawCount = jproject.getRawClasspath().length;
+ beforeResolvedCount = jproject.getResolvedClasspath(true).length;
+ removeContainer(jproject, path);
+ assertEquals(beforeRawCount-1, jproject.getRawClasspath().length);
+ assertEquals(beforeResolvedCount-expectedEntries,
jproject.getResolvedClasspath(true).length);
+
+ } catch( JavaModelException jme ) {
+ fail("Exception: " + jme.getMessage());
+ } catch( CoreException ce ) {
+ fail("Exception: " + ce.getMessage());
+ }
+
+ }
+
+ protected void verifyContainerEntries(IPath path, IJavaProject jproject, int expected)
throws JavaModelException {
+ IClasspathContainer cpc = JavaCore.getClasspathContainer(path, jproject);
+ IClasspathEntry[] entries = cpc.getClasspathEntries();
+ assertEquals("Received unexpected number of entries", expected,
entries.length );
+ }
+
+ protected void verifyRawClasspathCount(IJavaProject jproject, int count) throws
JavaModelException {
+ IClasspathEntry[] projectEntry = jproject.getRawClasspath();
+ assertEquals("Project should start with only " + count + " classpath
entries", count, projectEntry.length);
+ }
+
+ protected void verifyNotIncludedEntry(IJavaProject jproject, IPath path) throws
JavaModelException {
+ IClasspathEntry[] projectEntry = jproject.getRawClasspath();
+ for( int i = 0; i < projectEntry.length; i++ ) {
+ if( projectEntry[i].getPath().toOSString().startsWith(path.toOSString())) {
+ assertFalse("Project prematurely includes classpath", true);
+ }
+ }
+ }
+
+ protected void addContainer(IJavaProject jproject, IPath path) throws JavaModelException
{
+ ArrayList tmp = new ArrayList();
+ tmp.addAll(Arrays.asList(jproject.getRawClasspath()));
+ tmp.add(JavaCore.newContainerEntry(path));
+ jproject.setRawClasspath((IClasspathEntry[]) tmp.toArray(new
IClasspathEntry[tmp.size()]), null);
+ }
+
+ protected void removeContainer(IJavaProject jproject, IPath path) throws
JavaModelException {
+ ArrayList tmp = new ArrayList();
+ tmp.addAll(Arrays.asList(jproject.getRawClasspath()));
+ tmp.remove(JavaCore.newContainerEntry(path));
+ jproject.setRawClasspath((IClasspathEntry[]) tmp.toArray(new
IClasspathEntry[tmp.size()]), null);
+ }
+}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/ProjectRuntimeTest.java 2008-06-05
14:44:36 UTC (rev 8584)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java 2008-06-06
18:31:05 UTC (rev 8619)
@@ -1,110 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.test.model;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.core.JavaModelException;
-import org.eclipse.wst.server.core.IRuntime;
-import org.jboss.ide.eclipse.as.test.ASTest;
-import org.jboss.ide.eclipse.as.test.util.ProjectRuntimeUtil;
-import org.jboss.tools.common.test.util.TestProjectProvider;
-
-public class ProjectRuntimeTest extends TestCase {
- private TestProjectProvider provider;
- private IProject project;
-
- protected void setUp() throws Exception {
- provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null,
"basicwebproject", true);
- project = provider.getProject();
- project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
- }
-
- protected void tearDown() throws Exception {
- provider.dispose();
- }
-
- public void testProjectRuntime() {
- try {
- IJavaProject jp = JavaCore.create(project);
- verifyInitialClasspathEntries(jp);
-
- // lets try a runtime
- IRuntime createdRuntime = ProjectRuntimeUtil.createRuntime("runtime1",
ASTest.JBOSS_RUNTIME_42, ASTest.JBOSS_AS_HOME);
- ProjectRuntimeUtil.setTargetRuntime(createdRuntime, project);
- verifyPostRuntimeCPE(jp);
-
- ProjectRuntimeUtil.clearRuntime(project);
- verifyInitialClasspathEntries(jp);
-
- } catch( JavaModelException jme ) {
- jme.printStackTrace();
- fail(jme.getMessage());
- } catch( CoreException ce ) {
- ce.printStackTrace();
- fail(ce.getMessage());
- }
- }
-
- protected void verifyPostRuntimeCPE(IJavaProject jp) throws CoreException {
- IClasspathEntry[] entries = jp.getRawClasspath();
- assertEquals(3, entries.length);
- jp.getResolvedClasspath(false); // make sure it can resolve all
- String[] required = new String[] { "org.eclipse.jst.server.core.container",
- "basicwebproject", "org.eclipse.jst.j2ee.internal.web.container"
};
- verifyClasspathEntries(entries, required);
- }
-
- protected void verifyInitialClasspathEntries(IJavaProject jp) throws CoreException {
- IClasspathEntry[] entries = jp.getRawClasspath();
- jp.getResolvedClasspath(false); // make sure it can resolve all
- String[] required = new String[] {
- "org.eclipse.jst.j2ee.internal.web.container",
"basicwebproject"};
- verifyClasspathEntries(entries, required);
- }
-
- protected void verifyClasspathEntries(IClasspathEntry[] entries, String[] required) {
- ArrayList list = new ArrayList(Arrays.asList(required));
- for( int i = 0; i < entries.length; i++ ) {
- if( list.contains(entries[i].getPath().segment(0)))
- list.remove(entries[i].getPath().segment(0));
- }
-
- if( list.size() > 0 ) {
- String tmp = "Required enties not found: ";
- for( int i = 0; i < list.size(); i++ ) {
- tmp += list.get(i) + ", ";
- }
- fail(tmp.substring(0, tmp.length() - 2));
- }
- }
-}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java
(from rev 8618,
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/ProjectRuntimeTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/ProjectRuntimeTest.java 2008-06-06
18:31:05 UTC (rev 8619)
@@ -0,0 +1,110 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.test.classpath;
+
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.wst.server.core.IRuntime;
+import org.jboss.ide.eclipse.as.test.ASTest;
+import org.jboss.ide.eclipse.as.test.util.ProjectRuntimeUtil;
+import org.jboss.tools.common.test.util.TestProjectProvider;
+
+public class ProjectRuntimeTest extends TestCase {
+ private TestProjectProvider provider;
+ private IProject project;
+
+ protected void setUp() throws Exception {
+ provider = new TestProjectProvider("org.jboss.ide.eclipse.as.test", null,
"basicwebproject", true);
+ project = provider.getProject();
+ project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ }
+
+ protected void tearDown() throws Exception {
+ provider.dispose();
+ }
+
+ public void testProjectRuntime() {
+ try {
+ IJavaProject jp = JavaCore.create(project);
+ verifyInitialClasspathEntries(jp);
+
+ // lets try a runtime
+ IRuntime createdRuntime = ProjectRuntimeUtil.createRuntime("runtime1",
ASTest.JBOSS_RUNTIME_42, ASTest.JBOSS_AS_HOME);
+ ProjectRuntimeUtil.setTargetRuntime(createdRuntime, project);
+ verifyPostRuntimeCPE(jp);
+
+ ProjectRuntimeUtil.clearRuntime(project);
+ verifyInitialClasspathEntries(jp);
+
+ } catch( JavaModelException jme ) {
+ jme.printStackTrace();
+ fail(jme.getMessage());
+ } catch( CoreException ce ) {
+ ce.printStackTrace();
+ fail(ce.getMessage());
+ }
+ }
+
+ protected void verifyPostRuntimeCPE(IJavaProject jp) throws CoreException {
+ IClasspathEntry[] entries = jp.getRawClasspath();
+ assertEquals(3, entries.length);
+ jp.getResolvedClasspath(false); // make sure it can resolve all
+ String[] required = new String[] { "org.eclipse.jst.server.core.container",
+ "basicwebproject", "org.eclipse.jst.j2ee.internal.web.container"
};
+ verifyClasspathEntries(entries, required);
+ }
+
+ protected void verifyInitialClasspathEntries(IJavaProject jp) throws CoreException {
+ IClasspathEntry[] entries = jp.getRawClasspath();
+ jp.getResolvedClasspath(false); // make sure it can resolve all
+ String[] required = new String[] {
+ "org.eclipse.jst.j2ee.internal.web.container",
"basicwebproject"};
+ verifyClasspathEntries(entries, required);
+ }
+
+ protected void verifyClasspathEntries(IClasspathEntry[] entries, String[] required) {
+ List<String> list = Arrays.asList(required);
+ for( int i = 0; i < entries.length; i++ ) {
+ if( list.contains(entries[i].getPath().segment(0)))
+ list.remove(entries[i].getPath().segment(0));
+ }
+
+ if( list.size() > 0 ) {
+ String tmp = "Required enties not found: ";
+ for( int i = 0; i < list.size(); i++ ) {
+ tmp += list.get(i) + ", ";
+ }
+ fail(tmp.substring(0, tmp.length() - 2));
+ }
+ }
+}
Deleted:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/RuntimeServerModelTest.java 2008-06-05
14:44:36 UTC (rev 8584)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java 2008-06-06
18:31:05 UTC (rev 8619)
@@ -1,72 +0,0 @@
-/**
- * JBoss, a Division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
-* This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.as.test.model;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.wst.server.core.IRuntime;
-import org.eclipse.wst.server.core.IRuntimeType;
-import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
-import org.eclipse.wst.server.core.ServerUtil;
-import org.jboss.ide.eclipse.as.test.ASTest;
-
-public class RuntimeServerModelTest extends TestCase {
-
- //
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201340
- // skipped since reported issue and always failing
- public void skip_testDoubleCreateEclipseBug201340() throws CoreException {
- createGenericRuntime(ASTest.TOMCAT_RUNTIME_55);
- createGenericRuntime(ASTest.JBOSS_RUNTIME_42);
- }
-
- private IRuntime[] createGenericRuntime(String runtimeId) throws CoreException {
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null, runtimeId);
- assertEquals("expects only one runtime type", runtimeTypes.length, 1);
-
- IRuntimeType runtimeType = runtimeTypes[0];
-
- IRuntimeWorkingCopy firstRuntime = runtimeType.createRuntime(null, new
NullProgressMonitor());
- IRuntime savedRuntime = firstRuntime.save(true, new NullProgressMonitor());
-
- IRuntimeWorkingCopy secondRuntime = runtimeType.createRuntime(null, new
NullProgressMonitor());
- IRuntime secondSavedRuntime = secondRuntime.save(true, new NullProgressMonitor());
-
- assertEquals(savedRuntime.getName(), secondSavedRuntime.getName());
- assertNotSame(savedRuntime, secondSavedRuntime);
- assertFalse("Why are two different runtimes " + runtimeId + " created
with the same ID ?!", savedRuntime.getId().equals(secondSavedRuntime.getId()));
- return new IRuntime[] { savedRuntime, secondSavedRuntime };
- }
-
- public void testCreateBrokenServer() throws CoreException {
- IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null,
ASTest.JBOSS_RUNTIME_42);
- assertEquals("expects only one runtime type for jboss 4.2",
runtimeTypes.length, 1);
- IRuntimeType runtimeType = runtimeTypes[0];
- IRuntimeWorkingCopy jbossRuntime = runtimeType.createRuntime(null, new
NullProgressMonitor());
- IRuntime savedRuntime = jbossRuntime.save(true, new NullProgressMonitor());
- assertEquals("Neither vm install nor configuration is set - should not be able to
validate",savedRuntime.validate(null).getSeverity(), Status.ERROR);
- }
-
-
-}
Copied:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java
(from rev 8618,
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/RuntimeServerModelTest.java)
===================================================================
---
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/classpath/RuntimeServerModelTest.java 2008-06-06
18:31:05 UTC (rev 8619)
@@ -0,0 +1,72 @@
+/**
+ * JBoss, a Division of Red Hat
+ * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+* This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.ide.eclipse.as.test.classpath;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.wst.server.core.IRuntime;
+import org.eclipse.wst.server.core.IRuntimeType;
+import org.eclipse.wst.server.core.IRuntimeWorkingCopy;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.jboss.ide.eclipse.as.test.ASTest;
+
+public class RuntimeServerModelTest extends TestCase {
+
+ //
https://bugs.eclipse.org/bugs/show_bug.cgi?id=201340
+ // skipped since reported issue and always failing
+ public void skip_testDoubleCreateEclipseBug201340() throws CoreException {
+ createGenericRuntime(ASTest.TOMCAT_RUNTIME_55);
+ createGenericRuntime(ASTest.JBOSS_RUNTIME_42);
+ }
+
+ private IRuntime[] createGenericRuntime(String runtimeId) throws CoreException {
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null, runtimeId);
+ assertEquals("expects only one runtime type", runtimeTypes.length, 1);
+
+ IRuntimeType runtimeType = runtimeTypes[0];
+
+ IRuntimeWorkingCopy firstRuntime = runtimeType.createRuntime(null, new
NullProgressMonitor());
+ IRuntime savedRuntime = firstRuntime.save(true, new NullProgressMonitor());
+
+ IRuntimeWorkingCopy secondRuntime = runtimeType.createRuntime(null, new
NullProgressMonitor());
+ IRuntime secondSavedRuntime = secondRuntime.save(true, new NullProgressMonitor());
+
+ assertEquals(savedRuntime.getName(), secondSavedRuntime.getName());
+ assertNotSame(savedRuntime, secondSavedRuntime);
+ assertFalse("Why are two different runtimes " + runtimeId + " created
with the same ID ?!", savedRuntime.getId().equals(secondSavedRuntime.getId()));
+ return new IRuntime[] { savedRuntime, secondSavedRuntime };
+ }
+
+ public void testCreateBrokenServer() throws CoreException {
+ IRuntimeType[] runtimeTypes = ServerUtil.getRuntimeTypes(null,null,
ASTest.JBOSS_RUNTIME_42);
+ assertEquals("expects only one runtime type for jboss 4.2",
runtimeTypes.length, 1);
+ IRuntimeType runtimeType = runtimeTypes[0];
+ IRuntimeWorkingCopy jbossRuntime = runtimeType.createRuntime(null, new
NullProgressMonitor());
+ IRuntime savedRuntime = jbossRuntime.save(true, new NullProgressMonitor());
+ assertEquals("Neither vm install nor configuration is set - should not be able to
validate",savedRuntime.validate(null).getSeverity(), Status.ERROR);
+ }
+
+
+}