Umesh Krishnaswamy | 345ee99 | 2012-12-13 20:29:48 -0800 | [diff] [blame] | 1 | /** |
| 2 | * Copyright 2011, Big Switch Networks, Inc. |
| 3 | * Originally created by David Erickson, Stanford University |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 6 | * not use this file except in compliance with the License. You may obtain |
| 7 | * a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 14 | * License for the specific language governing permissions and limitations |
| 15 | * under the License. |
| 16 | **/ |
| 17 | |
| 18 | package net.floodlightcontroller.routing; |
| 19 | |
| 20 | import org.junit.Test; |
| 21 | |
| 22 | import net.floodlightcontroller.routing.Route; |
| 23 | import net.floodlightcontroller.test.FloodlightTestCase; |
| 24 | import net.floodlightcontroller.topology.NodePortTuple; |
| 25 | |
| 26 | /** |
| 27 | * |
| 28 | * @author David Erickson (daviderickson@cs.stanford.edu) |
| 29 | */ |
| 30 | public class RouteTest extends FloodlightTestCase { |
| 31 | @Test |
| 32 | public void testCloneable() throws Exception { |
| 33 | Route r1 = new Route(1L, 2L); |
| 34 | Route r2 = new Route(1L, 3L); |
| 35 | |
| 36 | assertNotSame(r1, r2); |
| 37 | assertNotSame(r1.getId(), r2.getId()); |
| 38 | |
| 39 | r1 = new Route(1L, 3L); |
| 40 | r1.getPath().add(new NodePortTuple(1L, (short)1)); |
| 41 | r1.getPath().add(new NodePortTuple(2L, (short)1)); |
| 42 | r1.getPath().add(new NodePortTuple(2L, (short)2)); |
| 43 | r1.getPath().add(new NodePortTuple(3L, (short)1)); |
| 44 | |
| 45 | r2.getPath().add(new NodePortTuple(1L, (short)1)); |
| 46 | r2.getPath().add(new NodePortTuple(2L, (short)1)); |
| 47 | r2.getPath().add(new NodePortTuple(2L, (short)2)); |
| 48 | r2.getPath().add(new NodePortTuple(3L, (short)1)); |
| 49 | |
| 50 | assertEquals(r1, r2); |
| 51 | |
| 52 | NodePortTuple temp = r2.getPath().remove(0); |
| 53 | assertNotSame(r1, r2); |
| 54 | |
| 55 | r2.getPath().add(0, temp); |
| 56 | assertEquals(r1, r2); |
| 57 | |
| 58 | r2.getPath().remove(1); |
| 59 | temp = new NodePortTuple(2L, (short)5); |
| 60 | r2.getPath().add(1, temp); |
| 61 | assertNotSame(r1, r2); |
| 62 | } |
| 63 | } |