2 * Copyright (c) 2013 Big Switch Networks, Inc. All rights reserved.
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
8 package org.opendaylight.controller.sal.core;
10 import org.junit.Assert;
11 import org.junit.Test;
12 import org.opendaylight.controller.sal.utils.NodeCreator;
14 public class NodeTableTest {
16 public void testNodeTableOpenFlowOfWrongType() {
18 Node node = NodeCreator.createOFNode((long) 20);
19 @SuppressWarnings("unused")
20 NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, "name", node);
22 // If we reach this point the exception was not raised
23 // which should have been the case
24 Assert.assertTrue(false);
25 } catch (ConstructionException e) {
26 // If we reach this point the exception has been raised
28 System.out.println("Got exception as expected!:" + e);
29 Assert.assertTrue(true);
34 public void testNodeTableOpenFlowOfCorrectType() {
36 Node node = NodeCreator.createOFNode((long) 20);
37 NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node);
39 // If we reach this point the exception has not been
40 // raised so we passed the test
41 System.out.println("Got node table:" + of1);
42 Assert.assertTrue(true);
43 } catch (ConstructionException e) {
44 // If we reach this point the exception was raised
45 // which is not expected
46 Assert.assertTrue(false);
51 public void testTwoOpenFlowNodeTableEquals() {
53 Node node1 = NodeCreator.createOFNode((long) 20);
54 NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node1);
55 NodeTable of2 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node1);
57 Assert.assertTrue(of1.equals(of2));
58 } catch (ConstructionException e) {
59 // If we reach this point the exception was raised
60 // which is not expected
61 Assert.assertTrue(false);
66 public void testTwoOpenFlowNodeTableDifferents() {
68 Node node1 = NodeCreator.createOFNode((long) 20);
69 NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node1);
70 Node node2 = NodeCreator.createOFNode((long) 40);
71 NodeTable of2 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("20"), node2);
73 Assert.assertTrue(!of1.equals(of2));
74 } catch (ConstructionException e) {
75 // If we reach this point the exception was raised
76 // which is not expected
77 Assert.assertTrue(false);