Do not rely on deprecated classes directly 77/2977/3
authorRobert Varga <rovarga@cisco.com>
Fri, 22 Nov 2013 06:34:01 +0000 (07:34 +0100)
committerRobert Varga <rovarga@cisco.com>
Fri, 22 Nov 2013 08:46:02 +0000 (09:46 +0100)
Change-Id: Ifeabc5220952aa6cee16a193875ff5b17d508faa
Signed-off-by: Robert Varga <rovarga@cisco.com>
bgp/parser-api/src/main/java/org/opendaylight/protocol/bgp/parser/BGPMessageFactory.java
bgp/parser-api/src/test/java/org/opendaylight/protocol/bgp/parser/APITest.java
bgp/parser-impl/src/main/java/org/opendaylight/protocol/bgp/parser/impl/BGPMessageFactoryImpl.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/ComplementaryTest.java
bgp/parser-impl/src/test/java/org/opendaylight/protocol/bgp/parser/impl/ParserTest.java
bgp/parser-mock/src/main/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMock.java
bgp/parser-mock/src/test/java/org/opendaylight/protocol/bgp/parser/mock/BGPMessageParserMockTest.java
bgp/rib-impl-config/src/main/java/org/opendaylight/controller/config/yang/bgp/rib/impl/BGPMessageFactoryImplModule.java
bgp/rib-mock/src/main/java/org/opendaylight/protocol/bgp/rib/mock/BGPMock.java
bgp/testtool/src/test/java/org/opendaylight/protocol/bgp/testtool/BGPSpeakerMock.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPByteToMessageDecoder.java

index 1c25f27768cfcb9927949500fa001a39a71f2f48..7406943cca040af5ee7235466dcb54b4c3925515 100644 (file)
@@ -14,5 +14,6 @@ import org.opendaylight.yangtools.yang.binding.Notification;
  * Interface to expose BGP specific MessageFactory.
  */
 public interface BGPMessageFactory extends ProtocolMessageFactory<Notification> {
-
+       @Override
+       public Notification parse(final byte[] bytes) throws BGPParsingException, BGPDocumentedException;
 }
index db2485088c83a36cb3fdb7823bf32478b54b56bc..7fa2d036ad10a4453f8b33c86b2cfbbd16b9cd8d 100644 (file)
@@ -11,22 +11,20 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNull;
 
 import org.junit.Test;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
 
 public class APITest {
 
        @Test
        public void testDocumentedException() {
-               final DocumentedException de = new BGPDocumentedException("Some message", BGPError.BAD_BGP_ID);
+               final BGPDocumentedException de = new BGPDocumentedException("Some message", BGPError.BAD_BGP_ID);
                assertEquals("Some message", de.getMessage());
-               assertEquals(BGPError.BAD_BGP_ID, ((BGPDocumentedException) de).getError());
-               assertNull(((BGPDocumentedException) de).getData());
+               assertEquals(BGPError.BAD_BGP_ID, de.getError());
+               assertNull(de.getData());
        }
 
        @Test
        public void testParsingException() {
-               final DeserializerException de = new BGPParsingException("Some message");
+               final BGPParsingException de = new BGPParsingException("Some message");
                assertEquals("Some message", de.getMessage());
        }
 
index 15eca5fe03a9e6bcdf877464407d13ef5716851d..1b591555430820dd65cf1c4a413ecde61e8e3509 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.protocol.bgp.parser.impl;
 
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.yangtools.yang.binding.Notification;
 
 import com.google.common.base.Preconditions;
@@ -27,7 +27,7 @@ public final class BGPMessageFactoryImpl implements BGPMessageFactory {
         * @see org.opendaylight.protocol.bgp.parser.BGPMessageParser#parse(byte[])
         */
        @Override
-       public Notification parse(final byte[] bytes) throws DeserializerException, DocumentedException {
+       public Notification parse(final byte[] bytes) throws BGPParsingException, BGPDocumentedException {
                return this.registry.parseMessage(bytes);
        }
 
index 3666ab7e8f7ed3bb88bd266456dab95c1c8f149f..32626f43a2ef6e9087c825017e0dc2a8aa3fe264 100644 (file)
@@ -21,8 +21,6 @@ import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
 import org.opendaylight.protocol.bgp.parser.impl.message.update.CommunitiesParser;
 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.util.ByteList;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
@@ -226,10 +224,6 @@ public class ComplementaryTest {
                        fail("Exception should have occured.");
                } catch (final IllegalArgumentException e) {
                        assertEquals("Too few bytes in passed array. Passed: 2. Expected: >= 19.", e.getMessage());
-               } catch (final DeserializerException e) {
-                       fail("Not this exception should have occured:" + e);
-               } catch (final DocumentedException e) {
-                       fail("Not this exception should have occured:" + e);
                }
        }
 
index 0ff66fc6d5a08f75103bca5b21925de22b2f04ef..f2a379c1717c61955721be81ae8fa4b89d2cc4e3 100644 (file)
@@ -25,11 +25,9 @@ import org.junit.Test;
 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPError;
 import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
-import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
 import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev130918.LinkstateAddressFamily;
@@ -56,31 +54,31 @@ import com.google.common.collect.Maps;
 public class ParserTest {
 
        public static final byte[] openBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4,
-                       (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
+               (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+               (byte) 0xff, (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4,
+               (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x14, (byte) 0x00 };
 
        public static final byte[] keepAliveBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
+               (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+               (byte) 0xff, (byte) 0x00, (byte) 0x13, (byte) 0x04 };
 
        public static final byte[] notificationBMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x03, (byte) 0x02, (byte) 0x04, (byte) 0x04, (byte) 0x09 };
+               (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+               (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x17, (byte) 0x03, (byte) 0x02, (byte) 0x04, (byte) 0x04, (byte) 0x09 };
 
        public static final byte[] openWithCpblt1 = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0x00, (byte) 0x2d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x48, (byte) 0x00, (byte) 0xb4,
-                       (byte) 0xac, (byte) 0x14, (byte) 0xa0, (byte) 0xaa, (byte) 0x10, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04,
-                       (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04, (byte) 0x40,
-                       (byte) 0x04, (byte) 0x00, (byte) 0x47 };
+               (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+               (byte) 0xff, (byte) 0x00, (byte) 0x2d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x48, (byte) 0x00, (byte) 0xb4,
+               (byte) 0xac, (byte) 0x14, (byte) 0xa0, (byte) 0xaa, (byte) 0x10, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04,
+               (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x01, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04, (byte) 0x40,
+               (byte) 0x04, (byte) 0x00, (byte) 0x47 };
 
        public static final byte[] openWithCpblt2 = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
-                       (byte) 0xff, (byte) 0x00, (byte) 0x2d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x48, (byte) 0x00, (byte) 0xb4,
-                       (byte) 0xac, (byte) 0x14, (byte) 0xa0, (byte) 0xaa, (byte) 0x10, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04,
-                       (byte) 0x40, (byte) 0x04, (byte) 0x00, (byte) 0x47, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04, (byte) 0x00,
-                       (byte) 0x01, (byte) 0x00, (byte) 0x01 };
+               (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
+               (byte) 0xff, (byte) 0x00, (byte) 0x2d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x48, (byte) 0x00, (byte) 0xb4,
+               (byte) 0xac, (byte) 0x14, (byte) 0xa0, (byte) 0xaa, (byte) 0x10, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04,
+               (byte) 0x40, (byte) 0x04, (byte) 0x00, (byte) 0x47, (byte) 0x02, (byte) 0x06, (byte) 0x01, (byte) 0x04, (byte) 0x00,
+               (byte) 0x01, (byte) 0x00, (byte) 0x01 };
 
        static BGPMessageFactory factory;
 
@@ -90,7 +88,7 @@ public class ParserTest {
        }
 
        @Test
-       public void testHeaderErrors() throws DeserializerException, DocumentedException {
+       public void testHeaderErrors() throws BGPParsingException, BGPDocumentedException {
                byte[] wrong = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00 };
                wrong = ByteArray.cutBytes(wrong, 16);
@@ -105,22 +103,22 @@ public class ParserTest {
        }
 
        @Test
-       public void testBadMsgType() throws DeserializerException {
+       public void testBadMsgType() throws BGPParsingException {
                final byte[] bytes = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0x00, (byte) 0x13, (byte) 0x08 };
                try {
                        ParserTest.factory.parse(bytes);
                        fail("Exception should have occured.");
-               } catch (final DocumentedException e) {
-                       assertEquals(BGPError.BAD_MSG_TYPE, ((BGPDocumentedException) e).getError());
+               } catch (final BGPDocumentedException e) {
+                       assertEquals(BGPError.BAD_MSG_TYPE, e.getError());
                        return;
                }
                fail();
        }
 
        @Test
-       public void testKeepAliveMsg() throws DeserializerException, DocumentedException {
+       public void testKeepAliveMsg() throws BGPParsingException, BGPDocumentedException {
                final Notification keepAlive = new KeepaliveBuilder().build();
                final byte[] bytes = ParserTest.factory.put(keepAlive);
                assertArrayEquals(keepAliveBMsg, bytes);
@@ -131,7 +129,7 @@ public class ParserTest {
        }
 
        @Test
-       public void testBadKeepAliveMsg() throws DeserializerException {
+       public void testBadKeepAliveMsg() throws BGPParsingException {
                final byte[] bytes = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0x00, (byte) 0x14, (byte) 0x04, (byte) 0x05 };
@@ -139,16 +137,16 @@ public class ParserTest {
                try {
                        ParserTest.factory.parse(bytes);
                        fail("Exception should have occured.");
-               } catch (final DocumentedException e) {
+               } catch (final BGPDocumentedException e) {
                        assertThat(e.getMessage(), containsString("Message length field not within valid range."));
-                       assertEquals(BGPError.BAD_MSG_LENGTH, ((BGPDocumentedException) e).getError());
+                       assertEquals(BGPError.BAD_MSG_LENGTH, e.getError());
                        return;
                }
                fail();
        }
 
        @Test
-       public void testOpenMessage() throws UnknownHostException, DeserializerException, DocumentedException {
+       public void testOpenMessage() throws UnknownHostException, BGPParsingException, BGPDocumentedException {
                final Notification open = new OpenBuilder().setMyAsNumber(100).setHoldTimer(180).setBgpIdentifier(new Ipv4Address("20.20.20.20")).setVersion(
                                new ProtocolVersion((short) 4)).build();
                final byte[] bytes = ParserTest.factory.put(open);
@@ -164,7 +162,7 @@ public class ParserTest {
        }
 
        @Test
-       public void testBadHoldTimeError() throws DeserializerException {
+       public void testBadHoldTimeError() throws BGPParsingException {
                final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0x01, (byte) 0x14,
@@ -173,16 +171,16 @@ public class ParserTest {
                try {
                        ParserTest.factory.parse(bMsg);
                        fail("Exception should have occured.");
-               } catch (final DocumentedException e) {
+               } catch (final BGPDocumentedException e) {
                        assertEquals("Hold time value not acceptable.", e.getMessage());
-                       assertEquals(BGPError.HOLD_TIME_NOT_ACC, ((BGPDocumentedException) e).getError());
+                       assertEquals(BGPError.HOLD_TIME_NOT_ACC, e.getError());
                        return;
                }
                fail();
        }
 
        @Test
-       public void testBadMsgLength() throws DeserializerException {
+       public void testBadMsgLength() throws BGPParsingException {
                final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0x00, (byte) 0x1b, (byte) 0x01, (byte) 0x04, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4, (byte) 0xff,
@@ -191,14 +189,14 @@ public class ParserTest {
                try {
                        ParserTest.factory.parse(bMsg);
                        fail("Exception should have occured.");
-               } catch (final DocumentedException e) {
+               } catch (final BGPDocumentedException e) {
                        assertEquals("Open message too small.", e.getMessage());
-                       assertEquals(BGPError.BAD_MSG_LENGTH, ((BGPDocumentedException) e).getError());
+                       assertEquals(BGPError.BAD_MSG_LENGTH, e.getError());
                }
        }
 
        @Test
-       public void testBadVersion() throws DeserializerException {
+       public void testBadVersion() throws BGPParsingException {
                final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0x00, (byte) 0x1d, (byte) 0x01, (byte) 0x08, (byte) 0x00, (byte) 0x64, (byte) 0x00, (byte) 0xb4, (byte) 0x14,
@@ -207,16 +205,16 @@ public class ParserTest {
                try {
                        ParserTest.factory.parse(bMsg);
                        fail("Exception should have occured.");
-               } catch (final DocumentedException e) {
+               } catch (final BGPDocumentedException e) {
                        assertEquals("BGP Protocol version 8 not supported.", e.getMessage());
-                       assertEquals(BGPError.VERSION_NOT_SUPPORTED, ((BGPDocumentedException) e).getError());
+                       assertEquals(BGPError.VERSION_NOT_SUPPORTED, e.getError());
                        return;
                }
                fail();
        }
 
        @Test
-       public void testNotificationMsg() throws DeserializerException, DocumentedException {
+       public void testNotificationMsg() throws BGPParsingException, BGPDocumentedException {
                Notification notMsg = new NotifyBuilder().setErrorCode(BGPError.OPT_PARAM_NOT_SUPPORTED.getCode()).setErrorSubcode(
                                BGPError.OPT_PARAM_NOT_SUPPORTED.getSubcode()).setData(new byte[] { 4, 9 }).build();
                byte[] bytes = ParserTest.factory.put(notMsg);
@@ -240,7 +238,7 @@ public class ParserTest {
        }
 
        @Test
-       public void testWrongLength() throws DeserializerException {
+       public void testWrongLength() throws BGPParsingException {
                final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0x00, (byte) 0x14, (byte) 0x03, (byte) 0x02 };
@@ -248,16 +246,16 @@ public class ParserTest {
                try {
                        ParserTest.factory.parse(bMsg);
                        fail("Exception should have occured.");
-               } catch (final DocumentedException e) {
+               } catch (final BGPDocumentedException e) {
                        assertEquals("Notification message too small.", e.getMessage());
-                       assertEquals(BGPError.BAD_MSG_LENGTH, ((BGPDocumentedException) e).getError());
+                       assertEquals(BGPError.BAD_MSG_LENGTH, e.getError());
                        return;
                }
                fail();
        }
 
        @Test
-       public void testUnrecognizedError() throws DeserializerException, DocumentedException {
+       public void testUnrecognizedError() throws BGPParsingException, BGPDocumentedException {
                final byte[] bMsg = new byte[] { (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff,
                                (byte) 0x00, (byte) 0x15, (byte) 0x03, (byte) 0x02, (byte) 0xaa };
index 75e4f8816f3c6397cb095d1af98afbb2508648d1..f630f3d3ed12bf71152e18aee48c1577afe0fbc2 100644 (file)
@@ -9,8 +9,8 @@ package org.opendaylight.protocol.bgp.parser.mock;
 
 import java.util.Map;
 
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
 import org.opendaylight.yangtools.yang.binding.Notification;
 
@@ -30,7 +30,7 @@ public class BGPMessageParserMock implements ProtocolMessageFactory<Notification
        }
 
        @Override
-       public Notification parse(final byte[] bytes) throws DeserializerException, DocumentedException {
+       public Notification parse(final byte[] bytes) throws BGPParsingException, BGPDocumentedException {
                final Notification ret = this.messages.get(bytes);
                if (ret == null) {
                        throw new IllegalArgumentException("Undefined message encountered");
index 8ebe4c08deda0311b6d9a11c375e207831b5f6c4..f84a78964fb0ae34e29262c71e7558ea9695cf6e 100644 (file)
@@ -20,9 +20,9 @@ import java.util.Set;
 
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.BgpTableTypeImpl;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Prefix;
@@ -82,12 +82,12 @@ public class BGPMessageParserMockTest {
        /**
         * Test if mock implementation of parser returns correct message
         * 
-        * @throws DocumentedException
-        * @throws DeserializerException
+        * @throws BGPParsingException
+        * @throws BGPDocumentedException
         * @throws IOException
         */
        @Test
-       public void testGetUpdateMessage() throws DeserializerException, DocumentedException, IOException {
+       public void testGetUpdateMessage() throws BGPParsingException, BGPDocumentedException, IOException {
                final Map<byte[], Notification> updateMap = Maps.newHashMap();
                for (int i = 0; i < this.inputBytes.length; i++) {
                        updateMap.put(this.inputBytes[i], this.messages.get(i));
@@ -104,12 +104,12 @@ public class BGPMessageParserMockTest {
        /**
         * Test if method throws IllegalArgumentException after finding no BGPUpdateMessage associated with given byte[] key
         * 
-        * @throws DocumentedException
-        * @throws DeserializerException
+        * @throws BGPDocumentedException
+        * @throws BGPParsingException
         * @throws IOException
         */
        @Test(expected = IllegalArgumentException.class)
-       public void testGetUpdateMessageException() throws DeserializerException, DocumentedException, IOException {
+       public void testGetUpdateMessageException() throws BGPParsingException, BGPDocumentedException, IOException {
                final Map<byte[], Notification> updateMap = Maps.newHashMap();
                for (int i = 0; i < this.inputBytes.length; i++) {
                        updateMap.put(this.inputBytes[i], this.messages.get(i));
@@ -150,7 +150,7 @@ public class BGPMessageParserMockTest {
                final List<AsSequence> asnums = Lists.newArrayList(new AsSequenceBuilder().setAs(new AsNumber(asn)).build());
                final List<Segments> asPath = Lists.newArrayList();
                asPath.add(new SegmentsBuilder().setCSegment(new CAListBuilder().setAsSequence(asnums).build()).build());
-               final CNextHop nextHop = (CNextHop) new CIpv6NextHopBuilder().setIpv6NextHop(
+               final CNextHop nextHop = new CIpv6NextHopBuilder().setIpv6NextHop(
                                new Ipv6NextHopBuilder().setGlobal(new Ipv6Address("2001:db8::1")).setLinkLocal(new Ipv6Address("fe80::c001:bff:fe7e:0")).build()).build();
 
                final Ipv6Prefix pref1 = new Ipv6Prefix("2001:db8:1:2::/64");
@@ -176,7 +176,7 @@ public class BGPMessageParserMockTest {
        }
 
        @Test
-       public void testGetOpenMessage() throws DeserializerException, DocumentedException, IOException {
+       public void testGetOpenMessage() throws BGPParsingException, BGPDocumentedException, IOException {
                final Map<byte[], Notification> openMap = Maps.newHashMap();
 
                final Set<BgpTableType> type = Sets.newHashSet();
index b0608ca96d06b8a6675e97547742c11a059f1b1b..dfbd70c2aaa6d54d8868c9fad2433506906c0ae7 100644 (file)
@@ -9,10 +9,10 @@
  */
 package org.opendaylight.controller.config.yang.bgp.rib.impl;
 
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.yangtools.yang.binding.Notification;
 
 /**
@@ -67,8 +67,7 @@ org.opendaylight.controller.config.yang.bgp.rib.impl.AbstractBGPMessageFactoryIm
                }
 
                @Override
-               public Notification parse(final byte[] bytes) throws DeserializerException,
-               DocumentedException {
+               public Notification parse(final byte[] bytes) throws BGPParsingException, BGPDocumentedException {
                        return inner.parse(bytes);
                }
 
index 22756166b6de98fcc8c78c8eb6949df71929f784..77886fd94c719c8fee6d0a3c6218a843e31cef10 100644 (file)
@@ -15,15 +15,15 @@ import java.util.List;
 import javax.annotation.concurrent.GuardedBy;
 import javax.annotation.concurrent.ThreadSafe;
 
+import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
 import org.opendaylight.protocol.bgp.parser.BGPError;
+import org.opendaylight.protocol.bgp.parser.BGPMessageFactory;
+import org.opendaylight.protocol.bgp.parser.BGPParsingException;
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
 import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
 import org.opendaylight.protocol.bgp.parser.spi.MessageRegistry;
 import org.opendaylight.protocol.bgp.rib.impl.BGP;
 import org.opendaylight.protocol.concepts.ListenerRegistration;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
-import org.opendaylight.protocol.framework.ProtocolMessageFactory;
 import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.protocol.framework.ReconnectStrategyFactory;
 import org.opendaylight.protocol.util.ByteArray;
@@ -43,7 +43,7 @@ import com.google.common.eventbus.EventBus;
 @ThreadSafe
 public final class BGPMock implements BGP, Closeable {
 
-       private static final Logger logger = LoggerFactory.getLogger(BGPMock.class);
+       private static final Logger LOG = LoggerFactory.getLogger(BGPMock.class);
 
        static final Notification CONNECTION_LOST_MAGIC_MSG = new NotifyBuilder().setErrorCode(BGPError.CEASE.getCode()).build();
 
@@ -63,7 +63,7 @@ public final class BGPMock implements BGP, Closeable {
 
        private List<Notification> parsePrevious(final MessageRegistry registry, final List<byte[]> msgs) {
                final List<Notification> messages = Lists.newArrayList();
-               final ProtocolMessageFactory<Notification> parser = new BGPMessageFactoryImpl(registry);
+               final BGPMessageFactory parser = new BGPMessageFactoryImpl(registry);
                try {
                        for (final byte[] b : msgs) {
 
@@ -71,10 +71,8 @@ public final class BGPMock implements BGP, Closeable {
 
                                messages.add(parser.parse(body));
                        }
-               } catch (final DeserializerException e) {
-                       logger.warn(e.getMessage(), e);
-               } catch (final DocumentedException e) {
-                       logger.warn(e.getMessage(), e);
+               } catch (final BGPDocumentedException | BGPParsingException e) {
+                       LOG.warn("Failed to parse message {}", e);
                }
                return messages;
        }
index 8264d83318b1c584ea14ea413f9e9fe5201c7ed6..e2e57f657e62716577ce34a3646c6bd42e4ddba4 100644 (file)
@@ -7,13 +7,15 @@
  */
 package org.opendaylight.protocol.bgp.testtool;
 
-import com.google.common.base.Preconditions;
 import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.SocketChannel;
 import io.netty.util.HashedWheelTimer;
 import io.netty.util.concurrent.DefaultPromise;
 import io.netty.util.concurrent.GlobalEventExecutor;
 import io.netty.util.concurrent.Promise;
+
+import java.net.InetSocketAddress;
+
 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
 import org.opendaylight.protocol.bgp.parser.impl.BGPMessageFactoryImpl;
 import org.opendaylight.protocol.bgp.parser.spi.pojo.ServiceLoaderBGPExtensionProviderContext;
@@ -23,7 +25,6 @@ import org.opendaylight.protocol.bgp.rib.impl.BGPSessionNegotiatorFactory;
 import org.opendaylight.protocol.bgp.rib.impl.BGPSessionProposalImpl;
 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
 import org.opendaylight.protocol.framework.AbstractDispatcher;
-import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
 import org.opendaylight.protocol.framework.ProtocolSession;
 import org.opendaylight.protocol.framework.SessionListener;
 import org.opendaylight.protocol.framework.SessionListenerFactory;
@@ -31,14 +32,14 @@ import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yangtools.yang.binding.Notification;
 
-import java.net.InetSocketAddress;
+import com.google.common.base.Preconditions;
 
 public class BGPSpeakerMock<M, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> extends AbstractDispatcher<S, L> {
 
        private final SessionNegotiatorFactory<M, S, L> negotiatorFactory;
-       private final ProtocolHandlerFactory<?> factory;
+       private final BGPHandlerFactory factory;
 
-       public BGPSpeakerMock(final SessionNegotiatorFactory<M, S, L> negotiatorFactory, final ProtocolHandlerFactory<?> factory,
+       public BGPSpeakerMock(final SessionNegotiatorFactory<M, S, L> negotiatorFactory, final BGPHandlerFactory factory,
                        final DefaultPromise<BGPSessionImpl> defaultPromise) {
                super(new NioEventLoopGroup(), new NioEventLoopGroup());
                this.negotiatorFactory = Preconditions.checkNotNull(negotiatorFactory);
index 8ba57ad185d46aa49baf87c977c4f5316514def0..995b372425e7edd42413f332b207562620eea6bd 100644 (file)
@@ -15,7 +15,7 @@ import io.netty.handler.codec.ByteToMessageDecoder;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.protocol.framework.DeserializerException;
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.MessageHandlerRegistry;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -57,7 +57,7 @@ public final class PCEPByteToMessageDecoder extends ByteToMessageDecoder {
 
                try {
                        out.add(parse(bytes, errors));
-               } catch (DeserializerException e) {
+               } catch (PCEPDeserializerException e) {
                        LOG.debug("Failed to decode protocol message", e);
                        this.exceptionCaught(ctx, e);
                }
@@ -72,13 +72,13 @@ public final class PCEPByteToMessageDecoder extends ByteToMessageDecoder {
                }
        }
 
-       private Message parse(final byte[] bytes, final List<Message> errors) throws DeserializerException {
+       private Message parse(final byte[] bytes, final List<Message> errors) throws PCEPDeserializerException {
                final int type = UnsignedBytes.toInt(bytes[1]);
                final int msgLength = ByteArray.bytesToInt(ByteArray.subByte(bytes, TYPE_SIZE + 1, LENGTH_SIZE));
 
                final byte[] msgBody = ByteArray.cutBytes(bytes, TYPE_SIZE + 1 + LENGTH_SIZE);
                if (msgBody.length != msgLength - PCEPMessageConstants.COMMON_HEADER_LENGTH) {
-                       throw new DeserializerException("Body size " + msgBody.length + " does not match header size "
+                       throw new PCEPDeserializerException("Body size " + msgBody.length + " does not match header size "
                                        + (msgLength - PCEPMessageConstants.COMMON_HEADER_LENGTH));
                }