Bug 76318 - [tests] Cannot run ASTModelBridgeTests if workspace path segment count is 1
Summary: [tests] Cannot run ASTModelBridgeTests if workspace path segment count is 1
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-14 17:19 EDT by Olivier Thomann CLA
Modified: 2004-12-15 06:28 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2004-10-14 17:19:30 EDT
Try to run the ASTModelBridgeTests setting the location of the workspace in c:\temp.
Two tests will fail. We need to check if the EXTERNAL_JAR_DIR_PATH ends with
File.separator. This would fix one test.
We need this:
	protected String getExternalJCLPathString() {
		if (EXTERNAL_JAR_DIR_PATH.endsWith(File.separator)) {
			return EXTERNAL_JAR_DIR_PATH + "jclMin.jar";
		} else {
			return EXTERNAL_JAR_DIR_PATH + File.separator + "jclMin.jar";
		}
	}

and:
	/**
	 * Returns the java.io path to the source of the external java class library
(e.g. jclMinsrc.zip)
	 */
	protected String getExternalJCLSourcePathString() {
		if (EXTERNAL_JAR_DIR_PATH.endsWith(File.separator)) {
			return EXTERNAL_JAR_DIR_PATH + "jclMinsrc.zip";
		} else {
			return EXTERNAL_JAR_DIR_PATH + File.separator + "jclMinsrc.zip";
		}
	}

and:

	public String getSourceWorkspacePath() {
		if (getPluginDirectoryPath().endsWith(File.separator)) {
			return getPluginDirectoryPath() +  "workspace";
		} else {
			return getPluginDirectoryPath() +  File.separator + "workspace";
		}
	}

These three methods are in AbstractJavaModelTests.

Once this is done, the test testModelTopLevelType3 is still failing because
jclMin.jar is not found as an external package fragment root. It seems to be
located in the project root path.
See JavaProject#public IPackageFragmentRoot getPackageFragmentRoot(IPath path)
in the case the segment count is 1.

I changed it to:
			case 1:
				// default root
				if
(org.eclipse.jdt.internal.compiler.util.Util.isArchiveFileName(path.lastSegment()))
{
					IResource resource = this.project.getWorkspace().getRoot().findMember(path); 
					if (resource != null && resource.getType() == IResource.FOLDER){
						return getPackageFragmentRoot(resource);
					}
					return getPackageFragmentRoot0(path);
				} else {
					return getPackageFragmentRoot(this.project);
				}

but it is not quite right. I still have problems with the File.separator.
Comment 1 Jerome Lanneluc CLA 2004-11-30 11:01:18 EST
Changed EXTERNAL_JAR_DIR_PATH to always end with a File.separatorChar.
Changed all its usages in the tests to not append a File.separatorChar.
Changed TypeBinding#getClassFile(char[]) to not convert the File.separatorChar
into a slash.
Changed ClasspathEntry#validateClasspath(...) and validateClasspathEntry(...) to
not assume that the path has at least one segment.

All Java model tests now pass if the workspace is at the root of the file system.
Comment 2 Frederic Fusier CLA 2004-12-15 06:28:56 EST
Implementation reviewed for 3.1 M4 using build I200412142000.