storm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ptgo...@apache.org
Subject [02/50] [abbrv] git commit: fix unit tests to match new behavior
Date Thu, 20 Mar 2014 21:22:25 GMT
fix unit tests to match new behavior


Project: http://git-wip-us.apache.org/repos/asf/incubator-storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-storm/commit/2aaada7f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-storm/tree/2aaada7f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-storm/diff/2aaada7f

Branch: refs/heads/master
Commit: 2aaada7ff0db344335642eabd0da52751a17717a
Parents: 78a0a99
Author: Mike Blume <mike@loggly.com>
Authored: Fri Feb 1 12:49:10 2013 -0800
Committer: Mike Blume <mike@loggly.com>
Committed: Fri Feb 1 12:49:55 2013 -0800

----------------------------------------------------------------------
 test/jvm/storm/starter/tools/SlidingWindowCounterTest.java | 6 +++++-
 test/jvm/storm/starter/tools/SlotBasedCounterTest.java     | 3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2aaada7f/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java
----------------------------------------------------------------------
diff --git a/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java b/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java
index 2e8fb26..7361ac8 100644
--- a/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java
+++ b/test/jvm/storm/starter/tools/SlidingWindowCounterTest.java
@@ -67,6 +67,10 @@ public class SlidingWindowCounterTest {
         for (int i = 0; i < numIterations; i++) {
             int numIncrements = incrementsPerIteration[i];
             long expCounts = expCountsPerIteration[i];
+            // Objects are absent if they were zero both this iteration
+            // and the last -- if only this one, we need to report zero.
+            boolean expAbsent = ((expCounts == 0) &&
+                ((i == 0) || (expCountsPerIteration[i-1] == 0)));
 
             // given (for this iteration)
             for (int j = 0; j < numIncrements; j++) {
@@ -77,7 +81,7 @@ public class SlidingWindowCounterTest {
             Map<Object, Long> counts = counter.getCountsThenAdvanceWindow();
 
             // then (for this iteration)
-            if (expCounts == 0) {
+            if (expAbsent) {
                 assertThat(counts).doesNotContainKey(ANY_OBJECT);
             }
             else {

http://git-wip-us.apache.org/repos/asf/incubator-storm/blob/2aaada7f/test/jvm/storm/starter/tools/SlotBasedCounterTest.java
----------------------------------------------------------------------
diff --git a/test/jvm/storm/starter/tools/SlotBasedCounterTest.java b/test/jvm/storm/starter/tools/SlotBasedCounterTest.java
index c3e51c1..be174d4 100644
--- a/test/jvm/storm/starter/tools/SlotBasedCounterTest.java
+++ b/test/jvm/storm/starter/tools/SlotBasedCounterTest.java
@@ -142,7 +142,7 @@ public class SlotBasedCounterTest {
     }
 
     @Test
-    public void wipeSlotShouldRemoveAnyObjectsWithZeroTotalCount() {
+    public void wipeZerosShouldRemoveAnyObjectsWithZeroTotalCount() {
         // given
         SlotBasedCounter<Object> counter = new SlotBasedCounter<Object>(2);
         int wipeSlot = 0;
@@ -155,6 +155,7 @@ public class SlotBasedCounterTest {
 
         // when
         counter.wipeSlot(wipeSlot);
+        counter.wipeZeros();
 
         // then
         assertThat(counter.getCounts()).doesNotContainKey(willBeRemoved);


Mime
View raw message