BUG-47 : removed PCEPMessage interface, switched to generated Message.
[bgpcep.git] / pcep / impl / src / test / java / org / opendaylight / protocol / pcep / impl / PCEPValidatorTest.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 import static java.util.Arrays.asList;
11 import static org.junit.Assert.assertEquals;
12
13 import java.io.IOException;
14 import java.util.ArrayList;
15 import java.util.List;
16
17 import org.junit.Test;
18 import org.opendaylight.protocol.concepts.IGPMetric;
19 import org.opendaylight.protocol.concepts.IPv4;
20 import org.opendaylight.protocol.concepts.IPv4Address;
21 import org.opendaylight.protocol.concepts.TEMetric;
22 import org.opendaylight.protocol.framework.DeserializerException;
23 import org.opendaylight.protocol.framework.DocumentedException;
24 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
25 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
26 import org.opendaylight.protocol.pcep.PCEPErrors;
27 import org.opendaylight.protocol.pcep.PCEPOFCodes;
28 import org.opendaylight.protocol.pcep.PCEPObject;
29 import org.opendaylight.protocol.pcep.PCEPTlv;
30 import org.opendaylight.protocol.pcep.concepts.LSPSymbolicName;
31 import org.opendaylight.protocol.pcep.concepts.UnnumberedInterfaceIdentifier;
32 import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
33 import org.opendaylight.protocol.pcep.message.PCCreateMessage;
34 import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
35 import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
36 import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
37 import org.opendaylight.protocol.pcep.message.PCEPNotificationMessage;
38 import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
39 import org.opendaylight.protocol.pcep.message.PCEPReplyMessage;
40 import org.opendaylight.protocol.pcep.message.PCEPReportMessage;
41 import org.opendaylight.protocol.pcep.message.PCEPRequestMessage;
42 import org.opendaylight.protocol.pcep.message.PCEPUpdateRequestMessage;
43 import org.opendaylight.protocol.pcep.object.CompositeErrorObject;
44 import org.opendaylight.protocol.pcep.object.CompositeInstantiationObject;
45 import org.opendaylight.protocol.pcep.object.CompositeNotifyObject;
46 import org.opendaylight.protocol.pcep.object.CompositePathObject;
47 import org.opendaylight.protocol.pcep.object.CompositeReplySvecObject;
48 import org.opendaylight.protocol.pcep.object.CompositeRequestObject;
49 import org.opendaylight.protocol.pcep.object.CompositeRequestSvecObject;
50 import org.opendaylight.protocol.pcep.object.CompositeResponseObject;
51 import org.opendaylight.protocol.pcep.object.CompositeRptPathObject;
52 import org.opendaylight.protocol.pcep.object.CompositeStateReportObject;
53 import org.opendaylight.protocol.pcep.object.CompositeUpdPathObject;
54 import org.opendaylight.protocol.pcep.object.CompositeUpdateRequestObject;
55 import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
56 import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
57 import org.opendaylight.protocol.pcep.object.PCEPEndPointsObject;
58 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
59 import org.opendaylight.protocol.pcep.object.PCEPExcludeRouteObject;
60 import org.opendaylight.protocol.pcep.object.PCEPExistingPathBandwidthObject;
61 import org.opendaylight.protocol.pcep.object.PCEPExplicitRouteObject;
62 import org.opendaylight.protocol.pcep.object.PCEPGlobalConstraintsObject;
63 import org.opendaylight.protocol.pcep.object.PCEPIncludeRouteObject;
64 import org.opendaylight.protocol.pcep.object.PCEPLoadBalancingObject;
65 import org.opendaylight.protocol.pcep.object.PCEPLspObject;
66 import org.opendaylight.protocol.pcep.object.PCEPLspaObject;
67 import org.opendaylight.protocol.pcep.object.PCEPMetricObject;
68 import org.opendaylight.protocol.pcep.object.PCEPNoPathObject;
69 import org.opendaylight.protocol.pcep.object.PCEPNotificationObject;
70 import org.opendaylight.protocol.pcep.object.PCEPObjectiveFunctionObject;
71 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
72 import org.opendaylight.protocol.pcep.object.PCEPReportedRouteObject;
73 import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
74 import org.opendaylight.protocol.pcep.object.PCEPRequestedPathBandwidthObject;
75 import org.opendaylight.protocol.pcep.object.PCEPSvecObject;
76 import org.opendaylight.protocol.pcep.spi.PCEPMessageType;
77 import org.opendaylight.protocol.pcep.spi.RawMessage;
78 import org.opendaylight.protocol.pcep.subobject.EROAsNumberSubobject;
79 import org.opendaylight.protocol.pcep.subobject.EROUnnumberedInterfaceSubobject;
80 import org.opendaylight.protocol.pcep.subobject.ExcludeRouteSubobject;
81 import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
82 import org.opendaylight.protocol.pcep.subobject.RROUnnumberedInterfaceSubobject;
83 import org.opendaylight.protocol.pcep.subobject.ReportedRouteSubobject;
84 import org.opendaylight.protocol.pcep.subobject.XROAsNumberSubobject;
85 import org.opendaylight.protocol.pcep.tlv.LSPStateDBVersionTlv;
86 import org.opendaylight.protocol.pcep.tlv.LSPSymbolicNameTlv;
87 import org.opendaylight.protocol.pcep.tlv.PCEStatefulCapabilityTlv;
88 import org.opendaylight.protocol.util.ByteArray;
89 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
90 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.concepts.rev130930.Bandwidth;
91 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
92
93 import com.google.common.collect.Lists;
94
95 public class PCEPValidatorTest {
96
97         private static final PCEPLspaObject lspa = new PCEPLspaObject(0L, 0L, 0L, (short) 0, (short) 0, false, false, false, false);
98
99         private final List<ExplicitRouteSubobject> eroSubobjects = asList(
100                         new EROAsNumberSubobject(new AsNumber(0xFFFFL), false),
101                         new EROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] { (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33 }), new UnnumberedInterfaceIdentifier(0x00FF00FF), false));
102
103         private final List<ReportedRouteSubobject> rroSubobjects = asList((ReportedRouteSubobject) new RROUnnumberedInterfaceSubobject(new IPv4Address(new byte[] {
104                         (byte) 0x00, (byte) 0x11, (byte) 0x22, (byte) 0x33 }), new UnnumberedInterfaceIdentifier(0x00FF00FF)));
105
106         private final List<Long> requestIds = asList(0x000001L);
107
108         private final IPv4Address ip4addr = new IPv4Address(new byte[] { (byte) 0xFF, 0x00, 0x00, 0x01 });
109
110         private final PCEPSvecObject svecObj = new PCEPSvecObject(true, true, true, false, false, PCEPValidatorTest.this.requestIds, true);
111
112         private final PCEPRequestParameterObject requestParameter = new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, true, false);
113
114         // private final PCEPEndPointsObject<IPv4Address> endPoints = new
115         // PCEPEndPointsObject<IPv4Address>(this.ip4addr, this.ip4addr);
116
117         private final PCEPEndPointsObject<IPv4Address> endPoints = new PCEPEndPointsObject<IPv4Address>(this.ip4addr, this.ip4addr);
118
119         private static final RawPCEPMessageFactory msgFactory = new RawPCEPMessageFactory();
120
121         // private final PCEPClassTypeObject classType = new
122         // PCEPClassTypeObject((short) 7);
123         // private final PCEPClassTypeObjectProvider classTypeProvider = new
124         // PCEPClassTypeObjectProvider((short) 7, true);
125
126         private static List<Message> deserMsg(final String srcFile) throws IOException, DeserializerException, DocumentedException,
127                         PCEPDeserializerException {
128                 final byte[] bytesFromFile = ByteArray.fileToBytes(srcFile);
129                 final RawMessage rawMessage = (RawMessage) msgFactory.parse(bytesFromFile).get(0);
130
131                 return PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects());
132         }
133
134         @Test
135         public void testOpenMessageValidationFromBin() throws IOException, DeserializerException, DocumentedException,
136                         PCEPDeserializerException {
137                 assertEquals(
138                                 deserMsg("src/test/resources/PCEPOpenMessage1.bin").toString(),
139                                 asList(
140                                                 new PCEPOpenMessage(new PCEPOpenObject(30, 120, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
141                                                                 new LSPStateDBVersionTlv(0x80))))).toString());
142
143                 assertEquals(deserMsg("src/test/resources/Open.1.bin").toString(),
144                                 asList(new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1))).toString());
145
146                 assertEquals(
147                                 deserMsg("src/test/resources/Open.3.bin").toString(),
148                                 asList(
149                                                 new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
150                                                                 new LSPStateDBVersionTlv(53))))).toString());
151         }
152
153         @Test
154         public void testKeepAliveMessageValidationFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
155                         DeserializerException, DocumentedException {
156                 assertEquals(deserMsg("src/test/resources/PCEPKeepAliveMessage1.bin").toString(),
157                                 asList((Message) new PCEPKeepAliveMessage()).toString());
158                 assertEquals(deserMsg("src/test/resources/Keepalive.1.bin").toString(), asList(new PCEPKeepAliveMessage()).toString());
159         }
160
161         @Test
162         public void testCloseMsg() throws PCEPDeserializerException, IOException, PCEPDocumentedException, DeserializerException,
163                         DocumentedException {
164                 assertEquals(deserMsg("src/test/resources/PCEPCloseMessage1.bin").toString(),
165                                 asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.TOO_MANY_UNKNOWN_MSG))).toString());
166                 assertEquals(deserMsg("src/test/resources/Close.1.bin").toString(),
167                                 asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.UNKNOWN))).toString());
168         }
169
170         @Test
171         public void testRequestMessageValidationFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
172                         DeserializerException, DocumentedException {
173                 List<CompositeRequestObject> requests = new ArrayList<CompositeRequestObject>();
174                 final byte[] ipAdress = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
175                 requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 5, 0xDEADBEEFL, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress), new IPv4Address(ipAdress))));
176                 PCEPRequestMessage specMessage = new PCEPRequestMessage(requests);
177                 List<Message> deserMsgs = deserMsg("src/test/resources/PCEPRequestMessage1.bin");
178                 final List<Message> specMessages = Lists.newArrayList();
179                 specMessages.add(specMessage);
180
181                 assertEquals(deserMsgs.toString(), specMessages.toString());
182
183                 requests = new ArrayList<CompositeRequestObject>();
184                 final byte[] ipAdress2 = { (byte) 0x7F, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
185                 requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress2))));
186                 specMessage = new PCEPRequestMessage(requests);
187                 deserMsgs = deserMsg("src/test/resources/PCReq.1.bin");
188                 specMessages.clear();
189                 specMessages.add(specMessage);
190                 assertEquals(deserMsgs.toString(), specMessages.toString());
191
192                 requests = new ArrayList<CompositeRequestObject>();
193                 requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, new PCEPLoadBalancingObject(3, new Bandwidth(ByteArray.floatToBytes((float) 1024.75)), false)));
194                 specMessage = new PCEPRequestMessage(requests);
195                 deserMsgs = deserMsg("src/test/resources/PCReq.2.bin");
196                 specMessages.clear();
197                 specMessages.add(specMessage);
198                 assertEquals(deserMsgs.toString(), specMessages.toString());
199
200                 requests = new ArrayList<CompositeRequestObject>();
201                 requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, new PCEPLspObject(1, false, false, true, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false, false), new ArrayList<PCEPMetricObject>() {
202                         private static final long serialVersionUID = 1L;
203
204                         {
205                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(53L), false, false));
206                         }
207                 }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3)), false)));
208
209                 List<CompositeRequestSvecObject> svecList = new ArrayList<CompositeRequestSvecObject>();
210                 svecList.add(new CompositeRequestSvecObject(new PCEPSvecObject(true, false, false, false, false, this.requestIds, false)));
211
212                 specMessage = new PCEPRequestMessage(svecList, requests);
213                 deserMsgs = deserMsg("src/test/resources/PCReq.3.bin");
214                 specMessages.clear();
215                 specMessages.add(specMessage);
216                 // FIXME BUG-89
217                 // assertEquals(deserMsgs, specMessages);
218
219                 specMessages.clear();
220                 requests = new ArrayList<CompositeRequestObject>();
221                 requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, null));
222                 specMessages.add(new PCEPRequestMessage(requests));
223
224                 final byte[] ipAdress3 = { (byte) 0x7F, (byte) 0x00, (byte) 0x30, (byte) 0x01 };
225                 requests = new ArrayList<CompositeRequestObject>();
226                 requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 4, 1, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress3), new IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, null));
227                 specMessages.add(new PCEPRequestMessage(requests));
228
229                 final byte[] ipAdress4 = { (byte) 0x7F, (byte) 0x30, (byte) 0x00, (byte) 0x01 };
230                 requests = new ArrayList<CompositeRequestObject>();
231                 requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress4)), null, null, null, null, null, null, null, null, null));
232                 specMessages.add(new PCEPRequestMessage(requests));
233
234                 final byte[] ipAdress5 = { (byte) 0x7F, (byte) 0xd0, (byte) 0x00, (byte) 0x01 };
235                 requests = new ArrayList<CompositeRequestObject>();
236                 requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 1, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress5), new IPv4Address(ipAdress5)), null, null, null, null, null, null, null, null, null));
237
238                 specMessages.add(new PCEPRequestMessage(requests));
239                 deserMsgs = deserMsg("src/test/resources/PCReq.4.bin");
240                 assertEquals(deserMsgs.toString(), specMessages.toString());
241
242                 specMessages.clear();
243                 svecList = new ArrayList<CompositeRequestSvecObject>();
244                 svecList.add(new CompositeRequestSvecObject(new PCEPSvecObject(true, false, false, false, false, this.requestIds, false)));
245                 svecList.add(new CompositeRequestSvecObject(new PCEPSvecObject(false, true, true, false, false, this.requestIds, false), new PCEPObjectiveFunctionObject(PCEPOFCodes.MCC, true, false), new PCEPGlobalConstraintsObject((short) 0x55, (short) 1, (short) 100, (short) 0x26, true, false), new PCEPExcludeRouteObject(new ArrayList<ExcludeRouteSubobject>() {
246                         private static final long serialVersionUID = 1L;
247
248                         {
249                                 this.add(new XROAsNumberSubobject(new AsNumber((long) 0x12), true));
250                         }
251                 }, true, true, false), new ArrayList<PCEPMetricObject>() {
252                         private static final long serialVersionUID = 1L;
253
254                         {
255                                 this.add(new PCEPMetricObject(true, true, new TEMetric(123456L), true, false));
256                         }
257                 }));
258
259                 requests = new ArrayList<CompositeRequestObject>();
260                 requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false, false), new ArrayList<PCEPMetricObject>() {
261                         private static final long serialVersionUID = 1L;
262
263                         {
264                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(53L), false, false));
265                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(5335L), false, false));
266                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(128256), false, false));
267                         }
268                 }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3)), false)));
269
270                 final byte[] ipAdress6 = { (byte) 0x7F, (byte) 0xF0, (byte) 0x00, (byte) 0x01 };
271                 specMessages.add(new PCEPRequestMessage(svecList, requests));
272
273                 requests = new ArrayList<CompositeRequestObject>();
274                 requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress6), new IPv4Address(ipAdress6)), null, null, PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false, false), new ArrayList<PCEPMetricObject>() {
275                         private static final long serialVersionUID = 1L;
276
277                         {
278                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(53L), false, false));
279                         }
280                 }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3f)), false)));
281                 deserMsgs = deserMsg("src/test/resources/PCReq.5.bin");
282                 specMessages.add(new PCEPRequestMessage(svecList, requests));
283                 // FIXME
284                 // assertEquals(deserMsgs, specMessages);
285
286                 // FIXME: need construct with invalid processed parameter
287                 // assertEquals(deserMsg("src/test/resources/PCReq.6.invalid.bin"),
288                 // asList(
289                 // new PCEPErrorMessage(new CompositeErrorObject(new
290                 // PCEPRequestParameterObject(true, false, false, false, false, false,
291                 // false, false, (short) 3,
292                 // 1L, false, false), new PCEPErrorObject(PCEPErrors.P_FLAG_NOT_SET))),
293                 // new PCEPRequestMessage(asList(new
294                 // CompositeRequestObject(this.requestParameter, new
295                 // PCEPEndPointsObject<IPv4Address>(IPv4Address
296                 // .getNetworkAddressFactory().getNetworkAddressForBytes(new byte[] {
297                 // 127, 0, 0, 1 }), IPv4Address.getNetworkAddressFactory()
298                 // .getNetworkAddressForBytes(new byte[] { 127, 0, 0, 1 })), null, null,
299                 // null, null, null, null, null, null, new PCEPLoadBalancingObject(
300                 // 3, new Bandwidth(1024.75), false))))));
301
302         }
303
304         @Test
305         public void testRequestMessageValidationFromRawMsg() throws PCEPDeserializerException {
306                 List<PCEPObject> objs = new ArrayList<PCEPObject>();
307                 List<Message> msgs;
308                 PCEPRequestParameterObject tmpRP;
309
310                 // test unrecognized object in svec list
311                 objs.add(this.svecObj);
312                 objs.add(new UnknownObject(true, false, PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
313                 objs.add(new PCEPSvecObject(true, true, true, false, false, PCEPValidatorTest.this.requestIds, true));
314
315                 msgs = PCEPMessageValidator.getValidator(PCEPMessageType.REQUEST).validate(objs);
316
317                 assertEquals(msgs.get(0).toString(), new PCEPErrorMessage(new ArrayList<PCEPErrorObject>() {
318                         private static final long serialVersionUID = 1L;
319
320                         {
321                                 this.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
322                         }
323                 }).toString());
324
325                 // test with request p flag not set and ignoracion of more than one
326                 // end-points objects
327                 objs = new ArrayList<PCEPObject>();
328                 objs.add(this.svecObj);
329                 objs.add(this.svecObj);
330                 tmpRP = new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false);
331                 objs.add(tmpRP);
332                 objs.add(this.endPoints);
333
334                 objs.add(this.requestParameter);
335                 objs.add(this.endPoints);
336                 objs.add(this.endPoints);
337                 // FIXME:mv use object constructor with set processed flag
338                 // objs.add(this.classTypeProvider);
339                 // objs.add(this.requestParameter);
340                 // objs.add(this.endPointsProvider);
341                 // objs.add(new PCEPClassTypeObjectProvider((short) 7, false));
342
343                 msgs = PCEPMessageValidator.getValidator(PCEPMessageType.REQUEST).validate(objs);
344                 // FIXME:mv use object constructor with set processed flag
345                 // assertEquals(msgs.get(0), new PCEPErrorMessage(new
346                 // CompositeErrorObject(tmpRP, new
347                 // PCEPErrorObject(PCEPErrors.P_FLAG_NOT_SET))));
348                 // assertEquals(
349                 // msgs.get(1),
350                 // new PCEPRequestMessage(asList(new
351                 // CompositeRequestSvecObject(this.svecObj), new
352                 // CompositeRequestSvecObject(this.svecObj)), Util
353                 // .asList(new CompositeRequestObject(this.requestParameter,
354                 // this.endPoints, this.classType, null, null, null, null, null, null,
355                 // null,
356                 // null))));
357                 // assertEquals(msgs.get(2), new PCEPErrorMessage(new
358                 // CompositeErrorObject(tmpRP, new
359                 // PCEPErrorObject(PCEPErrors.P_FLAG_NOT_SET))));
360         }
361
362         @Test
363         public void testReplyMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
364                         DeserializerException, DocumentedException {
365
366                 List<PCEPReplyMessage> specMessages = new ArrayList<PCEPReplyMessage>();
367                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 5, 0xDEADBEEFL, true, true)))));
368                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, false, false, false, false, false, (short) 7, 0x12345678L, false, false)))));
369                 assertEquals(deserMsg("src/test/resources/PCEPReplyMessage1.bin").toString(), specMessages.toString());
370
371                 specMessages = new ArrayList<PCEPReplyMessage>();
372                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false)))));
373                 assertEquals(deserMsg("src/test/resources/PCRep.1.bin").toString(), specMessages.toString());
374
375                 specMessages = new ArrayList<PCEPReplyMessage>();
376                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false)))));
377                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 5, 2, false, false), new PCEPNoPathObject((short) 0, false, false), null, null, null, null, null, null))));
378                 assertEquals(deserMsg("src/test/resources/PCRep.2.bin").toString(), specMessages.toString());
379
380                 specMessages = new ArrayList<PCEPReplyMessage>();
381                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false), new PCEPNoPathObject((short) 1, true, false), new PCEPLspObject(1, true, true, false, true), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
382                         private static final long serialVersionUID = 1L;
383
384                         {
385                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(234), false, false));
386                         }
387                 }, new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new ArrayList<CompositePathObject>() {
388                         private static final long serialVersionUID = 1L;
389
390                         {
391                                 this.add(new CompositePathObject(new PCEPExplicitRouteObject(PCEPValidatorTest.this.eroSubobjects, false), lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
392                                         private static final long serialVersionUID = 1L;
393
394                                         {
395                                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(234L), false, false));
396                                         }
397                                 }, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
398                         }
399                 }))));
400                 // FIXME BUG-89
401                 // assertEquals(deserMsg("src/test/resources/PCRep.3.bin"), specMessages);
402
403                 specMessages = new ArrayList<PCEPReplyMessage>();
404                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 7, 1, false, false)))));
405                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 2, false, false)))));
406                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 2, 4, false, false)))));
407                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 3, 4, false, false)))));
408                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 6, 5, false, false)))));
409                 assertEquals(deserMsg("src/test/resources/PCRep.4.bin").toString(), specMessages.toString());
410
411                 specMessages = new ArrayList<PCEPReplyMessage>();
412                 final List<Long> requestIDs = new ArrayList<Long>();
413                 requestIDs.add(0x25069045L);
414
415                 final List<PCEPMetricObject> metrics = new ArrayList<PCEPMetricObject>();
416                 metrics.add(new PCEPMetricObject(true, true, new IGPMetric(234L), true, false));
417
418                 final List<CompositeReplySvecObject> svecList = new ArrayList<CompositeReplySvecObject>();
419                 svecList.add(new CompositeReplySvecObject(new PCEPSvecObject(true, true, true, false, false, requestIDs, true), new PCEPObjectiveFunctionObject(PCEPOFCodes.MCC, true, false), metrics));
420
421                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false), new PCEPNoPathObject((short) 1, true, false), null, PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
422                         private static final long serialVersionUID = 1L;
423
424                         {
425                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(234), false, false));
426                         }
427                 }, new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new ArrayList<CompositePathObject>() {
428                         private static final long serialVersionUID = 1L;
429
430                         {
431                                 this.add(new CompositePathObject(new PCEPExplicitRouteObject(PCEPValidatorTest.this.eroSubobjects, false), lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
432                                         private static final long serialVersionUID = 1L;
433
434                                         {
435                                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(234L), false, false));
436                                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(5355L), false, false));
437                                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(5353L), false, false));
438                                         }
439                                 }, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
440                         }
441                 })), svecList));
442                 specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false), new PCEPNoPathObject((short) 1, true, false), null, PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
443                         private static final long serialVersionUID = 1L;
444
445                         {
446                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(234), false, false));
447                         }
448                 }, new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new ArrayList<CompositePathObject>() {
449                         private static final long serialVersionUID = 1L;
450
451                         {
452                                 this.add(new CompositePathObject(new PCEPExplicitRouteObject(PCEPValidatorTest.this.eroSubobjects, false), lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
453                                         private static final long serialVersionUID = 1L;
454
455                                         {
456                                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(234L), false, false));
457                                         }
458                                 }, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
459                                 this.add(new CompositePathObject(new PCEPExplicitRouteObject(PCEPValidatorTest.this.eroSubobjects, false), lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
460                                         private static final long serialVersionUID = 1L;
461
462                                         {
463                                                 this.add(new PCEPMetricObject(true, true, new IGPMetric(234L), false, false));
464                                         }
465                                 }, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
466                         }
467                 })), svecList));
468                 assertEquals(deserMsg("src/test/resources/PCRep.5.bin").toString(), specMessages.toString());
469         }
470
471         @Test
472         public void testUpdMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
473                         DeserializerException, DocumentedException {
474                 List<Message> specMessages = Lists.newArrayList();
475
476                 List<CompositeUpdateRequestObject> requests = new ArrayList<CompositeUpdateRequestObject>();
477                 requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
478
479                 specMessages.add(new PCEPUpdateRequestMessage(requests));
480                 assertEquals(deserMsg("src/test/resources/PCUpd.1.bin").toString(), specMessages.toString());
481
482                 specMessages = Lists.newArrayList();
483                 List<CompositeUpdPathObject> paths = new ArrayList<CompositeUpdPathObject>();
484                 paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, null, null));
485                 requests = new ArrayList<CompositeUpdateRequestObject>();
486                 requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
487                 specMessages.add(new PCEPUpdateRequestMessage(requests));
488                 assertEquals(deserMsg("src/test/resources/PCUpd.2.bin").toString(), specMessages.toString());
489
490                 specMessages = Lists.newArrayList();
491                 paths = new ArrayList<CompositeUpdPathObject>();
492                 paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new ArrayList<PCEPMetricObject>() {
493                         private static final long serialVersionUID = 1L;
494
495                         {
496                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
497                         }
498                 }));
499                 requests = new ArrayList<CompositeUpdateRequestObject>();
500                 requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
501                 specMessages.add(new PCEPUpdateRequestMessage(requests));
502                 assertEquals(deserMsg("src/test/resources/PCUpd.3.bin").toString(), specMessages.toString());
503
504                 specMessages = Lists.newArrayList();
505                 requests = new ArrayList<CompositeUpdateRequestObject>();
506                 requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
507                 requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
508                 specMessages.add(new PCEPUpdateRequestMessage(requests));
509                 assertEquals(deserMsg("src/test/resources/PCUpd.4.bin").toString(), specMessages.toString());
510
511                 specMessages = Lists.newArrayList();
512                 requests = new ArrayList<CompositeUpdateRequestObject>();
513                 requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
514                 paths = new ArrayList<CompositeUpdPathObject>();
515                 paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new ArrayList<PCEPMetricObject>() {
516                         private static final long serialVersionUID = 1L;
517
518                         {
519                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
520                         }
521                 }));
522                 requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
523                 paths = new ArrayList<CompositeUpdPathObject>();
524                 paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new ArrayList<PCEPMetricObject>() {
525                         private static final long serialVersionUID = 1L;
526
527                         {
528                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
529                         }
530                 }));
531                 paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new ArrayList<PCEPMetricObject>() {
532                         private static final long serialVersionUID = 1L;
533
534                         {
535                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
536                         }
537                 }));
538                 paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new ArrayList<PCEPMetricObject>() {
539                         private static final long serialVersionUID = 1L;
540
541                         {
542                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
543                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
544                         }
545                 }));
546                 requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
547                 specMessages.add(new PCEPUpdateRequestMessage(requests));
548                 assertEquals(deserMsg("src/test/resources/PCUpd.5.bin").toString(), specMessages.toString());
549         }
550
551         @Test
552         public void testRptMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
553                         DeserializerException, DocumentedException {
554                 List<Message> specMessages = Lists.newArrayList();
555                 List<CompositeStateReportObject> reports = new ArrayList<CompositeStateReportObject>();
556                 reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
557                 specMessages.add(new PCEPReportMessage(reports));
558                 assertEquals(deserMsg("src/test/resources/PCRpt.1.bin").toString(), specMessages.toString());
559
560                 specMessages = Lists.newArrayList();
561                 List<CompositeRptPathObject> paths = new ArrayList<CompositeRptPathObject>();
562                 paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, null, null, null));
563                 reports = new ArrayList<CompositeStateReportObject>();
564                 reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
565                 specMessages.add(new PCEPReportMessage(reports));
566                 assertEquals(deserMsg("src/test/resources/PCRpt.2.bin").toString(), specMessages.toString());
567
568                 specMessages = Lists.newArrayList();
569                 paths = new ArrayList<CompositeRptPathObject>();
570                 paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
571                         private static final long serialVersionUID = 1L;
572
573                         {
574                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
575                         }
576                 }));
577
578                 reports = new ArrayList<CompositeStateReportObject>();
579                 reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
580                 specMessages.add(new PCEPReportMessage(reports));
581
582                 // FIXME
583                 // assertEquals(deserMsg("src/test/resources/PCRpt.3.bin"), specMessages);
584
585                 specMessages = Lists.newArrayList();
586                 reports = new ArrayList<CompositeStateReportObject>();
587                 reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
588                 reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
589                 reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
590                 specMessages.add(new PCEPReportMessage(reports));
591                 assertEquals(deserMsg("src/test/resources/PCRpt.4.bin").toString(), specMessages.toString());
592
593                 specMessages = Lists.newArrayList();
594                 reports = new ArrayList<CompositeStateReportObject>();
595                 paths = new ArrayList<CompositeRptPathObject>();
596                 paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
597                         private static final long serialVersionUID = 1L;
598
599                         {
600                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
601                         }
602                 }));
603                 reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
604                 paths = new ArrayList<CompositeRptPathObject>();
605                 paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
606                         private static final long serialVersionUID = 1L;
607
608                         {
609                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
610                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
611                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
612                         }
613                 }));
614                 paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
615                         private static final long serialVersionUID = 1L;
616
617                         {
618                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
619                         }
620                 }));
621                 reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
622                 specMessages.add(new PCEPReportMessage(reports));
623                 // FIXME
624                 // assertEquals(deserMsg("src/test/resources/PCRpt.5.bin").toString(), specMessages.toString());
625         }
626
627         @Test
628         public void testPCCreateMessage() throws DeserializerException, DocumentedException, PCEPDeserializerException {
629                 final List<CompositeInstantiationObject> insts = new ArrayList<CompositeInstantiationObject>();
630                 final List<ExplicitRouteSubobject> subs = new ArrayList<ExplicitRouteSubobject>();
631                 subs.add(new EROAsNumberSubobject(new AsNumber((long) 10), false));
632                 final List<PCEPTlv> tlvs = new ArrayList<PCEPTlv>();
633                 final LSPSymbolicNameTlv tlv = new LSPSymbolicNameTlv(new LSPSymbolicName(new byte[] { 5, 4 }));
634                 tlvs.add(tlv);
635                 insts.add(new CompositeInstantiationObject(new PCEPEndPointsObject<IPv4Address>(IPv4.FAMILY.addressForString("127.0.0.2"), IPv4.FAMILY.addressForString("127.0.0.1")), PCEPValidatorTest.lspa, new PCEPExplicitRouteObject(subs, true), null, new ArrayList<PCEPMetricObject>() {
636                         private static final long serialVersionUID = 1L;
637
638                         {
639                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
640                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
641                                 this.add(new PCEPMetricObject(true, false, new IGPMetric(4L), false, false));
642                         }
643                 }));
644                 final PCCreateMessage msg = new PCCreateMessage(insts);
645
646                 final byte[] bytes = msgFactory.put(msg);
647
648                 // FIXME: need construct with invalid processed parameter
649                 final RawMessage rawMessage = (RawMessage) msgFactory.parse(bytes).get(0);
650
651                 assertEquals(PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects()).toString(),
652                                 asList((Message) msg).toString());
653         }
654
655         @Test
656         public void testNotificationValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
657                         DeserializerException, DocumentedException {
658                 List<CompositeNotifyObject> notifications = new ArrayList<CompositeNotifyObject>();
659                 List<PCEPNotificationObject> notificationsList = new ArrayList<PCEPNotificationObject>();
660                 notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
661                 notifications.add(new CompositeNotifyObject(notificationsList));
662                 PCEPNotificationMessage specMessage = new PCEPNotificationMessage(notifications);
663                 assertEquals(deserMsg("src/test/resources/PCNtf.1.bin").toString(), asList((Message) specMessage).toString());
664
665                 notifications = new ArrayList<CompositeNotifyObject>();
666                 notificationsList = new ArrayList<PCEPNotificationObject>();
667                 notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
668                 List<PCEPRequestParameterObject> requestsList = new ArrayList<PCEPRequestParameterObject>();
669                 requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false));
670                 notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
671                 specMessage = new PCEPNotificationMessage(notifications);
672                 assertEquals(deserMsg("src/test/resources/PCNtf.2.bin").toString(), asList((Message) specMessage).toString());
673
674                 notifications = new ArrayList<CompositeNotifyObject>();
675                 notificationsList = new ArrayList<PCEPNotificationObject>();
676                 notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
677                 requestsList = new ArrayList<PCEPRequestParameterObject>();
678                 requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 10, false, false));
679                 notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
680                 specMessage = new PCEPNotificationMessage(notifications);
681                 assertEquals(deserMsg("src/test/resources/PCNtf.3.bin").toString(), asList((Message) specMessage).toString());
682
683                 notifications = new ArrayList<CompositeNotifyObject>();
684                 notificationsList = new ArrayList<PCEPNotificationObject>();
685                 notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
686                 notificationsList.add(new PCEPNotificationObject((short) 1, (short) 2));
687                 notificationsList.add(new PCEPNotificationObject((short) 2, (short) 1));
688                 notificationsList.add(new PCEPNotificationObject((short) 2, (short) 2));
689                 notifications.add(new CompositeNotifyObject(notificationsList));
690                 specMessage = new PCEPNotificationMessage(notifications);
691                 assertEquals(deserMsg("src/test/resources/PCNtf.4.bin").toString(), asList((Message) specMessage).toString());
692
693                 notifications = new ArrayList<CompositeNotifyObject>();
694                 notificationsList = new ArrayList<PCEPNotificationObject>();
695                 notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
696                 requestsList = new ArrayList<PCEPRequestParameterObject>();
697                 requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 10, false, false));
698                 notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
699                 notificationsList = new ArrayList<PCEPNotificationObject>();
700                 notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
701                 notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
702                 requestsList = new ArrayList<PCEPRequestParameterObject>();
703                 requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 10, false, false));
704                 requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 10, false, false));
705                 notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
706                 specMessage = new PCEPNotificationMessage(notifications);
707                 assertEquals(deserMsg("src/test/resources/PCNtf.5.bin").toString(), asList((Message) specMessage).toString());
708         }
709
710         @Test
711         public void testErrorMessageValidatoinFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
712                         DeserializerException, DocumentedException {
713                 List<PCEPErrorObject> errorsList = new ArrayList<PCEPErrorObject>();
714                 errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
715
716                 PCEPErrorMessage specMessage = new PCEPErrorMessage(errorsList);
717                 assertEquals(deserMsg("src/test/resources/PCErr.1.bin").toString(), asList((Message) specMessage).toString());
718
719                 List<PCEPRequestParameterObject> requests = new ArrayList<PCEPRequestParameterObject>();
720                 requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false));
721
722                 List<CompositeErrorObject> errors = new ArrayList<CompositeErrorObject>();
723                 errors.add(new CompositeErrorObject(requests, errorsList));
724
725                 specMessage = new PCEPErrorMessage(errors);
726                 assertEquals(deserMsg("src/test/resources/PCErr.2.bin").toString(), asList((Message) specMessage).toString());
727
728                 specMessage = new PCEPErrorMessage(new PCEPOpenObject(0, 0, 0), errorsList, null);
729                 assertEquals(deserMsg("src/test/resources/PCErr.3.bin").toString(), asList((Message) specMessage).toString());
730
731                 requests = new ArrayList<PCEPRequestParameterObject>();
732                 requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 53, false, false));
733
734                 errors = new ArrayList<CompositeErrorObject>();
735                 errors.add(new CompositeErrorObject(requests, errorsList));
736
737                 specMessage = new PCEPErrorMessage(errors);
738                 assertEquals(deserMsg("src/test/resources/PCErr.3b.bin").toString(), asList((Message) specMessage).toString());
739
740                 errorsList = new ArrayList<PCEPErrorObject>();
741                 errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
742                 errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
743                 errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
744
745                 specMessage = new PCEPErrorMessage(null, errorsList, null);
746                 assertEquals(deserMsg("src/test/resources/PCErr.4.bin").toString(), asList((Message) specMessage).toString());
747
748                 requests = new ArrayList<PCEPRequestParameterObject>();
749                 requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 53, false, false));
750
751                 errorsList = new ArrayList<PCEPErrorObject>();
752                 errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
753
754                 errors = new ArrayList<CompositeErrorObject>();
755                 errors.add(new CompositeErrorObject(requests, errorsList));
756                 errors.add(new CompositeErrorObject(requests, errorsList));
757
758                 specMessage = new PCEPErrorMessage(errors);
759                 assertEquals(deserMsg("src/test/resources/PCErr.5.bin").toString(), asList((Message) specMessage).toString());
760         }
761 }