Skip to content

Commit

Permalink
[JENKINS-38696] - PrefetchingTest should disable JAR caching by defau…
Browse files Browse the repository at this point in the history
…lt in Windows
  • Loading branch information
oleg-nenashev committed Jul 7, 2017
1 parent 35c651a commit 40fa6a1
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/test/java/hudson/remoting/PrefetchingTest.java
Expand Up @@ -28,11 +28,19 @@ public class PrefetchingTest extends RmiTestBase implements Serializable {

// checksum of the jar files to force loading
private Checksum sum1,sum2;

// TODO: Rework to Rule once RmiTestBase is updated to JUnit 4/5
private boolean oldCachingValue;

@Override
protected void setUp() throws Exception {
super.setUp();

oldCachingValue = ResourceImageInJar.DISABLE_FILE_CACHING_IN_JAR_CONNECTION;
if (Launcher.isWindows()) {
// On Windows the test relies on the file locks cleanup when removing the temporary directory
ResourceImageInJar.DISABLE_FILE_CACHING_IN_JAR_CONNECTION = true;
}

URL jar1 = getClass().getClassLoader().getResource("remoting-test-client.jar");
URL jar2 = getClass().getClassLoader().getResource("remoting-test-client-tests.jar");

Expand Down Expand Up @@ -65,20 +73,17 @@ private File toFile(URL url) {

@Override
protected void tearDown() throws Exception {
ResourceImageInJar.DISABLE_FILE_CACHING_IN_JAR_CONNECTION = oldCachingValue;
cl.cleanup();
super.tearDown();

// because the dir is used by FIleSystemJarCache to asynchronously load stuff
// we might fail to shut it down right away
for (int i=0; ; i++) {
try {
FileUtils.deleteDirectory(dir);
return;
} catch (IOException e) {
if (i==3) throw e;
Thread.sleep(1000);
}
// TODO: Add to RMI base?
if (Boolean.getBoolean("remoting.test.interactive")) {

}

// Clenup the temporary cache and ensure we have no locked files left
FileUtils.deleteDirectory(dir);
}

/**
Expand Down

0 comments on commit 40fa6a1

Please sign in to comment.