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.device; |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 17 | |
| 18 | import org.junit.Test; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 19 | import org.onlab.packet.ChassisId; |
Pavel Likin | 9d49f54 | 2015-12-13 15:04:55 +0300 | [diff] [blame] | 20 | import org.onosproject.net.DefaultAnnotations; |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 21 | |
| 22 | import java.net.URI; |
| 23 | |
| 24 | import static org.junit.Assert.assertEquals; |
| 25 | import static org.junit.Assert.assertTrue; |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 26 | import static org.onosproject.net.Device.Type.SWITCH; |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Test of the default device description. |
| 30 | */ |
| 31 | public class DefaultDeviceDescriptionTest { |
| 32 | |
| 33 | private static final URI DURI = URI.create("of:foo"); |
| 34 | private static final String MFR = "whitebox"; |
| 35 | private static final String HW = "1.1.x"; |
| 36 | private static final String SW = "3.9.1"; |
| 37 | private static final String SN = "43311-12345"; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 38 | private static final ChassisId CID = new ChassisId(); |
Pavel Likin | 9d49f54 | 2015-12-13 15:04:55 +0300 | [diff] [blame] | 39 | private static final DefaultAnnotations DA = |
| 40 | DefaultAnnotations.builder().set("Key", "Value").build(); |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 41 | |
| 42 | @Test |
| 43 | public void basics() { |
| 44 | DeviceDescription device = |
Pavel Likin | 9d49f54 | 2015-12-13 15:04:55 +0300 | [diff] [blame] | 45 | new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID, DA); |
Jonathan Hart | d9df7bd | 2015-11-10 17:10:25 -0800 | [diff] [blame] | 46 | assertEquals("incorrect uri", DURI, device.deviceUri()); |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 47 | assertEquals("incorrect type", SWITCH, device.type()); |
| 48 | assertEquals("incorrect manufacturer", MFR, device.manufacturer()); |
| 49 | assertEquals("incorrect hw", HW, device.hwVersion()); |
| 50 | assertEquals("incorrect sw", SW, device.swVersion()); |
| 51 | assertEquals("incorrect serial", SN, device.serialNumber()); |
| 52 | assertTrue("incorrect toString", device.toString().contains("uri=of:foo")); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 53 | assertTrue("Incorrect chassis", device.chassisId().value() == 0); |
Pavel Likin | 9d49f54 | 2015-12-13 15:04:55 +0300 | [diff] [blame] | 54 | assertTrue("incorrect annotatios", device.toString().contains("Key=Value")); |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | } |