56
56
import org .junit .Test ;
57
57
import org .junit .rules .ExpectedException ;
58
58
59
- public class LocalCacheTest {
59
+ public class LocalCacheStorageTest {
60
60
@ Rule public ExpectedException expectedException = ExpectedException .none ();
61
61
@ Rule public TemporaryPaths tempDir = new TemporaryPaths ();
62
62
@@ -113,7 +113,7 @@ public void setUp() {
113
113
assumeThat (Platform .detect (), not (Platform .WINDOWS ));
114
114
filesystem = FakeProjectFilesystem .createJavaOnlyFilesystem ("/" );
115
115
localHandler = new LocalHandler ();
116
- Logger .get (LocalCache .class ).addHandler (localHandler );
116
+ Logger .get (LocalCacheStorage .class ).addHandler (localHandler );
117
117
}
118
118
119
119
@ Test
@@ -122,13 +122,14 @@ public void createLocalCacheWithAbsolutePathAndException()
122
122
expectedException .expect (ParserCacheException .class );
123
123
expectedException .expectMessage ("Failed to create local cache directory - /foo/bar" );
124
124
filesystem .createNewFile (Paths .get ("/foo" ));
125
- LocalCache .newInstance (getParserCacheConfig (true , filesystem .getPath ("/foo/bar" )), filesystem );
125
+ LocalCacheStorage .newInstance (
126
+ getParserCacheConfig (true , filesystem .getPath ("/foo/bar" )), filesystem );
126
127
}
127
128
128
129
@ Test
129
130
public void createLocalCacheWithAbsolutePath () throws ParserCacheException {
130
131
Path absPath = filesystem .getBuckPaths ().getBuckOut ().resolve ("/foo/bar" ).toAbsolutePath ();
131
- LocalCache .newInstance (getParserCacheConfig (true , absPath ), filesystem );
132
+ LocalCacheStorage .newInstance (getParserCacheConfig (true , absPath ), filesystem );
132
133
List <LogRecord > events = localHandler .messages ;
133
134
assertEquals (1 , events .size ());
134
135
LogRecord event = events .get (0 );
@@ -139,7 +140,7 @@ public void createLocalCacheWithAbsolutePath() throws ParserCacheException {
139
140
@ Test
140
141
public void createLocalCacheWithRelativePath () throws ParserCacheException {
141
142
Path path = filesystem .getPath ("foo/bar" );
142
- LocalCache .newInstance (getParserCacheConfig (true , path ), filesystem );
143
+ LocalCacheStorage .newInstance (getParserCacheConfig (true , path ), filesystem );
143
144
List <LogRecord > events = localHandler .messages ;
144
145
assertEquals (1 , events .size ());
145
146
LogRecord event = events .get (0 );
@@ -153,15 +154,15 @@ public void createLocalCacheWithRelativePath() throws ParserCacheException {
153
154
public void createLocalCacheWhenCachingDisabled () throws ParserCacheException {
154
155
expectedException .expect (IllegalStateException .class );
155
156
expectedException .expectMessage (
156
- "Invalid state: LocalCache should not be instantiated if the cache is disabled." );
157
- LocalCache .newInstance (
157
+ "Invalid state: LocalCacheStorage should not be instantiated if the cache is disabled." );
158
+ LocalCacheStorage .newInstance (
158
159
getParserCacheConfig (false , filesystem .getPath (tempDir .getRoot ().toString ())), filesystem );
159
160
}
160
161
161
162
@ Test
162
163
public void createLocalCacheWhenCacheDefaultDirectory () throws ParserCacheException {
163
164
Path emptyPathForDefaultCacheLocation = filesystem .getPath ("\" \" " );
164
- LocalCache .newInstance (
165
+ LocalCacheStorage .newInstance (
165
166
getParserCacheConfig (true , emptyPathForDefaultCacheLocation ), filesystem );
166
167
List <LogRecord > events = localHandler .messages ;
167
168
assertEquals (1 , events .size ());
@@ -172,16 +173,16 @@ public void createLocalCacheWhenCacheDefaultDirectory() throws ParserCacheExcept
172
173
173
174
@ Test
174
175
public void createLocalCacheWFPDirectoryNonExisting () throws IOException , ParserCacheException {
175
- LocalCache localCache =
176
- LocalCache .newInstance (
176
+ LocalCacheStorage localCacheStorage =
177
+ LocalCacheStorage .newInstance (
177
178
getParserCacheConfig (
178
179
true ,
179
180
filesystem .getPath (tempDir .getRoot ().toString () + File .separator + FOO_BAR_PATH )),
180
181
filesystem );
181
182
Path buildPath = filesystem .getPath (FOO_BAR_PATH );
182
183
HashCode weakFingerprint = Fingerprinter .getWeakFingerprint (buildPath , getConfig ().getConfig ());
183
184
HashCode strongFingerprint = Fingerprinter .getStrongFingerprint (filesystem , ImmutableList .of ());
184
- localCache .storeBuildFileManifest (weakFingerprint , strongFingerprint , null );
185
+ localCacheStorage .storeBuildFileManifest (weakFingerprint , strongFingerprint , null );
185
186
Path localCachePath = tempDir .getRoot ().resolve (FOO_BAR_PATH );
186
187
assertNotNull (localCachePath );
187
188
Path weakFingerprintPath =
@@ -193,8 +194,8 @@ public void createLocalCacheWFPDirectoryNonExisting() throws IOException, Parser
193
194
@ Test
194
195
public void createLocalCacheWFPDirectoryExistingAndKeepIt ()
195
196
throws IOException , ParserCacheException {
196
- LocalCache localCache =
197
- LocalCache .newInstance (
197
+ LocalCacheStorage localCacheStorage =
198
+ LocalCacheStorage .newInstance (
198
199
getParserCacheConfig (
199
200
true ,
200
201
filesystem .getPath (tempDir .getRoot ().toString () + File .separator + FOO_BAR_PATH )),
@@ -211,7 +212,7 @@ public void createLocalCacheWFPDirectoryExistingAndKeepIt()
211
212
assertTrue (filesystem .exists (newFilePath ));
212
213
HashCode weakFingerprint = Fingerprinter .getWeakFingerprint (buildPath , getConfig ().getConfig ());
213
214
HashCode strongFingerprint = Fingerprinter .getStrongFingerprint (filesystem , ImmutableList .of ());
214
- localCache .storeBuildFileManifest (weakFingerprint , strongFingerprint , null );
215
+ localCacheStorage .storeBuildFileManifest (weakFingerprint , strongFingerprint , null );
215
216
assertNotNull (localCachePath );
216
217
assertTrue (filesystem .exists (wfpPath ));
217
218
assertTrue (filesystem .exists (newFilePath ));
@@ -220,8 +221,8 @@ public void createLocalCacheWFPDirectoryExistingAndKeepIt()
220
221
@ Test
221
222
public void stroreInLocalCacheAndGetFromLocalCacheAndVerifyMatch ()
222
223
throws IOException , ParserCacheException {
223
- LocalCache localCache =
224
- LocalCache .newInstance (
224
+ LocalCacheStorage localCacheStorage =
225
+ LocalCacheStorage .newInstance (
225
226
getParserCacheConfig (
226
227
true ,
227
228
filesystem .getPath (tempDir .getRoot ().toString () + File .separator + FOO_BAR_PATH )),
@@ -295,7 +296,8 @@ public void stroreInLocalCacheAndGetFromLocalCacheAndVerifyMatch()
295
296
HashCode strongFingerprinter = Fingerprinter .getStrongFingerprint (filesystem , includes );
296
297
297
298
// Store in local cache
298
- localCache .storeBuildFileManifest (weakFingerprinter , strongFingerprinter , buildFileManifest );
299
+ localCacheStorage .storeBuildFileManifest (
300
+ weakFingerprinter , strongFingerprinter , buildFileManifest );
299
301
300
302
Path serializedDataFile =
301
303
localCachePath
@@ -305,7 +307,7 @@ public void stroreInLocalCacheAndGetFromLocalCacheAndVerifyMatch()
305
307
306
308
// Get from local cache
307
309
BuildFileManifest buildFileManifestResult =
308
- localCache .getBuildFileManifest (weakFingerprinter , strongFingerprinter );
310
+ localCacheStorage .getBuildFileManifest (weakFingerprinter , strongFingerprinter );
309
311
assertEquals (buildFileManifest , buildFileManifestResult );
310
312
}
311
313
0 commit comments