Ayaka Koshibe | e8e4535 | 2014-10-16 00:37:19 -0700 | [diff] [blame^] | 1 | package org.onlab.onos.store.mastership.impl; |
| 2 | |
| 3 | import static org.junit.Assert.assertEquals; |
| 4 | import static org.junit.Assert.assertTrue; |
| 5 | import static org.onlab.onos.net.MastershipRole.*; |
| 6 | |
| 7 | import org.junit.Test; |
| 8 | import org.onlab.onos.cluster.NodeId; |
| 9 | |
| 10 | import com.google.common.collect.Sets; |
| 11 | |
| 12 | public class RoleValueTest { |
| 13 | |
| 14 | private static final RoleValue RV = new RoleValue(); |
| 15 | |
| 16 | private static final NodeId NID1 = new NodeId("node1"); |
| 17 | private static final NodeId NID2 = new NodeId("node2"); |
| 18 | private static final NodeId NID3 = new NodeId("node3"); |
| 19 | |
| 20 | @Test |
| 21 | public void add() { |
| 22 | assertEquals("faulty initialization: ", 3, RV.value.size()); |
| 23 | RV.add(MASTER, NID1); |
| 24 | RV.add(STANDBY, NID2); |
| 25 | RV.add(STANDBY, NID3); |
| 26 | |
| 27 | assertEquals("wrong nodeID: ", NID1, RV.get(MASTER)); |
| 28 | assertTrue("wrong nodeIDs: ", |
| 29 | Sets.newHashSet(NID3, NID2).containsAll(RV.nodesOfRole(STANDBY))); |
| 30 | } |
| 31 | } |