Clean up NetconfServerSessionNegotiatorTest
[netconf.git] / protocol / netconf-server / src / test / java / org / opendaylight / netconf / server / NetconfServerSessionNegotiatorTest.java
1 /*
2  * Copyright (c) 2014, 2015 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.netconf.server;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11 import static org.junit.jupiter.api.Assertions.assertNotNull;
12
13 import io.netty.channel.local.LocalAddress;
14 import java.net.InetSocketAddress;
15 import org.junit.jupiter.api.Test;
16
17 class NetconfServerSessionNegotiatorTest {
18     @Test
19     void testPortTen() {
20         final var address = new InetSocketAddress(10);
21         final var hostname = NetconfServerSessionNegotiator.getHostName(address);
22         assertNotNull(hostname);
23         assertEquals(address.getHostName(), hostname.getValue());
24     }
25
26     @Test
27     void testPortTwenty() {
28         final var address = new InetSocketAddress("TestPortInet", 20);
29         final var hostname = NetconfServerSessionNegotiator.getHostName(address);
30         assertEquals(address.getHostName(), hostname.getValue());
31         assertEquals(String.valueOf(address.getPort()), hostname.getKey());
32     }
33
34     @Test
35     void testGetInetSocketAddress() {
36         final var address = new LocalAddress("TestPortLocal");
37         final var hostname = NetconfServerSessionNegotiator.getHostName(address);
38         assertEquals(String.valueOf(address.id()), hostname.getValue());
39     }
40 }