eee05dc4f06756a7fd491d987978b96e7a3bba4f
[openflowplugin.git] / applications / statistics-manager / src / test / java / test / mock / NodeRegistrationTest.java
1 package test.mock;
2
3 import org.junit.Test;
4 import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
5 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
6 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
7 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
8
9 import test.mock.util.StatisticsManagerTest;
10
11 import java.util.concurrent.ExecutionException;
12
13 import static org.junit.Assert.assertFalse;
14 import static org.junit.Assert.assertTrue;
15
16 public class NodeRegistrationTest extends StatisticsManagerTest {
17
18     @Test
19     public void nodeRegistrationTest() throws ExecutionException, InterruptedException {
20         StatisticsManager statisticsManager = setupStatisticsManager();
21
22         addFlowCapableNode(s1Key);
23         Thread.sleep(2000);
24         final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
25
26         assertTrue(statisticsManager.isProvidedFlowNodeActive(nodeII));
27     }
28
29     @Test
30     public void nodeUnregistrationTest() throws ExecutionException, InterruptedException {
31         StatisticsManager statisticsManager = setupStatisticsManager();
32
33         addFlowCapableNode(s1Key);
34         Thread.sleep(2000);
35         final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
36
37         assertTrue(statisticsManager.isProvidedFlowNodeActive(nodeII));
38
39         removeNode(s1Key);
40         Thread.sleep(2000);
41         assertFalse(statisticsManager.isProvidedFlowNodeActive(nodeII));
42     }
43 }
44