Skip to content

Commit

Permalink
Update test to remove some warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
willscott committed Apr 18, 2012
1 parent 80753db commit c504d0b
Showing 1 changed file with 16 additions and 5 deletions.
Expand Up @@ -25,16 +25,13 @@
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.util.AEDiagnostics;
import org.gudy.azureus2.core3.util.Debug;

import com.aelitis.azureus.core.networkmanager.VirtualChannelSelector;
import com.aelitis.azureus.core.networkmanager.VirtualServerChannelSelector;
import com.aelitis.azureus.core.networkmanager.VirtualServerChannelSelectorFactory;
import com.aelitis.azureus.core.networkmanager.VirtualChannelSelector.VirtualSelectorListener;
import com.aelitis.azureus.core.networkmanager.impl.ProtocolDecoder;
import com.aelitis.azureus.core.networkmanager.impl.ProtocolDecoderAdapter;
Expand All @@ -49,7 +46,7 @@ public class OsSSLTester {
private final VirtualChannelSelector connect_selector = new VirtualChannelSelector("PHETester",
VirtualChannelSelector.OP_CONNECT, true);

private byte[] TEST_HEADER = "TestHeader".getBytes();
private final byte[] TEST_HEADER = "TestHeader".getBytes();

private static boolean OUTGOING_PLAIN = false;

Expand Down Expand Up @@ -92,6 +89,7 @@ protected void incoming(SocketChannel channel) {

final ProtocolDecoderInitial decoder = new ProtocolDecoderInitial(helper, null, false,
null, new ProtocolDecoderAdapter() {
@Override
public void decodeComplete(ProtocolDecoder decoder,
ByteBuffer remaining_initial_data) {
System.out.println("incoming decode complete: "
Expand All @@ -102,18 +100,22 @@ public void decodeComplete(ProtocolDecoder decoder,
writeStream("ten fat monkies", decoder.getFilter());
}

@Override
public void decodeFailed(ProtocolDecoder decoder, Throwable cause) {
System.out.println("incoming decode failed: "
+ Debug.getNestedExceptionMessage(cause));
}

@Override
public void gotSecret(byte[] session_secret) {
}

@Override
public int getMaximumPlainHeaderLength() {
return (TEST_HEADER.length);
}

@Override
public int matchPlainHeader(ByteBuffer buffer) {
int pos = buffer.position();
int lim = buffer.limit();
Expand Down Expand Up @@ -164,6 +166,7 @@ protected void outgoing() {
} else {

connect_selector.register(channel, new VirtualSelectorListener() {
@Override
public boolean selectSuccess(VirtualChannelSelector selector, SocketChannel sc,
Object attachment) {
try {
Expand All @@ -184,6 +187,7 @@ public boolean selectSuccess(VirtualChannelSelector selector, SocketChannel sc,
}
}

@Override
public void selectFailure(VirtualChannelSelector selector, SocketChannel sc,
Object attachment, Throwable msg) {
msg.printStackTrace();
Expand Down Expand Up @@ -211,6 +215,7 @@ protected void outgoing(SocketChannel channel) {

final ProtocolDecoderInitial decoder = new ProtocolDecoderInitial(helper,
new byte[][] { shared_secret }, true, null, new ProtocolDecoderAdapter() {
@Override
public void decodeComplete(ProtocolDecoder decoder,
ByteBuffer remaining_initial_data) {
System.out.println("outgoing decode complete: "
Expand All @@ -223,19 +228,23 @@ public void decodeComplete(ProtocolDecoder decoder,
writeStream("two jolly porkers", decoder.getFilter());
}

@Override
public void decodeFailed(ProtocolDecoder decoder, Throwable cause) {
System.out.println("outgoing decode failed: "
+ Debug.getNestedExceptionMessage(cause));

}

@Override
public void gotSecret(byte[] session_secret) {
}

@Override
public int getMaximumPlainHeaderLength() {
throw (new RuntimeException());
}

@Override
public int matchPlainHeader(ByteBuffer buffer) {
throw (new RuntimeException());
}
Expand All @@ -254,6 +263,7 @@ protected void readStream(final String str, final TransportHelperFilter filter)
.getReadSelector()
.register(((TCPTransportHelper) filter.getHelper()).getSocketChannel(),
new VirtualSelectorListener() {
@Override
public boolean selectSuccess(VirtualChannelSelector selector,
SocketChannel sc, Object attachment) {
ByteBuffer buffer = ByteBuffer.allocate(1024);
Expand All @@ -279,6 +289,7 @@ public boolean selectSuccess(VirtualChannelSelector selector,
}
}

@Override
public void selectFailure(VirtualChannelSelector selector,
SocketChannel sc, Object attachment, Throwable msg) {
msg.printStackTrace();
Expand Down Expand Up @@ -317,7 +328,7 @@ protected void writeStream(byte[] data, SocketChannel channel) {

public static void main(String[] args) {
// String[] encrProto = { "Plain", "XOR", "RC4", "AES", "SSL" };
AEDiagnostics.startup();
AEDiagnostics.startup(true);

// OUTGOING_PLAIN = true;

Expand Down

0 comments on commit c504d0b

Please sign in to comment.