Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Open Networking Laboratory |
| 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.link; |
tom | c0ccfb2 | 2014-09-08 00:41:32 -0700 | [diff] [blame] | 17 | |
| 18 | import org.junit.Test; |
Pavel Likin | 9d49f54 | 2015-12-13 15:04:55 +0300 | [diff] [blame] | 19 | import org.onosproject.net.DefaultAnnotations; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 20 | import org.onosproject.net.DeviceId; |
| 21 | import org.onosproject.net.PortNumber; |
tom | c0ccfb2 | 2014-09-08 00:41:32 -0700 | [diff] [blame] | 22 | |
| 23 | import static org.junit.Assert.assertEquals; |
Pavel Likin | 9d49f54 | 2015-12-13 15:04:55 +0300 | [diff] [blame] | 24 | import static org.junit.Assert.assertTrue; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 25 | import static org.onosproject.net.DefaultLinkTest.cp; |
| 26 | import static org.onosproject.net.DeviceId.deviceId; |
| 27 | import static org.onosproject.net.Link.Type.DIRECT; |
| 28 | import static org.onosproject.net.PortNumber.portNumber; |
tom | c0ccfb2 | 2014-09-08 00:41:32 -0700 | [diff] [blame] | 29 | |
| 30 | /** |
| 31 | * Test of the default link description. |
| 32 | */ |
| 33 | public class DefaultLinkDescriptionTest { |
| 34 | |
| 35 | private static final DeviceId DID1 = deviceId("of:foo"); |
| 36 | private static final DeviceId DID2 = deviceId("of:bar"); |
| 37 | private static final PortNumber P1 = portNumber(1); |
Pavel Likin | 9d49f54 | 2015-12-13 15:04:55 +0300 | [diff] [blame] | 38 | private static final DefaultAnnotations DA = |
| 39 | DefaultAnnotations.builder().set("Key", "Value").build(); |
tom | c0ccfb2 | 2014-09-08 00:41:32 -0700 | [diff] [blame] | 40 | |
| 41 | @Test |
| 42 | public void basics() { |
Pavel Likin | 9d49f54 | 2015-12-13 15:04:55 +0300 | [diff] [blame] | 43 | LinkDescription desc = new DefaultLinkDescription(cp(DID1, P1), cp(DID2, P1), DIRECT, DA); |
tom | c0ccfb2 | 2014-09-08 00:41:32 -0700 | [diff] [blame] | 44 | assertEquals("incorrect src", cp(DID1, P1), desc.src()); |
| 45 | assertEquals("incorrect dst", cp(DID2, P1), desc.dst()); |
| 46 | assertEquals("incorrect type", DIRECT, desc.type()); |
Pavel Likin | 9d49f54 | 2015-12-13 15:04:55 +0300 | [diff] [blame] | 47 | assertTrue("incorrect annotatios", desc.toString().contains("Key=Value")); |
tom | c0ccfb2 | 2014-09-08 00:41:32 -0700 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | } |