Merge "1. Corrected Ip Protocol match field. 2. Added mask for Ipv6 Extension header...
[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 import org.junit.Test;
12
13 public class AdditionalHeaderParserTest {
14
15     @Test
16     public void testParsing() throws Exception {
17         String s = "[netconf;10.12.0.102:48528;ssh;;;;;;]";
18         NetconfServerSessionNegotiator.AdditionalHeader header = new NetconfServerSessionNegotiator.AdditionalHeader(s);
19         Assert.assertEquals("netconf", header.getUsername());
20         Assert.assertEquals("10.12.0.102", header.getAddress());
21         Assert.assertEquals("ssh", header.getTransport());
22     }
23
24     @Test
25     public void testParsing2() throws Exception {
26         String s = "[tomas;10.0.0.0/10000;tcp;1000;1000;;/home/tomas;;]";
27         NetconfServerSessionNegotiator.AdditionalHeader header = new NetconfServerSessionNegotiator.AdditionalHeader(s);
28         Assert.assertEquals("tomas", header.getUsername());
29         Assert.assertEquals("10.0.0.0", header.getAddress());
30         Assert.assertEquals("tcp", header.getTransport());
31     }
32
33     @Test(expected = IllegalArgumentException.class)
34     public void testParsingNoUsername() throws Exception {
35         String s = "[10.12.0.102:48528;ssh;;;;;;]";
36         new NetconfServerSessionNegotiator.AdditionalHeader(s);
37     }
38 }