4e9aa25dd6f8ac28d295d0cf490bb5cf4c30eaab
[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
14 import org.junit.Before;
15 import org.junit.Test;
16 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
17 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
18
19 /*
20  * To test incorrect values.
21  */
22 public class PathAttributeParserTest {
23
24         @Before
25         public void setUp() {
26                 // Activates everything
27                 SimpleBGPMessageFactory.getInstance();
28         }
29
30         @Test
31         public void testOriginParser() {
32                 try {
33                         SimpleAttributeRegistry.getInstance().parseAttributes(new byte[] { 0x40, 0x01, 0x01, 0x04 });
34                         fail("This needs to fail.");
35                 } catch (final BGPDocumentedException e) {
36                         assertEquals("Unknown Origin type.", e.getMessage());
37                         assertArrayEquals(new byte[] { 0x01, 0x01, 0x04 }, e.getData());
38                 } catch (final BGPParsingException e) {
39                         fail("This exception should not occur.");
40                 }
41         }
42 }