Skip to main content

interview classPath entries w/ spaces

5 replies [Last post]
bernhasc
Offline
Joined: 2008-11-11

Using JUnit tests -- 1st off, I've figured out a sol'n that'd allow the Interview classPath settings to take affect when running JUnit tests. I'm using a slight variant of SimpleInterviewParameters. The otherVM adds a main class to wrap and capture Junit output. that's working great. The problem is in class path specification w/in the interview process. I wish to enter build/test/classes and build/classes; however, the interview process fills in the fully qualified name. To us unix users who never use spaces in directory or file names, this is ok. Windows, on the other hand LOVES spaces, for some reason. Those 2 directory names are getting expanded to:

C:\Documents and Settings\bernhasc.CCT\Projects\NetBeans\dsf\utility\build\test\classes
C:\Documents and Settings\bernhasc.CCT\Projects\NetBeans\dsf\utility\build\classes

This results in class not found exception: and. Manual edit of the JTI file replacing these 2 w/ relative paths (build/test/classes and build/classes), removing the CHECKSUM line, editing the configuration thru the gui and only clicking DONE solves the problem.

Is there a way to specify relative paths in the interview? If not, how do I go about getting those dirnames changed to their shorthand names (or somehow properly escape the spaces). Will executing a cpFiles[i].replace("Documents and Settings", "Docume~1") work?

Message was edited by: bernhasc

Message was edited by: bernhasc

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bkurotsu
Offline
Joined: 2004-12-13

Have you tried using the relative mode API present in the FileQuestion and FileListQuestion to get the result that you want?

As for spaces in filenames, yes, it is a serious problem. I haven't played with it recently on Windows, but perhaps the getCanonical() or getAbsolute() methods in the File API would help? I don't think that doing string substitution is a good general solution.

bernhasc
Offline
Joined: 2008-11-11

Yea, String subst is a *bad* idea. I'll give those others a shot.

bernhasc
Offline
Joined: 2008-11-11

Both get[Absolute|Canonical]Path() return strings w/ spaces. I ended up going here for a quick-fix.
   http://java.ittoolbox.com/code/archives.asp?d=2810&a=s&i=8

bernhasc
Offline
Joined: 2008-11-11

Even better solution.... This should work for all cases, for all platforms. I surrounded the generated classpath statement in single quotes. So far, the test works under Windows2000 and RHESv4.

SVN diff follows:

% svn diff SimpleInterviewParameters.java
Index: SimpleInterviewParameters.java
===================================================================
--- SimpleInterviewParameters.java (revision 1177)
+++ SimpleInterviewParameters.java (working copy)

@@ -224,12 +224,13 @@
  sb.append(jvm == null ? "unknown_jvm" : jvm.getPath());
  File[] cpFiles = qClassPath.getValue();
  if (cpFiles != null && cpFiles.length > 0) {
-    sb.append(" -classpath ");
+    sb.append(" -classpath \'");
      for (int i = 0; i < cpFiles.length; i++) {
         if (i > 0)
            sb.append(File.pathSeparator);
         sb.append(cpFiles[i]);
     }
+    sb.append("\'");
  }
  sb.append(" $testExecuteClass $testExecuteArgs");
  return sb.toString();

Message was edited by: bernhasc

bernhasc
Offline
Joined: 2008-11-11

/bump

I'll post a diff of my Interview class that allows me to run JUnit tests using the Interview classpath instead of the JTT classpath as soon as I find the right copy of my code :)