Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 385223

Summary: JUnit Test shows other results if project root directory contains space characters
Product: [Eclipse Project] JDT Reporter: Björn Schmidt <bs-devl>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3    
Version: 4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description Björn Schmidt CLA 2012-07-16 14:19:01 EDT
Build Identifier: Version: Juno Release Build id: 20120614-1722

In a test that could but must not fail, I run in a behavior where the count of the occurrence of errors differs much from another test with a project that is equals to the first one (configuration/source/jdk/compliance/lib/maven aso.). The only things that were changed are artifactId- and name-Tag in the pom and the project base directory. First project has no spaces, second has one space in the directory.
To do such a test I made a class on Windows 7 that writes and deletes files. Depends on the underlying OS (windows), it can happend that the test fails with an expected AssertionError in FileUtilsTest.testDeletDir due to open file handlers. Mostly the handler are closed and the test passed. 
The class looks like that:

public class FileUtils {
   public static boolean delete(File file) throws Exception {
      return file.delete();
   }
   public static void write(File file, String content) throws Exception {
      FileOutputStream fw = null;
      try {
         fw = new FileOutputStream(file);
         fw.write(content.getBytes());
         fw.flush();
         fw.close();
      } finally {
         if (fw != null) {
            fw.close();
         }
      }
   }
}

I test it with a JUnit class shown below.

public class FileUtilsTest{
   private static final String FILENAME = "src/test/resources/file_utils_test.txt";

   @Test
   public void testWriteFile() throws Exception {
      FileUtils.write(new File(FILENAME), "abc"+System.getProperty("line.separator")+"123");
   }

   @Test
   public void testDeleteFile() throws Exception{
      assertTrue(FileUtils.delete(new File(FILENAME)));
   }
}

Im not sure, if this also happends with other OS like linux. The Test above will not work on such an OS.
I am using Eclipse with jdk1.7.0_03 and m2e with maven 3.0.4


Reproducible: Always

Steps to Reproduce:
1. Creates a project "test" and a project "test 2" with the classes I posted. So it look like that:
C:\test
C:\test\src
aso.
C:\test 2
C:\test 2\src
aso.

2. Execute the JUnit test of FileUtilsTest in project "test" with "Run as -> JUnit Test" and hit the "Rerun Test" in the JUnit window again and again. The test will failed at the ratio of 1:5 (the value depends on your enviroment, I think, and can be something else)
3. Execute the JUnit test in project "test 2" in the same way. The ratio will be conspicuously other than doing it in project "test".
Comment 1 Eclipse Genie CLA 2018-10-07 14:47:30 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.