netconf-console unit tests added
[netconf.git] / netconf / netconf-console / src / test / java / org / opendaylight / netconf / console / commands / NetconfCommandUtilsTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.netconf.console.commands;
10
11 import static junit.framework.TestCase.assertFalse;
12 import static junit.framework.TestCase.assertTrue;
13
14 import org.junit.Test;
15
16 public class NetconfCommandUtilsTest {
17
18     @Test
19     public void testIsPortValid() {
20         final boolean portTrue = NetconfCommandUtils.isPortValid("65535");
21         final boolean portTrue2 = NetconfCommandUtils.isPortValid("0");
22
23         final boolean portFalse = NetconfCommandUtils.isPortValid("123x");
24         final boolean portFalse2 = NetconfCommandUtils.isPortValid("65536");
25         final boolean portFalse3 = NetconfCommandUtils.isPortValid("");
26
27         assertTrue(portTrue);
28         assertTrue(portTrue2);
29         assertFalse(portFalse);
30         assertFalse(portFalse2);
31         assertFalse(portFalse3);
32
33     }
34
35     @Test
36     public void testIsIpValid() {
37         final boolean ipTrue = NetconfCommandUtils.isIpValid("0.0.0.0");
38         final boolean ipTrue2 = NetconfCommandUtils.isIpValid("255.255.255.255");
39
40         final boolean ipFalse = NetconfCommandUtils.isIpValid("256.1.1.1");
41         final boolean ipFalse2 = NetconfCommandUtils.isIpValid("123.145.12.x");
42         final boolean ipFalse3 = NetconfCommandUtils.isIpValid("");
43
44         assertTrue(ipTrue);
45         assertTrue(ipTrue2);
46         assertFalse(ipFalse);
47         assertFalse(ipFalse2);
48         assertFalse(ipFalse3);
49     }
50 }