df0e4bc73855ff86304e1df984d8acc886746fcb
[netconf.git] / netconf / netconf-api / src / test / java / org / opendaylight / netconf / api / messages / NetconfHelloMessageTest.java
1 /*
2  * Copyright (c) 2014 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.api.messages;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12
13 import java.util.Optional;
14 import java.util.Set;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.mockito.internal.util.collections.Sets;
18 import org.opendaylight.netconf.api.NetconfDocumentedException;
19
20 public class NetconfHelloMessageTest {
21
22     Set<String> caps;
23
24     @Before
25     public void setUp() {
26         caps = Sets.newSet("cap1");
27     }
28
29     @Test
30     public void testConstructor() throws NetconfDocumentedException {
31         NetconfHelloMessageAdditionalHeader additionalHeader = new NetconfHelloMessageAdditionalHeader("name",
32                 "host", "1", "transp", "id");
33         NetconfHelloMessage message = NetconfHelloMessage.createClientHello(caps, Optional.of(additionalHeader));
34         assertTrue(NetconfHelloMessage.isHelloMessage(message));
35         assertEquals(Optional.of(additionalHeader), message.getAdditionalHeader());
36
37         NetconfHelloMessage serverMessage = NetconfHelloMessage.createServerHello(caps, 100L);
38         assertTrue(NetconfHelloMessage.isHelloMessage(serverMessage));
39     }
40 }