959e2ff144810c2017131e8041229e86b1cabd64
[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 static org.junit.Assert.assertArrayEquals;
12 import static org.junit.Assert.assertEquals;
13
14 import org.junit.Test;
15 import org.opendaylight.controller.netconf.util.messages.NetconfMessageHeader;
16
17 public class MessageHeaderTest {
18     @Test
19     public void testFromBytes() {
20         final byte[] raw = new byte[] { (byte) 0x0a, (byte) 0x23, (byte) 0x35, (byte) 0x38, (byte) 0x0a };
21         NetconfMessageHeader header = NetconfMessageHeader.fromBytes(raw);
22         assertEquals(58, header.getLength());
23     }
24
25     @Test
26     public void testToBytes() {
27         NetconfMessageHeader header = new NetconfMessageHeader(123);
28         assertArrayEquals(new byte[] { (byte) 0x0a, (byte) 0x23, (byte) 0x31, (byte) 0x32, (byte) 0x33, (byte) 0x0a },
29                 header.toBytes());
30     }
31 }