c2dcd679210f1d66cd055e48a9c05494d3d8d374
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / netconf / impl / AdditionalHeaderParserTest.java
1 /*
2  * Copyright (c) 2013 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 package org.opendaylight.controller.netconf.impl;
9
10 import junit.framework.Assert;
11
12 import org.junit.Test;
13 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
14
15 public class AdditionalHeaderParserTest {
16
17     @Test
18     public void testParsing() throws Exception {
19         String s = "[netconf;10.12.0.102:48528;ssh;;;;;;]";
20         NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(s);
21         Assert.assertEquals("netconf", header.getUserName());
22         Assert.assertEquals("10.12.0.102", header.getAddress());
23         Assert.assertEquals("ssh", header.getTransport());
24     }
25
26     @Test
27     public void testParsing2() throws Exception {
28         String s = "[tomas;10.0.0.0/10000;tcp;1000;1000;;/home/tomas;;]";
29         NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(s);
30         Assert.assertEquals("tomas", header.getUserName());
31         Assert.assertEquals("10.0.0.0", header.getAddress());
32         Assert.assertEquals("tcp", header.getTransport());
33     }
34
35     @Test(expected = IllegalArgumentException.class)
36     public void testParsingNoUsername() throws Exception {
37         String s = "[10.12.0.102:48528;ssh;;;;;;]";
38         NetconfHelloMessageAdditionalHeader.fromString(s);
39     }
40 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.