Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package org.onosproject.incubator.net.virtual; |
| 18 | |
| 19 | import com.google.common.testing.EqualsTester; |
| 20 | import org.junit.Test; |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 21 | import org.onosproject.net.ConnectPoint; |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 22 | import org.onosproject.net.PortNumber; |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 23 | import org.onosproject.net.TestDeviceParams; |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 24 | |
| 25 | import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable; |
| 26 | |
| 27 | /** |
| 28 | * Test of the default virtual port model entity. |
| 29 | */ |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 30 | public class DefaultVirtualPortTest extends TestDeviceParams { |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 31 | /** |
| 32 | * Checks that the DefaultVirtualPort class is immutable. |
| 33 | */ |
| 34 | @Test |
| 35 | public void testImmutability() { |
| 36 | assertThatClassIsImmutable(DefaultVirtualPort.class); |
| 37 | } |
| 38 | |
| 39 | @Test |
| 40 | public void testEquality() { |
| 41 | DefaultVirtualDevice device1 = |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 42 | new DefaultVirtualDevice(NetworkId.networkId(0), DID1); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 43 | DefaultVirtualDevice device2 = |
Brian Stanke | 7a81b53 | 2016-06-14 15:43:51 -0400 | [diff] [blame] | 44 | new DefaultVirtualDevice(NetworkId.networkId(0), DID2); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 45 | |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 46 | ConnectPoint cpA = new ConnectPoint(device1.id(), PortNumber.portNumber(1)); |
| 47 | ConnectPoint cpB = new ConnectPoint(device1.id(), PortNumber.portNumber(2)); |
| 48 | ConnectPoint cpC = new ConnectPoint(device2.id(), PortNumber.portNumber(2)); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 49 | |
| 50 | DefaultVirtualPort port1 = |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 51 | new DefaultVirtualPort(NetworkId.networkId(0), device1, |
| 52 | PortNumber.portNumber(1), cpA); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 53 | DefaultVirtualPort port2 = |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 54 | new DefaultVirtualPort(NetworkId.networkId(0), device1, |
| 55 | PortNumber.portNumber(1), cpA); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 56 | DefaultVirtualPort port3 = |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 57 | new DefaultVirtualPort(NetworkId.networkId(0), device1, |
| 58 | PortNumber.portNumber(2), cpB); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 59 | DefaultVirtualPort port4 = |
Yoonseon Han | 6c60389 | 2016-09-01 11:52:21 -0700 | [diff] [blame] | 60 | new DefaultVirtualPort(NetworkId.networkId(1), device2, |
| 61 | PortNumber.portNumber(2), cpC); |
Brian Stanke | 0e5c94e | 2016-03-08 11:20:04 -0500 | [diff] [blame] | 62 | |
| 63 | |
| 64 | new EqualsTester().addEqualityGroup(port1, port2).addEqualityGroup(port3) |
| 65 | .addEqualityGroup(port4).testEquals(); |
| 66 | } |
| 67 | } |