Author: scabanovich
Date: 2008-02-22 06:35:02 -0500 (Fri, 22 Feb 2008)
New Revision: 6526
Added:
trunk/common/tests/org.jboss.tools.common.model.test/projects/
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/.classpath
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/.project
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/lib/
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/lib/a.jar
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/src/
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/.classpath
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/.project
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/lib/
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/lib/b.jar
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/src/
trunk/common/tests/org.jboss.tools.common.model.test/projects/c.jar
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/ClassPathTest.java
Modified:
trunk/common/tests/org.jboss.tools.common.model.test/META-INF/MANIFEST.MF
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java
Log:
JBIDE-1811
Modified: trunk/common/tests/org.jboss.tools.common.model.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/META-INF/MANIFEST.MF 2008-02-22
11:24:36 UTC (rev 6525)
+++ trunk/common/tests/org.jboss.tools.common.model.test/META-INF/MANIFEST.MF 2008-02-22
11:35:02 UTC (rev 6526)
@@ -12,5 +12,6 @@
org.eclipse.core.resources,
org.jboss.tools.common.model,
org.jboss.tools.common.test,
+ org.jboss.tools.tests,
org.jboss.tools.common.model.ui
Provide-Package: org.jboss.tools.common.model.test
Added: trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/.classpath
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/.classpath
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/.classpath 2008-02-22
11:35:02 UTC (rev 6526)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/a.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/.project
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/.project
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/.project 2008-02-22
11:35:02 UTC (rev 6526)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Test1</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/lib/a.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test1/lib/a.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/.classpath
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/.classpath
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/.classpath 2008-02-22
11:35:02 UTC (rev 6526)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="lib/b.jar"/>
+ <classpathentry kind="lib" path="/Test1/lib/a.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/.project
===================================================================
--- trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/.project
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/.project 2008-02-22
11:35:02 UTC (rev 6526)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>Test2</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/lib/b.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/common/tests/org.jboss.tools.common.model.test/projects/Test2/lib/b.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/common/tests/org.jboss.tools.common.model.test/projects/c.jar
===================================================================
(Binary files differ)
Property changes on: trunk/common/tests/org.jboss.tools.common.model.test/projects/c.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added:
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/ClassPathTest.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/ClassPathTest.java
(rev 0)
+++
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/ClassPathTest.java 2008-02-22
11:35:02 UTC (rev 6526)
@@ -0,0 +1,95 @@
+package org.jboss.tools.common.model.test;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.test.util.TestProjectProvider;
+import org.jboss.tools.test.util.xpl.EditorTestHelper;
+import org.osgi.framework.Bundle;
+
+import junit.framework.TestCase;
+
+public class ClassPathTest extends TestCase {
+ static String BUNDLE_NAME = "org.jboss.tools.common.model.test";
+ TestProjectProvider provider1 = null;
+ IProject project1 = null;
+ TestProjectProvider provider2 = null;
+ IProject project2 = null;
+
+ public ClassPathTest() {}
+
+ public void setUp() throws Exception {
+ provider1 = new TestProjectProvider(BUNDLE_NAME, null, "Test1", true);
+ project1 = provider1.getProject();
+
+ provider2 = new TestProjectProvider(BUNDLE_NAME, null, "Test2", true);
+ project2 = provider2.getProject();
+
+ project1.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ project2.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+
+ EditorTestHelper.joinBackgroundActivities();
+
+ IJavaProject jp = JavaCore.create(project2);
+ IClasspathEntry[] es = jp.getRawClasspath();
+
+ String location = getLocation("projects/c.jar");
+ assertTrue("Cannot find file " + location, new File(location).isFile());
+
+ IPath path = new Path(location);
+ IClasspathEntry e = JavaCore.newLibraryEntry(path, null, null);
+
+ IClasspathEntry[] esn = new IClasspathEntry[es.length + 1];
+ System.arraycopy(es, 0, esn, 0, es.length);
+ esn[es.length] = e;
+
+ jp.setRawClasspath(esn, new NullProgressMonitor());
+
+ EditorTestHelper.joinBackgroundActivities();
+ }
+
+ public void testGetClassPath() throws CoreException, IOException {
+ List<String> list = EclipseResourceUtil.getClassPath(project2);
+
+ String[] testNames = {
+ "/Test2/lib/b.jar",
+ "/Test1/lib/a.jar",
+ "projects/c.jar"
+ };
+ for (int i = 0; i < testNames.length; i++) {
+ assertTrue("Cannot find classpath entry " + testNames[i], contains(list,
testNames[i]));
+ }
+
+ }
+
+ private String getLocation(String relativeInBundle) throws IOException {
+ Bundle bundle = Platform.getBundle(BUNDLE_NAME);
+ URL url = FileLocator.resolve(bundle.getEntry(relativeInBundle));
+ String location = url.getFile();
+ return location;
+ }
+
+ private boolean contains(List<String> list, String name) {
+ for (String s: list) {
+ if(s.replace('\\', '/').endsWith(name.replace('\\',
'/'))) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
Modified:
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java
===================================================================
---
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java 2008-02-22
11:24:36 UTC (rev 6525)
+++
trunk/common/tests/org.jboss.tools.common.model.test/src/org/jboss/tools/common/model/test/CommonModelAllTests.java 2008-02-22
11:35:02 UTC (rev 6526)
@@ -23,6 +23,7 @@
TestSuite suite = new TestSuite();
suite.setName("All tests for " + PLUGIN_ID);
suite.addTestSuite(MetaModelTest.class);
+ suite.addTestSuite(ClassPathTest.class);
return suite;
}
}
Show replies by date