Skip to content

Commit

Permalink
Replace org.eclipse.core.runtime.Path by IPath
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Nov 18, 2023
1 parent a129b55 commit 056b30e
Show file tree
Hide file tree
Showing 12 changed files with 124 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
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.IAccessRule;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathContainer;
Expand Down Expand Up @@ -90,6 +89,7 @@
public class BuildPathManagerTest extends AbstractMavenProjectTestCase {

private ProjectRegistryManager manager;

private boolean initialDownloadSources;

@Override
Expand Down Expand Up @@ -265,16 +265,16 @@ public void testProjectImport001_useMavenOutputFolders() throws Exception {
IJavaProject javaProject = JavaCore.create(project);

String outputPath = "/projectimport-p001/target/classes";
assertEquals(new Path(outputPath), javaProject.getOutputLocation());
assertEquals(IPath.fromOSString(outputPath), javaProject.getOutputLocation());

String srcMain = "/projectimport-p001/src/main/java";
String srcTest = "/projectimport-p001/src/test/java";
Map<String, IClasspathEntry> map = ClasspathHelpers.assertClasspath(project, srcMain, srcTest);
IClasspathEntry cp0 = map.get(srcMain);
IClasspathEntry cp1 = map.get(srcTest);

assertEquals(new Path(outputPath), cp0.getOutputLocation());
assertEquals(new Path("/projectimport-p001/target/test-classes"), cp1.getOutputLocation());
assertEquals(IPath.fromOSString(outputPath), cp0.getOutputLocation());
assertEquals(IPath.fromOSString("/projectimport-p001/target/test-classes"), cp1.getOutputLocation());
}

// disabled nested modules tests
Expand All @@ -290,12 +290,12 @@ public void _testProjectImport002_useMavenOutputFolders() throws Exception {

IJavaProject javaProject = JavaCore.create(project);

assertEquals(new Path("/projectimport-p002/target/classes"), javaProject.getOutputLocation());
assertEquals(IPath.fromOSString("/projectimport-p002/target/classes"), javaProject.getOutputLocation());
IClasspathEntry[] cp = javaProject.getRawClasspath();

assertEquals(3, cp.length);
assertEquals(new Path("/projectimport-p002/p002-m1/src/main/java"), cp[0].getPath());
assertEquals(new Path("/projectimport-p002/p002-m1/target/classes"), cp[0].getOutputLocation());
assertEquals(IPath.fromOSString("/projectimport-p002/p002-m1/src/main/java"), cp[0].getPath());
assertEquals(IPath.fromOSString("/projectimport-p002/p002-m1/target/classes"), cp[0].getOutputLocation());
}

@Test
Expand All @@ -319,7 +319,7 @@ public void testClasspathOrderWorkspace001() throws Exception {

// order according to mvn -X
assertEquals(4, cp.length);
assertEquals(new Path("/p2"), cp[0].getPath());
assertEquals(IPath.fromOSString("/p2"), cp[0].getPath());
assertEquals("junit-4.13.1.jar", cp[2].getPath().lastSegment());
assertEquals("easymock-1.0.jar", cp[1].getPath().lastSegment());

Expand Down Expand Up @@ -449,8 +449,8 @@ public void testDownloadSources_001_sourceAttachment() throws Exception {

IPath entryPath = getClasspathEntries(project)[0].getPath();

IPath srcPath = new Path("/a");
IPath srcRoot = new Path("/b");
IPath srcPath = IPath.fromOSString("/a");
IPath srcRoot = IPath.fromOSString("/b");
String javaDocUrl = "c";

IClasspathAttribute attribute = JavaCore.newClasspathAttribute(IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
Expand Down Expand Up @@ -1066,14 +1066,14 @@ public void testSimpleProjectInExternalLocation() throws CoreException, IOExcept
tmp.delete(); //deleting a tmp file so we can use the name for a folder

final String projectName1 = "external-simple-project-1";
createSimpleProject(projectName1, new Path(tmp.getAbsolutePath()).append(projectName1));
createSimpleProject(projectName1, IPath.fromOSString(tmp.getAbsolutePath()).append(projectName1));

final String projectName2 = "external-simple-project-2";
File existingFolder = new File(tmp, projectName2);
existingFolder.mkdirs();
new File(existingFolder, IMavenConstants.POM_FILE_NAME).createNewFile();
try {
createSimpleProject(projectName2, new Path(tmp.getAbsolutePath()).append(projectName2));
createSimpleProject(projectName2, IPath.fromOSString(tmp.getAbsolutePath()).append(projectName2));
fail("Project creation should fail if the POM exists in the target folder");
} catch(CoreException e) {
final String msg = IMavenConstants.POM_FILE_NAME + " already exists";
Expand Down Expand Up @@ -1108,7 +1108,7 @@ public void testArchetypeProjectInExternalLocation() throws CoreException, IOExc
tmp.delete(); //deleting a tmp file so we can use the name for a folder

final String projectName1 = "external-archetype-project-1";
IProject project1 = createArchetypeProject(projectName1, new Path(tmp.getAbsolutePath()).append(projectName1),
IProject project1 = createArchetypeProject(projectName1, IPath.fromOSString(tmp.getAbsolutePath()).append(projectName1),
quickStart);
assertNotNull(JavaCore.create(project1)); // TODO more meaningful assertion

Expand All @@ -1117,7 +1117,7 @@ public void testArchetypeProjectInExternalLocation() throws CoreException, IOExc
existingFolder.mkdirs();
new File(existingFolder, IMavenConstants.POM_FILE_NAME).createNewFile();
try {
createArchetypeProject(projectName2, new Path(tmp.getAbsolutePath()).append(projectName2), quickStart);
createArchetypeProject(projectName2, IPath.fromOSString(tmp.getAbsolutePath()).append(projectName2), quickStart);
fail("Project creation should fail if the POM exists in the target folder");
} catch(CoreException e) {
// this is supposed to happen
Expand Down Expand Up @@ -1178,20 +1178,20 @@ public void testMNGECLIPSE_696_compiler_includes_excludes() throws Exception {

final IPath[] inclusionsMain = cpMain.getInclusionPatterns();
assertEquals(2, inclusionsMain.length);
assertEquals(new Path("org/apache/maven/"), inclusionsMain[0]);
assertEquals(new Path("org/maven/ide/eclipse/"), inclusionsMain[1]);
assertEquals(IPath.fromOSString("org/apache/maven/"), inclusionsMain[0]);
assertEquals(IPath.fromOSString("org/maven/ide/eclipse/"), inclusionsMain[1]);

final IPath[] exclusionsMain = cpMain.getExclusionPatterns();
assertEquals(1, exclusionsMain.length);
assertEquals(new Path("org/maven/ide/eclipse/tests/"), exclusionsMain[0]);
assertEquals(IPath.fromOSString("org/maven/ide/eclipse/tests/"), exclusionsMain[0]);

final IPath[] inclusionsTest = cpTest.getInclusionPatterns();
assertEquals(1, inclusionsTest.length);
assertEquals(new Path("org/apache/maven/tests/"), inclusionsTest[0]);
assertEquals(IPath.fromOSString("org/apache/maven/tests/"), inclusionsTest[0]);

final IPath[] exclusionsTest = cpTest.getExclusionPatterns();
assertEquals(1, exclusionsTest.length);
assertEquals(new Path("org/apache/maven/tests/Excluded.java"), exclusionsTest[0]);
assertEquals(IPath.fromOSString("org/apache/maven/tests/Excluded.java"), exclusionsTest[0]);
}

@Test
Expand Down
Loading

0 comments on commit 056b30e

Please sign in to comment.