Promote MessageRegistry to pcep-api
[bgpcep.git] / pcep / ietf-p2mp-te-lsp / src / test / java / org / opendaylight / protocol / pcep / p2mp / te / lsp / P2MPTeLspTlvsParserTest.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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.protocol.pcep.p2mp.te.lsp;
9
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.opendaylight.protocol.pcep.p2mp.te.lsp.P2MPTeLspCapabilityParser.P2MP_CAPABILITY;
13
14 import io.netty.buffer.ByteBuf;
15 import io.netty.buffer.Unpooled;
16 import org.junit.Test;
17 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
18 import org.opendaylight.protocol.util.ByteArray;
19
20 public class P2MPTeLspTlvsParserTest {
21     private static final byte[] SPC_TLV_BYTES = {0x0, 0x06, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0};
22
23     @Test
24     public void testSrPceCapabilityParser() throws PCEPDeserializerException {
25         final P2MPTeLspCapabilityParser parser = new P2MPTeLspCapabilityParser();
26         assertEquals(P2MP_CAPABILITY, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(SPC_TLV_BYTES, 4))));
27         final ByteBuf buff = Unpooled.buffer();
28         parser.serializeTlv(P2MP_CAPABILITY, buff);
29         assertArrayEquals(SPC_TLV_BYTES, ByteArray.getAllBytes(buff));
30     }
31 }