2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.pcep.impl;
10 import io.netty.buffer.ByteBufAllocator;
11 import io.netty.channel.Channel;
12 import io.netty.channel.ChannelConfig;
13 import io.netty.channel.ChannelFuture;
14 import io.netty.channel.ChannelMetadata;
15 import io.netty.channel.ChannelPipeline;
16 import io.netty.channel.ChannelProgressivePromise;
17 import io.netty.channel.ChannelPromise;
18 import io.netty.channel.EventLoop;
19 import io.netty.util.Attribute;
20 import io.netty.util.AttributeKey;
21 import io.netty.util.HashedWheelTimer;
23 import java.net.SocketAddress;
25 import org.opendaylight.protocol.pcep.PCEPCloseTermination;
26 import org.opendaylight.protocol.pcep.PCEPMessage;
27 import org.opendaylight.protocol.pcep.PCEPSessionListener;
28 import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
29 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
31 public class ServerSessionMock extends PCEPSessionImpl {
33 private final MockPCE client;
35 public ServerSessionMock(final PCEPSessionListener listener, final PCEPSessionListener client) {
36 super(new HashedWheelTimer(), listener, 5, new Channel() {
39 public int compareTo(final Channel arg0) {
40 // TODO Auto-generated method stub
45 public ChannelPromise voidPromise() {
46 // TODO Auto-generated method stub
51 public ChannelPipeline pipeline() {
52 // TODO Auto-generated method stub
57 public ChannelFuture newSucceededFuture() {
58 // TODO Auto-generated method stub
63 public ChannelPromise newPromise() {
64 // TODO Auto-generated method stub
69 public ChannelProgressivePromise newProgressivePromise() {
70 // TODO Auto-generated method stub
75 public ChannelFuture newFailedFuture(final Throwable cause) {
76 // TODO Auto-generated method stub
81 public ByteBufAllocator alloc() {
82 // TODO Auto-generated method stub
87 public ChannelFuture writeAndFlush(final Object msg, final ChannelPromise promise) {
88 // TODO Auto-generated method stub
93 public ChannelFuture writeAndFlush(final Object msg) {
94 // TODO Auto-generated method stub
99 public ChannelFuture write(final Object msg, final ChannelPromise promise) {
100 // TODO Auto-generated method stub
105 public ChannelFuture write(final Object msg) {
106 // TODO Auto-generated method stub
111 public ChannelFuture disconnect(final ChannelPromise promise) {
112 // TODO Auto-generated method stub
117 public ChannelFuture disconnect() {
118 // TODO Auto-generated method stub
123 public ChannelFuture deregister(final ChannelPromise promise) {
124 // TODO Auto-generated method stub
129 public ChannelFuture deregister() {
130 // TODO Auto-generated method stub
135 public ChannelFuture connect(final SocketAddress remoteAddress,
136 final SocketAddress localAddress, final ChannelPromise promise) {
137 // TODO Auto-generated method stub
142 public ChannelFuture connect(final SocketAddress remoteAddress,
143 final ChannelPromise promise) {
144 // TODO Auto-generated method stub
149 public ChannelFuture connect(final SocketAddress remoteAddress,
150 final SocketAddress localAddress) {
151 // TODO Auto-generated method stub
156 public ChannelFuture connect(final SocketAddress remoteAddress) {
157 // TODO Auto-generated method stub
162 public ChannelFuture close(final ChannelPromise promise) {
163 // TODO Auto-generated method stub
168 public ChannelFuture close() {
169 // TODO Auto-generated method stub
174 public ChannelFuture bind(final SocketAddress localAddress, final ChannelPromise promise) {
175 // TODO Auto-generated method stub
180 public ChannelFuture bind(final SocketAddress localAddress) {
181 // TODO Auto-generated method stub
186 public <T> Attribute<T> attr(final AttributeKey<T> key) {
187 // TODO Auto-generated method stub
192 public Unsafe unsafe() {
193 // TODO Auto-generated method stub
198 public SocketAddress remoteAddress() {
199 // TODO Auto-generated method stub
204 public Channel read() {
205 // TODO Auto-generated method stub
210 public Channel parent() {
211 // TODO Auto-generated method stub
216 public ChannelMetadata metadata() {
217 // TODO Auto-generated method stub
222 public SocketAddress localAddress() {
223 // TODO Auto-generated method stub
228 public boolean isWritable() {
229 // TODO Auto-generated method stub
234 public boolean isRegistered() {
235 // TODO Auto-generated method stub
240 public boolean isOpen() {
241 // TODO Auto-generated method stub
246 public boolean isActive() {
247 // TODO Auto-generated method stub
252 public Channel flush() {
253 // TODO Auto-generated method stub
258 public EventLoop eventLoop() {
259 // TODO Auto-generated method stub
264 public ChannelConfig config() {
265 // TODO Auto-generated method stub
270 public ChannelFuture closeFuture() {
271 // TODO Auto-generated method stub
274 }, new PCEPOpenObject(4, 9, 2), new PCEPOpenObject(4, 9, 2));
275 this.client = (MockPCE) client;
279 public void sendMessage(final PCEPMessage msg) {
280 this.lastMessageSentAt = System.nanoTime();
281 this.client.onMessage(this, msg);
285 public void close() {
286 this.client.onSessionTerminated(this, new PCEPCloseTermination(Reason.UNKNOWN));