Andrea Campanella | 58454b9 | 2016-04-01 15:19:00 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 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 | */ |
| 16 | |
| 17 | package org.onosproject.snmp.ctl; |
| 18 | |
| 19 | import org.junit.Test; |
| 20 | import org.onosproject.net.DeviceId; |
| 21 | |
| 22 | import static org.junit.Assert.*; |
| 23 | |
| 24 | /** |
| 25 | * Test class for DefaultSnmpDevice. |
| 26 | */ |
| 27 | public class DefaultSnmpDeviceTest { |
| 28 | |
| 29 | private final String snmpHost = "1.1.1.1"; |
| 30 | private int snmpPort = 1; |
| 31 | private final String username = "test"; |
| 32 | private final String community = "test"; |
| 33 | private final DeviceId deviceId = DeviceId.deviceId("snmp:1.1.1.1:1"); |
| 34 | private final String deviceInfo = "host: 1.1.1.1. port: 1"; |
| 35 | |
| 36 | DefaultSnmpDevice device = new DefaultSnmpDevice("1.1.1.1", 1, "test", "test"); |
| 37 | |
| 38 | @Test |
| 39 | public void basics() throws Exception { |
| 40 | assertTrue("Device should be reachable", device.isReachable()); |
| 41 | assertEquals("Incorrect host", snmpHost, device.getSnmpHost()); |
| 42 | assertEquals("Incorrect port", snmpPort, device.getSnmpPort()); |
| 43 | assertEquals("Incorrect username", username, device.getUsername()); |
| 44 | assertEquals("Incorrect community", community, device.getCommunity()); |
| 45 | assertEquals("Incorrect deviceID", deviceId, device.deviceId()); |
| 46 | assertEquals("Incorrect deviceInfo", deviceInfo, device.deviceInfo()); |
| 47 | device.disconnect(); |
| 48 | assertFalse("Device should not be reachable", device.isReachable()); |
| 49 | |
| 50 | } |
| 51 | } |