2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
9 package org.opendaylight.netconf.console.commands;
11 import static junit.framework.TestCase.assertFalse;
12 import static junit.framework.TestCase.assertTrue;
14 import org.junit.Test;
16 public class NetconfCommandUtilsTest {
19 public void testIsPortValid() {
20 final boolean portTrue = NetconfCommandUtils.isPortValid("65535");
21 final boolean portTrue2 = NetconfCommandUtils.isPortValid("0");
23 final boolean portFalse = NetconfCommandUtils.isPortValid("123x");
24 final boolean portFalse2 = NetconfCommandUtils.isPortValid("65536");
25 final boolean portFalse3 = NetconfCommandUtils.isPortValid("");
28 assertTrue(portTrue2);
29 assertFalse(portFalse);
30 assertFalse(portFalse2);
31 assertFalse(portFalse3);
36 public void testIsIpValid() {
37 final boolean ipTrue = NetconfCommandUtils.isIpValid("0.0.0.0");
38 final boolean ipTrue2 = NetconfCommandUtils.isIpValid("255.255.255.255");
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("");
47 assertFalse(ipFalse2);
48 assertFalse(ipFalse3);