blob: 3d428d0a16dccb9c556d84bb8bc75c0c9d6785c3 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
Ayaka Koshibee8e45352014-10-16 00:37:19 -070016package org.onlab.onos.store.mastership.impl;
17
18import static org.junit.Assert.assertEquals;
19import static org.junit.Assert.assertTrue;
20import static org.onlab.onos.net.MastershipRole.*;
21
22import org.junit.Test;
23import org.onlab.onos.cluster.NodeId;
24
25import com.google.common.collect.Sets;
26
27public class RoleValueTest {
28
29 private static final RoleValue RV = new RoleValue();
30
31 private static final NodeId NID1 = new NodeId("node1");
32 private static final NodeId NID2 = new NodeId("node2");
33 private static final NodeId NID3 = new NodeId("node3");
34
35 @Test
36 public void add() {
37 assertEquals("faulty initialization: ", 3, RV.value.size());
38 RV.add(MASTER, NID1);
39 RV.add(STANDBY, NID2);
40 RV.add(STANDBY, NID3);
41
42 assertEquals("wrong nodeID: ", NID1, RV.get(MASTER));
43 assertTrue("wrong nodeIDs: ",
44 Sets.newHashSet(NID3, NID2).containsAll(RV.nodesOfRole(STANDBY)));
45 }
46}