Add missing license headers
[openflowplugin.git] / applications / statistics-manager / src / test / java / test / mock / NodeRegistrationTest.java
1 /*
2  * Copyright (c) 2014, 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package test.mock;
9
10 import org.junit.Test;
11 import org.opendaylight.openflowplugin.applications.statistics.manager.StatisticsManager;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
14 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
15
16 import test.mock.util.StatisticsManagerTest;
17
18 import java.util.concurrent.ExecutionException;
19
20 import static org.junit.Assert.assertFalse;
21 import static org.junit.Assert.assertTrue;
22
23 public class NodeRegistrationTest extends StatisticsManagerTest {
24
25     @Test
26     public void nodeRegistrationTest() throws ExecutionException, InterruptedException {
27         StatisticsManager statisticsManager = setupStatisticsManager();
28
29         addFlowCapableNode(s1Key);
30         Thread.sleep(2000);
31         final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
32
33         assertTrue(statisticsManager.isProvidedFlowNodeActive(nodeII));
34     }
35
36     @Test
37     public void nodeUnregistrationTest() throws ExecutionException, InterruptedException {
38         StatisticsManager statisticsManager = setupStatisticsManager();
39
40         addFlowCapableNode(s1Key);
41         Thread.sleep(2000);
42         final InstanceIdentifier<Node> nodeII = InstanceIdentifier.create(Nodes.class).child(Node.class, s1Key);
43
44         assertTrue(statisticsManager.isProvidedFlowNodeActive(nodeII));
45
46         removeNode(s1Key);
47         Thread.sleep(2000);
48         assertFalse(statisticsManager.isProvidedFlowNodeActive(nodeII));
49     }
50 }