Skip to content

Commit b59c79f

Browse files
DATAREDIS-452 - Polishing.
Fix indentation and organized imports. Original Pull Request: spring-projects#165
1 parent be40b08 commit b59c79f

File tree

1 file changed

+25
-29
lines changed

1 file changed

+25
-29
lines changed

src/test/java/org/springframework/data/redis/cache/RedisCacheTest.java

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
package org.springframework.data.redis.cache;
1818

19-
import static org.hamcrest.core.Is.is;
19+
import static edu.umd.cs.mtc.TestFramework.*;
2020
import static org.hamcrest.core.IsEqual.*;
2121
import static org.hamcrest.core.IsInstanceOf.*;
2222
import static org.hamcrest.core.IsNot.*;
@@ -32,9 +32,6 @@
3232
import java.util.concurrent.TimeUnit;
3333
import java.util.concurrent.atomic.AtomicBoolean;
3434

35-
import edu.umd.cs.mtc.MultithreadedTestCase;
36-
import edu.umd.cs.mtc.TestFramework;
37-
import org.hamcrest.core.IsEqual;
3835
import org.junit.AfterClass;
3936
import org.junit.Before;
4037
import org.junit.Test;
@@ -49,6 +46,8 @@
4946
import org.springframework.data.redis.core.AbstractOperationsTestParams;
5047
import org.springframework.data.redis.core.RedisTemplate;
5148

49+
import edu.umd.cs.mtc.MultithreadedTestCase;
50+
5251
/**
5352
* @author Costin Leau
5453
* @author Jennifer Hickey
@@ -292,58 +291,55 @@ public void testCacheGetSynchronized() throws Throwable {
292291
assumeThat(cache, instanceOf(RedisCache.class));
293292
assumeThat(valueFactory, instanceOf(StringObjectFactory.class));
294293

295-
TestFramework.runOnce(new CacheGetWithValueLoaderIsThreadSafe((RedisCache) cache));
294+
runOnce(new CacheGetWithValueLoaderIsThreadSafe((RedisCache) cache));
296295
}
297296

298-
static class CacheGetWithValueLoaderIsThreadSafe extends MultithreadedTestCase {
297+
@SuppressWarnings("unused")
298+
private static class CacheGetWithValueLoaderIsThreadSafe extends MultithreadedTestCase {
299299

300300
RedisCache redisCache;
301301
TestCacheLoader<String> cacheLoader;
302302

303303
public CacheGetWithValueLoaderIsThreadSafe(RedisCache redisCache) {
304+
304305
this.redisCache = redisCache;
305306

306-
cacheLoader = new TestCacheLoader<String>("test"){
307+
cacheLoader = new TestCacheLoader<String>("test") {
307308

308309
@Override
309310
public String call() throws Exception {
311+
310312
waitForTick(2);
311313
return super.call();
312314
}
313315
};
314316
}
315317

316-
public void thread1(){
317-
assertTick(0);
318-
Thread.currentThread().setName(getClass().getSimpleName() + " Cache Loader Thread");
319-
320-
String result = redisCache.get("key", cacheLoader);
318+
public void thread1() {
321319

322-
assertThat(result, is("test"));
320+
assertTick(0);
321+
assertThat(redisCache.get("key", cacheLoader), equalTo("test"));
323322
}
324323

325-
public void thread2(){
326-
waitForTick(1);
327-
Thread.currentThread().setName(getClass().getSimpleName() + " Cache Reader Thread");
328-
329-
String result = redisCache.get("key", new TestCacheLoader<String>("illegal value"));
324+
public void thread2() {
330325

331-
assertThat(result, is("test"));
326+
waitForTick(1);
327+
assertThat(redisCache.get("key", new TestCacheLoader<String>("illegal value")), equalTo("test"));
332328
assertTick(2);
333329
}
334330
}
335331

336-
protected static class TestCacheLoader<T> implements Callable<T> {
332+
private static class TestCacheLoader<T> implements Callable<T> {
337333

338-
private final T value;
334+
private final T value;
339335

340-
public TestCacheLoader(T value) {
341-
this.value = value;
342-
}
336+
public TestCacheLoader(T value) {
337+
this.value = value;
338+
}
343339

344-
@Override
345-
public T call() throws Exception {
346-
return value;
347-
}
348-
}
340+
@Override
341+
public T call() throws Exception {
342+
return value;
343+
}
344+
}
349345
}

0 commit comments

Comments
 (0)