(no commit message)
[utils] / support / general / src / test / java / org / wamblee / cache / CachedObjectTest.java
index 02d151cbd9126c75708d1c3c33d8583d6ac3970a..da7d8d47bcf6e4b9301475400f07d2e4e52fe147 100644 (file)
@@ -58,10 +58,10 @@ public class CachedObjectTest extends TestCase {
         computation = mock(CachedObject.Computation.class);
         when(computation.getObject(anyInt())).thenAnswer(new Answer<Integer>() {
             public Integer answer(
-                org.mockito.invocation.InvocationOnMock invocation)
+                org.mockito.invocation.InvocationOnMock aInvocation)
                 throws Throwable {
                 ncomputations++;
-                return compute((Integer) invocation.getArguments()[0]);
+                return compute((Integer) aInvocation.getArguments()[0]);
             }
         });
         ncomputations = 0;
@@ -192,8 +192,8 @@ public class CachedObjectTest extends TestCase {
         assertEquals(101, getComputationCount());
     }
 
-    public void testPreviousValueWhileComputationBeingDone() throws Exception { 
-        final CachedObject<Integer,Integer> cached = createCached(new ZeroCache<Integer, Integer>());
+    public void testPreviousValueWhileComputationBeingDone() throws Exception {
+        final CachedObject<Integer, Integer> cached = createCached(new ZeroCache<Integer, Integer>());
         reset(computation);
         when(computation.getObject(anyInt())).thenReturn(1).thenAnswer(
             new Answer<Integer>() {
@@ -203,40 +203,43 @@ public class CachedObjectTest extends TestCase {
                     TimingUtils.sleep(1000);
                     return 2;
                 }
-            }
-            ).thenReturn(3);
-        
+            }).thenReturn(3);
+
         assertEquals(1, cached.get().intValue());
         Thread recompute = new Thread(new Runnable() {
-            
+
             @Override
             public void run() {
-                // will sleep for 1 second. 
+                // will sleep for 1 second.
                 assertEquals(2, cached.get().intValue());
             }
         });
         recompute.start();
-        // Now asking the value should not recompute but should return the old value.
+        // Now asking the value should not recompute but should return the old
+        // value.
         TimingUtils.sleep(500);
         assertEquals(1, cached.get().intValue());
         recompute.join();
     }
-    
-    public void testNullValueWhenComputationReturnsNull() throws Exception { 
-        final CachedObject<Integer,Integer> cached = createCached(new ZeroCache<Integer, Integer>());
+
+    public void testNullValueWhenComputationReturnsNull() throws Exception {
+        final CachedObject<Integer, Integer> cached = createCached(new ZeroCache<Integer, Integer>());
         reset(computation);
-        when(computation.getObject(anyInt())).thenReturn(1).thenReturn(null).thenReturn(2);
-        
+        when(computation.getObject(anyInt())).thenReturn(1).thenReturn(null)
+            .thenReturn(2);
+
         assertEquals(1, cached.get().intValue());
         assertNull(cached.get());
         assertEquals(2, cached.get().intValue());
     }
-    
-    public void testPreviousValueWhenComputationThrowsException() throws Exception { 
-        final CachedObject<Integer,Integer> cached = createCached(new ZeroCache<Integer, Integer>());
+
+    public void testPreviousValueWhenComputationThrowsException()
+        throws Exception {
+        final CachedObject<Integer, Integer> cached = createCached(new ZeroCache<Integer, Integer>());
         reset(computation);
-        when(computation.getObject(anyInt())).thenReturn(1).thenThrow(new RuntimeException()).thenReturn(2);
-        
+        when(computation.getObject(anyInt())).thenReturn(1).thenThrow(
+            new RuntimeException()).thenReturn(2);
+
         assertEquals(1, cached.get().intValue());
         assertEquals(1, cached.get().intValue());
         assertEquals(2, cached.get().intValue());