Cleanup package imports
[bgpcep.git] / bgp / rib-mock / src / main / java / org / opendaylight / protocol / bgp / rib / mock / BGPMock.java
index 418df4c3d86b02c44f8519342ff7ef5e747ea175..4889114acc69b6a86594a4bbb8a326fdecdc9437 100644 (file)
@@ -18,6 +18,7 @@ import javax.annotation.concurrent.ThreadSafe;
 import org.opendaylight.protocol.bgp.parser.BGPError;
 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;
@@ -44,24 +45,25 @@ public final class BGPMock implements BGP, Closeable {
        private final List<byte[]> allPreviousByteMessages;
        private final List<Notification> allPreviousBGPMessages;
        private final EventBus eventBus;
+
        @GuardedBy("this")
        private final List<EventBusRegistration> openRegistrations = Lists.newLinkedList();
 
-       public BGPMock(final EventBus eventBus, final List<byte[]> bgpMessages) {
+       public BGPMock(final EventBus eventBus, final MessageRegistry registry, final List<byte[]> bgpMessages) {
                this.allPreviousByteMessages = Lists.newLinkedList(bgpMessages);
                this.eventBus = eventBus;
-               this.allPreviousBGPMessages = this.parsePrevious(this.allPreviousByteMessages);
+               this.allPreviousBGPMessages = this.parsePrevious(registry, this.allPreviousByteMessages);
        }
 
-       private List<Notification> parsePrevious(final List<byte[]> msgs) {
+       private List<Notification> parsePrevious(final MessageRegistry registry, final List<byte[]> msgs) {
                final List<Notification> messages = Lists.newArrayList();
-               final ProtocolMessageFactory<Notification> parser = BGPMessageFactoryImpl.INSTANCE;
+               final ProtocolMessageFactory<Notification> parser = new BGPMessageFactoryImpl(registry);
                try {
                        for (final byte[] b : msgs) {
 
                                final byte[] body = ByteArray.cutBytes(b, 1);
 
-                               messages.addAll(parser.parse(body));
+                               messages.add(parser.parse(body));
                        }
                } catch (final DeserializerException e) {
                        e.printStackTrace();