From 935c44e8b502304cec0830bb09099c27c3ed07bb Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Wed, 30 Apr 2014 15:51:32 +0000 Subject: QPID-5715: Address review comments from Alex Rudyy git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1591366 13f79535-47bb-0310-9956-ffa450edef68 --- .../store/berkeleydb/BDBHAVirtualHostNodeTest.java | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'qpid/java/bdbstore/src/test') diff --git a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java index 826694904c..78a86c685d 100644 --- a/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java +++ b/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBHAVirtualHostNodeTest.java @@ -246,7 +246,6 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase assertNotNull("Join time should be set", node.getJoinTime()); assertNotNull("Last known replication transaction idshould be set", node.getLastKnownReplicationTransactionId()); - } public void testTransferMasterToSelf() throws Exception @@ -421,6 +420,38 @@ public class BDBHAVirtualHostNodeTest extends QpidTestCase } } + public void testMutatingRoleWhenNotReplica_IsDisallowed() throws Exception + { + int nodePortNumber = findFreePort(); + String helperAddress = "localhost:" + nodePortNumber; + String groupName = "group"; + + Map node1Attributes = new HashMap(); + node1Attributes.put(BDBHAVirtualHostNode.ID, UUID.randomUUID()); + node1Attributes.put(BDBHAVirtualHostNode.TYPE, "BDB_HA"); + node1Attributes.put(BDBHAVirtualHostNode.NAME, "node1"); + node1Attributes.put(BDBHAVirtualHostNode.GROUP_NAME, groupName); + node1Attributes.put(BDBHAVirtualHostNode.ADDRESS, helperAddress); + node1Attributes.put(BDBHAVirtualHostNode.HELPER_ADDRESS, helperAddress); + node1Attributes.put(BDBHAVirtualHostNode.STORE_PATH, _bdbStorePath + File.separator + "1"); + + BDBHAVirtualHostNode node = createHaVHN(node1Attributes); + assertEquals("Failed to activate node", State.ACTIVE, node.setDesiredState(node.getState(), State.ACTIVE)); + + assertEquals("Node is expected to be master", "MASTER", node.getRole()); + + try + { + node.setAttributes(Collections.singletonMap(BDBHAVirtualHostNode.ROLE, "REPLICA")); + fail("Role mutation should fail"); + } + catch(IllegalStateException e) + { + // PASS + } + } + + private BDBHAVirtualHostNode createHaVHN(Map attributes) { BDBHAVirtualHostNode node = (BDBHAVirtualHostNode) _objectFactory.create(VirtualHostNode.class, attributes, _broker); -- cgit v1.2.1