BUG-47 : unfinished PCEP migration to generated DTOs.
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / PCEPTlvParserTest.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 package org.opendaylight.protocol.pcep.impl;
9
10
11 /**
12  * Tests of PCEPTlvParser
13  */
14 public class PCEPTlvParserTest {
15
16         // @Test
17         // public void testDeserialization() throws PCEPDeserializerException, IOException {
18         // final byte[] bytesFromFile = ByteArray.fileToBytes("src/test/resources/PackOfTlvs.bin");
19         // final List<PCEPTlv> tlvsToTest = PCEPTlvParser.parseTlv(bytesFromFile);
20         //
21         // assertEquals(17, tlvsToTest.size());
22         // assertEquals(tlvsToTest.get(0), new PCEStatefulCapabilityTlv(false, false, true));
23         // assertEquals(tlvsToTest.get(1), new LSPStateDBVersionTlv(0xFF00FFAAB2F5F2CFL));
24         // assertEquals(tlvsToTest.get(2), new PCEStatefulCapabilityTlv(false, true, true));
25         // assertEquals(tlvsToTest.get(3), new LSPStateDBVersionTlv(0xFFFFFFFFFFFFFFFFL));
26         // assertEquals(tlvsToTest.get(4), new NoPathVectorTlv(true, true, true, false, true, true));
27         // assertEquals(tlvsToTest.get(5), new OverloadedDurationTlv(0x7FFFFFFF));
28         // assertEquals(tlvsToTest.get(6), new LSPSymbolicNameTlv(new LSPSymbolicName(new
29         // String("Med test of symbolic name").getBytes())));
30         // final byte[] errorCode = { (byte) 0x25, (byte) 0x68, (byte) 0x95, (byte) 0x03 };
31         // assertEquals(tlvsToTest.get(7), new LSPUpdateErrorTlv(errorCode));
32         // final byte[] ipv4Address = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
33         // final byte[] tunnelId1 = { (byte) 0x12, (byte) 0x34 };
34         // final byte[] extendedTunnelID1 = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 };
35         // final byte[] lspId1 = { (byte) 0xFF, (byte) 0xFF };
36         // assertEquals(tlvsToTest.get(8), new IPv4LSPIdentifiersTlv(new IPv4Address(ipv4Address),
37         // new LSPIdentifier(lspId1), new TunnelIdentifier(tunnelId1), new IPv4ExtendedTunnelIdentifier(new
38         // IPv4Address(extendedTunnelID1))));
39         // final byte[] ipv6Address = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte)
40         // 0xDE, (byte) 0xF0, (byte) 0x12,
41         // (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x9A, (byte) 0xBC, (byte) 0xDE, (byte) 0xF0 };
42         // final byte[] tunnelId2 = { (byte) 0xFF, (byte) 0xFF };
43         // final byte[] extendedTunnelID2 = { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x12, (byte) 0x34,
44         // (byte) 0x56, (byte) 0x78, (byte) 0x01,
45         // (byte) 0x23, (byte) 0x45, (byte) 0x67, (byte) 0x01, (byte) 0x23, (byte) 0x45, (byte) 0x67 };
46         // final byte[] lspId2 = { (byte) 0x12, (byte) 0x34 };
47         // assertEquals(tlvsToTest.get(9), new IPv6LSPIdentifiersTlv(new IPv6Address(ipv6Address),
48         // new LSPIdentifier(lspId2), new TunnelIdentifier(tunnelId2), new IPv6ExtendedTunnelIdentifier(new
49         // IPv6Address(extendedTunnelID2))));
50         // assertEquals(tlvsToTest.get(10), new RSVPErrorSpecTlv<IPv4Address>(new IPv4Address(ipv4Address), false, true,
51         // 0x92, 0x1602));
52         // assertEquals(tlvsToTest.get(11), new RSVPErrorSpecTlv<IPv6Address>(new IPv6Address(ipv6Address), true, false,
53         // 0xD5, 0xC5D9));
54         // assertEquals(tlvsToTest.get(12), new ReqMissingTlv(0xF7823517L));
55         // final byte[] valueBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
56         // assertEquals(tlvsToTest.get(13), new NodeIdentifierTlv(valueBytes));
57         // assertEquals(tlvsToTest.get(14), new OrderTlv(0xFFFFFFFFL, 0x00000001L));
58         // assertEquals(tlvsToTest.get(15), new OFListTlv(new ArrayList<PCEPOFCodes>() {
59         // private static final long serialVersionUID = 1L;
60         //
61         // {
62         // this.add(PCEPOFCodes.MCC);
63         // this.add(PCEPOFCodes.MCP);
64         // this.add(PCEPOFCodes.MLL);
65         // }
66         // }));
67         // assertEquals(tlvsToTest.get(16), new P2MPCapabilityTlv(2));
68         //
69         // assertArrayEquals(bytesFromFile, PCEPTlvParser.put(tlvsToTest));
70         // }
71         //
72         // @Test
73         // public void testDifferentLengthExceptions() {
74         // final byte[] bytes = { (byte) 0x00 }; // not empty but not enought data
75         // // for parsing subobjects
76         //
77         // try {
78         // LSPIdentifierIPv4TlvParser.parse(bytes);
79         // fail("");
80         // } catch (final PCEPDeserializerException e) {
81         // }
82         //
83         // try {
84         // LSPIdentifierIPv6TlvParser.parse(bytes);
85         // fail("");
86         // } catch (final PCEPDeserializerException e) {
87         // }
88         //
89         // try {
90         // PCEStatefulCapabilityTlvParser.deserializeValueField(bytes);
91         // fail("");
92         // } catch (final PCEPDeserializerException e) {
93         // }
94         //
95         // try {
96         // RSVPErrorSpecTlvParser.parse(bytes);
97         // fail("");
98         // } catch (final PCEPDeserializerException e) {
99         // }
100         //
101         // try {
102         // RSVPErrorSpecIPv6TlvParser.parse(bytes);
103         // fail("");
104         // } catch (final PCEPDeserializerException e) {
105         // }
106         //
107         // try {
108         // OFListTlvParser.parse(bytes);
109         // fail("");
110         // } catch (final PCEPDeserializerException e) {
111         // }
112         // }
113         //
114         // @Test
115         // public void testUnknownInstanceExceptions() {
116         // try {
117         // LSPIdentifierIPv4TlvParser.put(null);
118         // fail("");
119         // } catch (final IllegalArgumentException e) {
120         // }
121         //
122         // try {
123         // LSPIdentifierIPv6TlvParser.put(null);
124         // fail("");
125         // } catch (final IllegalArgumentException e) {
126         // }
127         //
128         // try {
129         // PCEStatefulCapabilityTlvParser.serializeValueField(null);
130         // fail("");
131         // } catch (final IllegalArgumentException e) {
132         // }
133         //
134         // try {
135         // RSVPErrorSpecTlvParser.put(null);
136         // fail("");
137         // } catch (final IllegalArgumentException e) {
138         // }
139         //
140         // try {
141         // RSVPErrorSpecIPv6TlvParser.put(null);
142         // fail("");
143         // } catch (final IllegalArgumentException e) {
144         // }
145         //
146         // try {
147         // OFListTlvParser.put(null);
148         // fail("");
149         // } catch (final IllegalArgumentException e) {
150         // }
151         //
152         // }
153         //
154         // @Test
155         // public void testEmptyExceptions() throws PCEPDeserializerException {
156         // final byte[] bytes = {}; // empty
157         //
158         // try {
159         // LSPIdentifierIPv4TlvParser.parse(bytes);
160         // fail("");
161         // } catch (final IllegalArgumentException e) {
162         // }
163         //
164         // try {
165         // LSPIdentifierIPv6TlvParser.parse(bytes);
166         // fail("");
167         // } catch (final IllegalArgumentException e) {
168         // }
169         //
170         // try {
171         // PCEStatefulCapabilityTlvParser.deserializeValueField(bytes);
172         // fail("");
173         // } catch (final IllegalArgumentException e) {
174         // }
175         //
176         // try {
177         // RSVPErrorSpecTlvParser.parse(bytes);
178         // fail("");
179         // } catch (final IllegalArgumentException e) {
180         // }
181         //
182         // try {
183         // RSVPErrorSpecIPv6TlvParser.parse(bytes);
184         // fail("");
185         // } catch (final IllegalArgumentException e) {
186         // }
187         //
188         // try {
189         // OFListTlvParser.parse(bytes);
190         // fail("");
191         // } catch (final IllegalArgumentException e) {
192         // }
193         // }
194 }