d9fcf82a2971cc70bb1bea3ebc06a4c9e83e359f
[bgpcep.git] / bgp / parser-impl / src / test / java / org / opendaylight / protocol / bgp / parser / impl / PathAttributeParserTest.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.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.fail;
13 import io.netty.buffer.Unpooled;
14
15 import org.junit.Test;
16 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
17 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
18 import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
19
20 /*
21  * To test incorrect values.
22  */
23 public class PathAttributeParserTest {
24         @Test
25         public void testOriginParser() throws Exception {
26                 try {
27                         ServiceLoaderBGPExtensionProviderContext.createConsumerContext().getAttributeRegistry().parseAttributes(Unpooled.copiedBuffer(new byte[] { 0x40, 0x01, 0x01, 0x04 }));
28                         fail("This needs to fail.");
29                 } catch (final BGPDocumentedException e) {
30                         assertEquals("Unknown Origin type.", e.getMessage());
31                         assertArrayEquals(new byte[] { 0x01, 0x01, 0x04 }, e.getData());
32                 } catch (final BGPParsingException e) {
33                         fail("This exception should not occur.");
34                 }
35         }
36 }