ARTEMIS-742 = test fixes

https://issues.apache.org/jira/browse/ARTEMIS-742
This commit is contained in:
Andy Taylor 2016-09-23 08:17:56 +01:00
parent 42fa3931ec
commit 4c1d9e2c0f
1 changed files with 25 additions and 6 deletions

View File

@ -35,7 +35,7 @@ public class QuorumVoteServerConnectTest extends ActiveMQTestBase {
@Parameterized.Parameters(name = "size={0} trueVotes={1}")
public static Collection primeNumbers() {
return Arrays.asList(new Object[][]{{1, 0}, {2, 0}, {3, 1}, {4, 2}, {5, 3}, {6, 3}, {7, 4}, {8, 4}, {9, 5}, {10, 5}});
return Arrays.asList(new Object[][]{{1, 0}, {2, 1}, {3, 2}, {4, 3}, {5, 3}, {6, 4}, {7, 4}, {8, 5}, {9, 5}, {10, 6}});
}
public QuorumVoteServerConnectTest(int size, int trueVotes) {
@ -45,16 +45,13 @@ public class QuorumVoteServerConnectTest extends ActiveMQTestBase {
}
@Test
public void testClusterSize() {
public void testSuccessfulVote() {
QuorumVoteServerConnect quorum = new QuorumVoteServerConnect(size, new FakeStorageManager());
for (int i = 0; i < trueVotes - 1; i++) {
quorum.vote(new BooleanVote(true));
}
if (size <= 2) {
assertTrue(quorum.getDecision());
}
else {
if (size > 1) {
assertFalse(quorum.getDecision());
}
quorum = new QuorumVoteServerConnect(size, new FakeStorageManager());
@ -63,4 +60,26 @@ public class QuorumVoteServerConnectTest extends ActiveMQTestBase {
}
assertTrue(quorum.getDecision());
}
@Test
public void testUnSuccessfulVote() {
QuorumVoteServerConnect quorum = new QuorumVoteServerConnect(size, new FakeStorageManager());
for (int i = 0; i < trueVotes - 1; i++) {
quorum.vote(new BooleanVote(true));
}
if (size > 1) {
assertFalse(quorum.getDecision());
}
quorum = new QuorumVoteServerConnect(size, new FakeStorageManager());
for (int i = 0; i < trueVotes - 1; i++) {
quorum.vote(new BooleanVote(true));
}
if (size == 1) {
assertTrue(quorum.getDecision());
}
else {
assertFalse(quorum.getDecision());
}
}
}