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; |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 20 | |
| 21 | import java.net.URI; |
| 22 | |
| 23 | import static org.junit.Assert.assertEquals; |
| 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.Device.Type.SWITCH; |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * Test of the default device description. |
| 29 | */ |
| 30 | public class DefaultDeviceDescriptionTest { |
| 31 | |
| 32 | private static final URI DURI = URI.create("of:foo"); |
| 33 | private static final String MFR = "whitebox"; |
| 34 | private static final String HW = "1.1.x"; |
| 35 | private static final String SW = "3.9.1"; |
| 36 | private static final String SN = "43311-12345"; |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 37 | private static final ChassisId CID = new ChassisId(); |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 38 | |
| 39 | |
| 40 | @Test |
| 41 | public void basics() { |
| 42 | DeviceDescription device = |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 43 | new DefaultDeviceDescription(DURI, SWITCH, MFR, HW, SW, SN, CID); |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 44 | assertEquals("incorrect uri", DURI, device.deviceURI()); |
| 45 | assertEquals("incorrect type", SWITCH, device.type()); |
| 46 | assertEquals("incorrect manufacturer", MFR, device.manufacturer()); |
| 47 | assertEquals("incorrect hw", HW, device.hwVersion()); |
| 48 | assertEquals("incorrect sw", SW, device.swVersion()); |
| 49 | assertEquals("incorrect serial", SN, device.serialNumber()); |
| 50 | assertTrue("incorrect toString", device.toString().contains("uri=of:foo")); |
alshabib | 7911a05 | 2014-10-16 17:49:37 -0700 | [diff] [blame] | 51 | assertTrue("Incorrect chassis", device.chassisId().value() == 0); |
tom | 3065d12 | 2014-09-03 21:56:43 -0700 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | } |