Ayaka Koshibe | abedb09 | 2014-10-20 17:01:31 -0700 | [diff] [blame] | 1 | package org.onlab.onos.cluster; |
Ayaka Koshibe | 67af1f4 | 2014-10-20 15:26:37 -0700 | [diff] [blame] | 2 | |
| 3 | import java.util.List; |
| 4 | |
| 5 | import org.junit.Test; |
Ayaka Koshibe | 67af1f4 | 2014-10-20 15:26:37 -0700 | [diff] [blame] | 6 | |
| 7 | import com.google.common.collect.Lists; |
| 8 | |
| 9 | import static org.junit.Assert.assertEquals; |
| 10 | import static org.junit.Assert.assertNotEquals; |
| 11 | |
| 12 | /** |
| 13 | * Test to check behavioral correctness of the RoleInfo structure. |
| 14 | */ |
| 15 | public class RoleInfoTest { |
| 16 | private static final NodeId N1 = new NodeId("n1"); |
| 17 | private static final NodeId N2 = new NodeId("n2"); |
| 18 | private static final NodeId N3 = new NodeId("n3"); |
| 19 | private static final NodeId N4 = new NodeId("n4"); |
| 20 | |
| 21 | private static final List<NodeId> BKUP1 = Lists.newArrayList(N2, N3); |
| 22 | private static final List<NodeId> BKUP2 = Lists.newArrayList(N3, N4); |
| 23 | |
| 24 | private static final RoleInfo RI1 = new RoleInfo(N1, BKUP1); |
| 25 | private static final RoleInfo RI2 = new RoleInfo(N1, BKUP2); |
| 26 | private static final RoleInfo RI3 = new RoleInfo(N2, BKUP1); |
| 27 | |
| 28 | @Test |
| 29 | public void basics() { |
| 30 | assertEquals("wrong master", new NodeId("n1"), RI1.master()); |
Ayaka Koshibe | 67af1f4 | 2014-10-20 15:26:37 -0700 | [diff] [blame] | 31 | assertEquals("wrong Backups", RI1.backups(), Lists.newArrayList(N2, N3)); |
| 32 | |
| 33 | assertNotEquals("equals() broken", RI1, RI2); |
| 34 | assertNotEquals("equals() broken", RI1, RI3); |
| 35 | |
| 36 | List<NodeId> bkup3 = Lists.newArrayList(N3, new NodeId("n4")); |
| 37 | assertEquals("equals() broken", new RoleInfo(N1, bkup3), RI2); |
| 38 | } |
| 39 | } |