Skip to content

Commit 83b9c09

Browse files
committed
Fix for new tests so that they don't pollute other tests
1 parent 3123589 commit 83b9c09

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

biojava-core/src/main/java/org/biojava/nbio/core/util/InputStreamProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ public class InputStreamProvider {
6565

6666
private boolean cacheRawFiles ;
6767

68-
FlatFileCache cache ;
6968
public InputStreamProvider() {
7069
super();
7170
cacheRawFiles = false;
7271

7372
String prop = System.getProperty(CACHE_PROPERTY);
7473
if ( prop != null && prop.equals("true")) {
7574
cacheRawFiles = true;
76-
cache = FlatFileCache.getInstance();
75+
// init the singleton
76+
FlatFileCache.getInstance();
7777
}
7878

7979
}

biojava-structure/src/test/java/org/biojava/nbio/structure/TestDownloadChemCompProvider.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121
package org.biojava.nbio.structure;
2222

23+
import org.biojava.nbio.core.util.FlatFileCache;
2324
import org.biojava.nbio.structure.io.mmcif.DownloadChemCompProvider;
2425
import org.biojava.nbio.structure.io.mmcif.model.ChemComp;
2526
import org.junit.Test;
@@ -67,6 +68,10 @@ public void testRedirectWorks() {
6768
// just in case the we did get garbage, let's clean up
6869
file.delete();
6970

71+
// very important: we have a memory cache of files, we need to reset it not to pollute the cache for later tests
72+
FlatFileCache ffc = FlatFileCache.getInstance();
73+
ffc.clear();
74+
7075
assertNotNull(cc);
7176

7277
assertNotNull(cc.getName());
@@ -95,6 +100,10 @@ public void testWeDontCacheGarbage() {
95100

96101
file.delete();
97102

103+
// very important: we have a memory cache of files, we need to reset it not to pollute the cache for later tests
104+
FlatFileCache ffc = FlatFileCache.getInstance();
105+
ffc.clear();
106+
98107
// we couldn't parse, thus there should be no content
99108
assertNull(cc.getName());
100109

@@ -122,6 +131,10 @@ public void testIfWeCachedGarbageWeCanDetectIt() throws IOException {
122131

123132
file.delete();
124133

134+
// very important: we have a memory cache of files, we need to reset it not to pollute the cache for later tests
135+
FlatFileCache ffc = FlatFileCache.getInstance();
136+
ffc.clear();
137+
125138
assertNull(cc.getName());
126139

127140

0 commit comments

Comments
 (0)