Merge "BUG-49 : more tests & warnings fixed."
[bgpcep.git] / bgp / parser-api / src / test / java / org / opendaylight / protocol / bgp / parser / APITest.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;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNull;
12
13 import org.junit.Test;
14 import org.opendaylight.protocol.framework.DeserializerException;
15 import org.opendaylight.protocol.framework.DocumentedException;
16
17 public class APITest {
18
19         @Test
20         public void testDocumentedException() {
21                 final DocumentedException de = new BGPDocumentedException("Some message", BGPError.BAD_BGP_ID);
22                 assertEquals("Some message", de.getMessage());
23                 assertEquals(BGPError.BAD_BGP_ID, ((BGPDocumentedException) de).getError());
24                 assertNull(((BGPDocumentedException) de).getData());
25         }
26
27         @Test
28         public void testParsingException() {
29                 final DeserializerException de = new BGPParsingException("Some message");
30                 assertEquals("Some message", de.getMessage());
31         }
32
33         @Test
34         public void testBGPError() {
35                 assertEquals(BGPError.BAD_MSG_TYPE, BGPError.forValue(1, 3));
36         }
37
38         @Test
39         public void testTerminationReason() {
40                 assertEquals(BGPError.BAD_PEER_AS.toString(), new BGPTerminationReason(BGPError.BAD_PEER_AS).getErrorMessage());
41         }
42 }