-
-
Notifications
You must be signed in to change notification settings - Fork 939
Expand file tree
/
Copy pathJarCacheTest.java
More file actions
41 lines (32 loc) · 1.26 KB
/
JarCacheTest.java
File metadata and controls
41 lines (32 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package org.jruby.util;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.net.URL;
import static java.util.concurrent.TimeUnit.*;
import static org.awaitility.Awaitility.waitAtMost;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
public class JarCacheTest {
private JarCache jarCache ;
@Before
public void setUp() throws Exception {
this.jarCache = new JarCache();
}
/**
* Verifies that updating a JAR (i.e. change of last modification time) is recognized by the {@link JarCache} after at most 1s.
*/
@Test
public void updateJar() {
URL resource = Thread.currentThread().getContextClassLoader().getResource("foobar.jar");
File jarFile = new File(resource.getFile());
jarFile.setLastModified(System.currentTimeMillis() - MINUTES.toMillis(2));
JarCache.JarIndex index = jarCache.getIndex(resource.getFile());
assertNotNull(index);
jarFile.setLastModified(System.currentTimeMillis() - MINUTES.toMillis(1));
waitAtMost(1, SECONDS).untilAsserted(() -> {
JarCache.JarIndex updatedIndex = jarCache.getIndex(resource.getFile());
assertNotSame(index, updatedIndex);
});
}
}