View | Details | Raw Unified | Return to bug 248466 | Differences between
and this patch

Collapse All | Expand All

(-)tests/org/eclipse/jdt/debug/tests/core/ClasspathProviderTests.java (+73 lines)
Lines 17-32 Link Here
17
import org.eclipse.core.resources.IProject;
17
import org.eclipse.core.resources.IProject;
18
import org.eclipse.core.resources.IResource;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.ResourcesPlugin;
19
import org.eclipse.core.resources.ResourcesPlugin;
20
import org.eclipse.core.runtime.IPath;
20
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.Path;
21
import org.eclipse.debug.core.ILaunchConfiguration;
22
import org.eclipse.debug.core.ILaunchConfiguration;
22
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
23
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
23
import org.eclipse.jdt.core.IJavaProject;
24
import org.eclipse.jdt.core.IJavaProject;
24
import org.eclipse.jdt.core.JavaCore;
25
import org.eclipse.jdt.core.JavaCore;
26
import org.eclipse.jdt.debug.testplugin.JavaProjectHelper;
25
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
27
import org.eclipse.jdt.debug.tests.AbstractDebugTest;
26
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
28
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
27
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
29
import org.eclipse.jdt.launching.IRuntimeClasspathEntry;
28
import org.eclipse.jdt.launching.IRuntimeClasspathProvider;
30
import org.eclipse.jdt.launching.IRuntimeClasspathProvider;
29
import org.eclipse.jdt.launching.JavaRuntime;
31
import org.eclipse.jdt.launching.JavaRuntime;
32
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
30
33
31
/**
34
/**
32
 * Tests runtime classpath provider extension point
35
 * Tests runtime classpath provider extension point
Lines 494-497 Link Here
494
		assertTrue("Classpath is missing " + location, list.contains(location));
497
		assertTrue("Classpath is missing " + location, list.contains(location));
495
				
498
				
496
	}	
499
	}	
500
	
501
	/**
502
	 * Tests that a buildpath with a relative (../..) classpath entry will resolve properly.
503
	 * 
504
	 * @throws Exception
505
	 */
506
	public void testRelativeClasspathEntry() throws Exception {
507
        // create a project with a relative classpath entry
508
        IProject pro = ResourcesPlugin.getWorkspace().getRoot().getProject("RelativeCP");
509
        assertFalse("Project should not exist", pro.exists());
510
511
        // create project with source folder and output location
512
        IJavaProject project = JavaProjectHelper.createJavaProject("RelativeCP");
513
        JavaProjectHelper.addSourceContainer(project, "src", "bin");
514
        IExecutionEnvironment j2se14 = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment("J2SE-1.4");
515
        assertNotNull("Missing J2SE-1.4 environment", j2se14);
516
        IPath path = JavaRuntime.newJREContainerPath(j2se14);
517
        JavaProjectHelper.addContainerEntry(project, path);
518
        // add relative entry - point to A.jar in DebugTests/src
519
        JavaProjectHelper.addLibrary(project, new Path("../DebugTests/src/A.jar"));
520
     
521
        // test runtime class path resolution
522
        String[] entries = JavaRuntime.computeDefaultRuntimeClassPath(project);
523
        String jarPath = getJavaProject().getProject().getLocation().append("src").append("A.jar").toOSString();
524
        List list = new ArrayList();
525
		for (int i = 0; i < entries.length; i++) {
526
			list.add(entries[i]);
527
		}
528
        
529
        // delete the project
530
        pro.delete(false, null);
531
        
532
        assertTrue("Classpath is missing " + jarPath, list.contains(jarPath));
533
	}
534
	
535
	/**
536
	 * Tests that a variable with a relative (../..) path will resolve properly.
537
	 * 
538
	 * @throws Exception
539
	 */
540
	public void testVariableWithRelativePath() throws Exception {
541
        // create a project with a relative classpath entry
542
        IProject pro = ResourcesPlugin.getWorkspace().getRoot().getProject("RelativeVar");
543
        assertFalse("Project should not exist", pro.exists());
544
545
        // create project with source folder and output location
546
        IJavaProject project = JavaProjectHelper.createJavaProject("RelativeVar");
547
        JavaProjectHelper.addSourceContainer(project, "src", "bin");
548
        IExecutionEnvironment j2se14 = JavaRuntime.getExecutionEnvironmentsManager().getEnvironment("J2SE-1.4");
549
        assertNotNull("Missing J2SE-1.4 environment", j2se14);
550
        IPath path = JavaRuntime.newJREContainerPath(j2se14);
551
        JavaProjectHelper.addContainerEntry(project, path);
552
        // add relative entry - point to A.jar in DebugTests/src
553
        String varName = "RELATIVE_DEBUG_TESTS";
554
		JavaCore.setClasspathVariable(varName, new Path("../DebugTests"), null);        
555
		JavaProjectHelper.addVariableEntry(project, new Path("RELATIVE_DEBUG_TESTS/src/A.jar"), null, null);
556
     
557
        // test runtime class path resolution
558
        String[] entries = JavaRuntime.computeDefaultRuntimeClassPath(project);
559
        String jarPath = getJavaProject().getProject().getLocation().append("src").append("A.jar").toOSString();
560
        List list = new ArrayList();
561
		for (int i = 0; i < entries.length; i++) {
562
			list.add(entries[i]);
563
		}
564
        
565
        // delete the project
566
        pro.delete(false, null);
567
        
568
        assertTrue("Classpath is missing " + jarPath, list.contains(jarPath));
569
	}	
497
}
570
}

Return to bug 248466