Author: rob.stryker(a)jboss.com
Date: 2008-01-31 19:39:39 -0500 (Thu, 31 Jan 2008)
New Revision: 6085
Added:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/JBIDE1657Test.java
Modified:
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java
Log:
JBIDE-1657 - regression test to make sure the new default classpath container returns the
same elements as the old and that the old still works so users with old projects will not
experience errors.
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-02-01
00:12:19 UTC (rev 6084)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/ASTestSuite.java 2008-02-01
00:39:39 UTC (rev 6085)
@@ -24,7 +24,7 @@
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.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;
@@ -36,7 +36,7 @@
suite.addTestSuite(RuntimeServerModelTest.class);
suite.addTestSuite(JEEClasspathContainerTest.class);
suite.addTestSuite(ProjectRuntimeTest.class);
- // suite.addTestSuite(JBIDE1657Test.class);
+ suite.addTestSuite(JBIDE1657Test.class);
return suite;
}
Added:
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/model/JBIDE1657Test.java
(rev 0)
+++
trunk/as/tests/org.jboss.ide.eclipse.as.test/src/org/jboss/ide/eclipse/as/test/model/JBIDE1657Test.java 2008-02-01
00:39:39 UTC (rev 6085)
@@ -0,0 +1,90 @@
+/**
+ * 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);
+ assertTrue("New classpath container path should return the same classpath entries
as the old. ",
+ resolved1.length == resolved2.length);
+ } catch( CoreException ce ) {
+ ce.printStackTrace();
+ fail(ce.getMessage());
+ }
+ }
+}