package com.google.bitcoin.core;

import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.concurrent.BlockingQueue;

import org.jboss.netty.channel.*;
import org.jboss.netty.util.internal.QueueFactory;

public class FakeChannel extends AbstractChannel {
    final BlockingQueue<ChannelEvent> events = QueueFactory.createQueue(ChannelEvent.class);

    private final ChannelConfig config;
    private SocketAddress localAddress;
    private SocketAddress remoteAddress;

    protected FakeChannel(ChannelFactory factory,
            ChannelPipeline pipeline, ChannelSink sink) {
        super(null, factory, pipeline, sink);
        config = new DefaultChannelConfig();
        localAddress = new InetSocketAddress("127.0.0.1", 2000);
    }

    public ChannelConfig getConfig() {
        return config;
    }

    public SocketAddress getLocalAddress() {
        return localAddress;
    }

    public SocketAddress getRemoteAddress() {
        return remoteAddress;
    }

    @Override
    public ChannelFuture connect(SocketAddress remoteAddress) {
        this.remoteAddress = remoteAddress;
        return super.connect(remoteAddress);
    }
    
    public boolean isBound() {
        return true;
    }

    public boolean isConnected() {
        return true;
    }


    public ChannelEvent nextEvent() {
        return events.poll();
    }
}

@@ -23,24 +23,110 @@
 coin.core;%0A%0A
+import org.jboss.netty.channel.*;%0Aimport org.jboss.netty.util.internal.QueueFactory;%0A%0A
 import java.
@@ -227,94 +227,8 @@
 e;%0A%0A
-import org.jboss.netty.channel.*;%0Aimport org.jboss.netty.util.internal.QueueFactory;%0A%0A
 publ
@@ -543,20 +543,8 @@
 ory,
-%0A           
  Cha
@@ -1282,17 +1282,16 @@
 %0A    %7D%0A%0A
-%0A
     publ

Reformat FakeChannel.