Initial framework migration to netty.
[bgpcep.git] / bgp / parser-impl / src / test / java / org / opendaylight / protocol / bgp / parser / impl / BGPUpdateMessageParserTest.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.bgp.parser.impl;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12
13 import java.io.File;
14 import java.util.List;
15 import java.util.Set;
16
17 import org.junit.Ignore;
18 import org.junit.Test;
19 import org.opendaylight.protocol.bgp.concepts.BGPObject;
20 import org.opendaylight.protocol.bgp.parser.BGPNode;
21 import org.opendaylight.protocol.bgp.parser.BGPUpdateEvent;
22 import org.opendaylight.protocol.bgp.parser.BGPUpdateMessage;
23 import org.opendaylight.protocol.bgp.parser.impl.message.BGPUpdateMessageParser;
24 import org.opendaylight.protocol.bgp.util.HexDumpBGPFileParser;
25 import org.opendaylight.protocol.util.ByteArray;
26
27 public class BGPUpdateMessageParserTest {
28
29         @Test
30         @Ignore
31         public void testNodeParsing() throws Exception {
32                 final List<byte[]> result = HexDumpBGPFileParser.parseMessages(new File(this.getClass().getResource("/bgp-update-nodes.txt").getFile()));
33                 assertEquals(1, result.size());
34                 final byte[] body = ByteArray.cutBytes(result.get(0), BGPMessageFactory.COMMON_HEADER_LENGTH);
35                 final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(result.get(0), BGPMessageFactory.MARKER_LENGTH,
36                                 BGPMessageFactory.LENGTH_FIELD_LENGTH));
37                 final BGPUpdateEvent event = BGPUpdateMessageParser.parse(body, messageLength);
38                 final BGPUpdateMessage updateMessage = (BGPUpdateMessage) event;
39                 final Set<BGPObject> addedObjects = updateMessage.getAddedObjects();
40                 assertEquals(14, addedObjects.size());
41                 assertEquals(0, updateMessage.getRemovedObjects().size());
42                 for (final BGPObject bgpObject : addedObjects) {
43                         assertTrue(bgpObject instanceof BGPNode);
44                 }
45         }
46 }