Initial code drop of netconf protocol implementation
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / netconf / impl / MessageHeaderTest.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
9 package org.opendaylight.controller.netconf.impl;
10
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.opendaylight.controller.netconf.util.messages.NetconfMessageHeader;
14
15 import static org.junit.Assert.assertArrayEquals;
16 import static org.junit.Assert.assertEquals;
17
18 public class MessageHeaderTest {
19
20     private NetconfMessageHeader header = null;
21
22     @Before
23     public void setUp() {
24         this.header = new NetconfMessageHeader();
25     }
26
27     @Test
28     public void testFromBytes() {
29         final byte[] raw = new byte[] { (byte) 0x0a, (byte) 0x23, (byte) 0x35, (byte) 0x38, (byte) 0x0a };
30         this.header.fromBytes(raw);
31         assertEquals(58, this.header.getLength());
32     }
33
34     @Test
35     public void testToBytes() {
36         this.header.setLength(123);
37         assertArrayEquals(new byte[] { (byte) 0x0a, (byte) 0x23, (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x0a },
38                 this.header.toBytes());
39     }
40 }