7589938c07963e212f8bed093a9ce0fa904f54f5
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / SpeakerSessionMock.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.rib.impl;
9
10 import static org.mockito.Mockito.mock;
11 import io.netty.channel.Channel;
12 import io.netty.util.HashedWheelTimer;
13
14 import org.opendaylight.protocol.bgp.parser.BGPMessage;
15 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
16 import org.opendaylight.protocol.bgp.parser.message.BGPOpenMessage;
17
18 /**
19  * Mock of the BGP speakers session.
20  */
21 public class SpeakerSessionMock extends BGPSessionImpl {
22
23         private final BGPSessionListener client;
24
25         SpeakerSessionMock(final BGPSessionListener listener, final BGPSessionListener client) {
26                 super(new HashedWheelTimer(), listener, mock(Channel.class), new BGPOpenMessage(null, (short) 5, null, null));
27                 this.client = client;
28         }
29
30         @Override
31         public void sendMessage(final BGPMessage msg) {
32                 this.lastMessageSentAt = System.nanoTime();
33                 this.client.onMessage(this, msg);
34         }
35 }