Bug-915: Adding static document generation.
[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 static org.junit.Assert.assertEquals;
11 import org.junit.Test;
12 import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessageAdditionalHeader;
13
14 public class AdditionalHeaderParserTest {
15
16     @Test
17     public void testParsing() throws Exception {
18         String s = "[netconf;10.12.0.102:48528;ssh;;;;;;]";
19         NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(s);
20         assertEquals("netconf", header.getUserName());
21         assertEquals("10.12.0.102", header.getAddress());
22         assertEquals("ssh", header.getTransport());
23     }
24
25     @Test
26     public void testParsing2() throws Exception {
27         String s = "[tomas;10.0.0.0/10000;tcp;1000;1000;;/home/tomas;;]";
28         NetconfHelloMessageAdditionalHeader header = NetconfHelloMessageAdditionalHeader.fromString(s);
29         assertEquals("tomas", header.getUserName());
30         assertEquals("10.0.0.0", header.getAddress());
31         assertEquals("tcp", header.getTransport());
32     }
33
34     @Test(expected = IllegalArgumentException.class)
35     public void testParsingNoUsername() throws Exception {
36         String s = "[10.12.0.102:48528;ssh;;;;;;]";
37         NetconfHelloMessageAdditionalHeader.fromString(s);
38     }
39 }