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 NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, "name", node);
21 // If we reach this point the exception was not raised
22 // which should have been the case
23 Assert.assertTrue(false);
24 } catch (ConstructionException e) {
25 // If we reach this point the exception has been raised
27 System.out.println("Got exception as expected!:" + e);
28 Assert.assertTrue(true);
33 public void testNodeTableOpenFlowOfCorrectType() {
35 Node node = NodeCreator.createOFNode((long) 20);
36 NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node);
38 // If we reach this point the exception has not been
39 // raised so we passed the test
40 System.out.println("Got node table:" + of1);
41 Assert.assertTrue(true);
42 } catch (ConstructionException e) {
43 // If we reach this point the exception was raised
44 // which is not expected
45 Assert.assertTrue(false);
50 public void testTwoOpenFlowNodeTableEquals() {
52 Node node1 = NodeCreator.createOFNode((long) 20);
53 NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node1);
54 NodeTable of2 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node1);
56 Assert.assertTrue(of1.equals(of2));
57 } catch (ConstructionException e) {
58 // If we reach this point the exception was raised
59 // which is not expected
60 Assert.assertTrue(false);
65 public void testTwoOpenFlowNodeTableDifferents() {
67 Node node1 = NodeCreator.createOFNode((long) 20);
68 NodeTable of1 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("10"), node1);
69 Node node2 = NodeCreator.createOFNode((long) 40);
70 NodeTable of2 = new NodeTable(NodeTable.NodeTableIDType.OPENFLOW, Byte.valueOf("20"), node2);
72 Assert.assertTrue(!of1.equals(of2));
73 } catch (ConstructionException e) {
74 // If we reach this point the exception was raised
75 // which is not expected
76 Assert.assertTrue(false);