kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 9694702a25f2627618512bf30beb7295bcfa549956617be5f466ac19e356fd0c |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2014-12-22 19:51 -05:00 |
| Committer | Andrew Tolbert <andrew.tolbert@datastax.com> · 2014-12-23 08:45 -05:00 |
| Parents | 2f7ab0de2ec4 |
1 file changed
modified driver-core/src/test/java/com/datastax/driver/core/StateListenerTest.java +17 −22
| @@ -15,7 +15,11 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | +import com.google.common.collect.Sets; | |
| 18 | 19 | import org.testng.annotations.Test; |
| 20 | + | |
| 21 | +import java.util.Set; | |
| 22 | + | |
| 19 | 23 | import static org.testng.Assert.assertEquals; |
| 20 | 24 | |
| 21 | 25 | import static com.datastax.driver.core.TestUtils.*; |
| @@ -42,22 +46,22 @@ | ||
| 42 | 46 | // just before the listeners are called, and since waitFor is based on isUP, |
| 43 | 47 | // it can return *just* before the listener are called. |
| 44 | 48 | Thread.sleep(500); |
| 45 | - assertEquals(listener.adds, 1); | |
| 49 | + assertEquals(listener.adds.size(), 1); | |
| 46 | 50 | |
| 47 | 51 | c.cassandraCluster.forceStop(1); |
| 48 | 52 | waitForDown(CCMBridge.IP_PREFIX + '1', cluster); |
| 49 | 53 | Thread.sleep(500); |
| 50 | - assertEquals(listener.downs, 1); | |
| 54 | + assertEquals(listener.downs.size(), 1); | |
| 51 | 55 | |
| 52 | 56 | c.cassandraCluster.start(1); |
| 53 | 57 | waitFor(CCMBridge.IP_PREFIX + '1', cluster); |
| 54 | 58 | Thread.sleep(500); |
| 55 | - assertEquals(listener.ups, 1); | |
| 59 | + assertEquals(listener.ups.size(), 1); | |
| 56 | 60 | |
| 57 | 61 | c.cassandraCluster.decommissionNode(2); |
| 58 | 62 | waitForDecommission(CCMBridge.IP_PREFIX + '2', cluster); |
| 59 | 63 | Thread.sleep(500); |
| 60 | - assertEquals(listener.removes, 1); | |
| 64 | + assertEquals(listener.removes.size(), 1); | |
| 61 | 65 | } catch (Throwable e) { |
| 62 | 66 | c.errorOut(); |
| 63 | 67 | throw e; |
| @@ -68,28 +72,19 @@ | ||
| 68 | 72 | |
| 69 | 73 | private static class CountingListener implements Host.StateListener { |
| 70 | 74 | |
| 71 | - public int adds; | |
| 72 | - public int removes; | |
| 73 | - public int ups; | |
| 74 | - public int downs; | |
| 75 | + public Set<Host> adds = Sets.newHashSet(); | |
| 76 | + public Set<Host> removes = Sets.newHashSet(); | |
| 77 | + public Set<Host> ups = Sets.newHashSet(); | |
| 78 | + public Set<Host> downs = Sets.newHashSet(); | |
| 75 | 79 | |
| 76 | - public void onAdd(Host host) { | |
| 77 | - adds++; | |
| 78 | - } | |
| 80 | + public void onAdd(Host host) { adds.add(host); } | |
| 79 | 81 | |
| 80 | - public void onUp(Host host) { | |
| 81 | - ups++; | |
| 82 | - } | |
| 82 | + public void onUp(Host host) { ups.add(host); } | |
| 83 | 83 | |
| 84 | - public void onSuspected(Host host) { | |
| 85 | - } | |
| 84 | + public void onSuspected(Host host) {} | |
| 86 | 85 | |
| 87 | - public void onDown(Host host) { | |
| 88 | - downs++; | |
| 89 | - } | |
| 86 | + public void onDown(Host host) { downs.add(host); } | |
| 90 | 87 | |
| 91 | - public void onRemove(Host host) { | |
| 92 | - removes++; | |
| 93 | - } | |
| 88 | + public void onRemove(Host host) { removes.add(host); } | |
| 94 | 89 | } |
| 95 | 90 | } |