Router JUnit tests: type arguments, unused imports

This commit is contained in:
str4d
2013-11-20 22:47:14 +00:00
parent f161a2dfc9
commit 228bd980db
14 changed files with 35 additions and 41 deletions

View File

@ -8,8 +8,6 @@ package net.i2p.data.i2np;
* *
*/ */
import java.io.IOException;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;

View File

@ -11,7 +11,6 @@ package net.i2p.data.i2np;
import net.i2p.data.DataFormatException; import net.i2p.data.DataFormatException;
import net.i2p.data.DataStructure; import net.i2p.data.DataStructure;
import net.i2p.data.Hash; import net.i2p.data.Hash;
import net.i2p.data.SessionKey;
import net.i2p.data.StructureTest; import net.i2p.data.StructureTest;
import net.i2p.data.TunnelId; import net.i2p.data.TunnelId;

View File

@ -8,7 +8,6 @@ package net.i2p.data.i2np;
* *
*/ */
import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;

View File

@ -8,8 +8,6 @@ package net.i2p.data.i2np;
* *
*/ */
import java.io.IOException;
import net.i2p.I2PAppContext; import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.data.TunnelId; import net.i2p.data.TunnelId;

View File

@ -16,6 +16,7 @@ import net.i2p.data.Hash;
import net.i2p.data.PublicKey; import net.i2p.data.PublicKey;
import net.i2p.data.RouterInfo; import net.i2p.data.RouterInfo;
import net.i2p.data.SessionKey; import net.i2p.data.SessionKey;
import net.i2p.data.SessionTag;
import net.i2p.data.i2np.DeliveryInstructions; import net.i2p.data.i2np.DeliveryInstructions;
import net.i2p.data.i2np.DeliveryStatusMessage; import net.i2p.data.i2np.DeliveryStatusMessage;
import net.i2p.data.i2np.I2NPMessage; import net.i2p.data.i2np.I2NPMessage;
@ -80,7 +81,7 @@ public class BuildTestMessageJob extends JobImpl {
_log.debug("Building garlic message to test " + _target.getIdentity().getHash().toBase64()); _log.debug("Building garlic message to test " + _target.getIdentity().getHash().toBase64());
GarlicConfig config = buildGarlicCloveConfig(); GarlicConfig config = buildGarlicCloveConfig();
// TODO: make the last params on this specify the correct sessionKey and tags used // TODO: make the last params on this specify the correct sessionKey and tags used
ReplyJob replyJob = new JobReplyJob(getContext(), _onSend, config.getRecipient().getIdentity().getPublicKey(), config.getId(), null, new HashSet()); ReplyJob replyJob = new JobReplyJob(getContext(), _onSend, config.getRecipient().getIdentity().getPublicKey(), config.getId(), null, new HashSet<SessionTag>());
MessageSelector sel = buildMessageSelector(); MessageSelector sel = buildMessageSelector();
SendGarlicJob job = new SendGarlicJob(getContext(), config, null, _onSendFailed, replyJob, _onSendFailed, _timeoutMs, _priority, sel); SendGarlicJob job = new SendGarlicJob(getContext(), config, null, _onSendFailed, replyJob, _onSendFailed, _timeoutMs, _priority, sel);
getContext().jobQueue().addJob(job); getContext().jobQueue().addJob(job);
@ -183,9 +184,9 @@ public class BuildTestMessageJob extends JobImpl {
private Job _job; private Job _job;
private PublicKey _target; private PublicKey _target;
private long _msgId; private long _msgId;
private Set _sessionTagsDelivered; private Set<SessionTag> _sessionTagsDelivered;
private SessionKey _keyDelivered; private SessionKey _keyDelivered;
public JobReplyJob(RouterContext ctx, Job job, PublicKey target, long msgId, SessionKey keyUsed, Set tagsDelivered) { public JobReplyJob(RouterContext ctx, Job job, PublicKey target, long msgId, SessionKey keyUsed, Set<SessionTag> tagsDelivered) {
super(ctx); super(ctx);
_job = job; _job = job;
_target = target; _target = target;

View File

@ -20,7 +20,7 @@ class OutboundClientMessageStatus {
private ClientMessage _msg; private ClientMessage _msg;
private PayloadGarlicConfig _clove; private PayloadGarlicConfig _clove;
private LeaseSet _leaseSet; private LeaseSet _leaseSet;
private final Set _sent; private final Set<Tunnel> _sent;
private int _numLookups; private int _numLookups;
private boolean _success; private boolean _success;
private boolean _failure; private boolean _failure;
@ -32,7 +32,7 @@ class OutboundClientMessageStatus {
_msg = msg; _msg = msg;
_clove = null; _clove = null;
_leaseSet = null; _leaseSet = null;
_sent = new HashSet(4); _sent = new HashSet<Tunnel>(4);
_success = false; _success = false;
_failure = false; _failure = false;
_numLookups = 0; _numLookups = 0;

View File

@ -53,9 +53,9 @@ public class SendGarlicJob extends JobImpl {
* @param replySelector ??? * @param replySelector ???
*/ */
public SendGarlicJob(RouterContext ctx, GarlicConfig config, Job onSend, Job onSendFailed, ReplyJob onReply, Job onReplyFailed, long timeoutMs, int priority, MessageSelector replySelector) { public SendGarlicJob(RouterContext ctx, GarlicConfig config, Job onSend, Job onSendFailed, ReplyJob onReply, Job onReplyFailed, long timeoutMs, int priority, MessageSelector replySelector) {
this(ctx, config, onSend, onSendFailed, onReply, onReplyFailed, timeoutMs, priority, replySelector, new SessionKey(), new HashSet()); this(ctx, config, onSend, onSendFailed, onReply, onReplyFailed, timeoutMs, priority, replySelector, new SessionKey(), new HashSet<SessionTag>());
} }
public SendGarlicJob(RouterContext ctx, GarlicConfig config, Job onSend, Job onSendFailed, ReplyJob onReply, Job onReplyFailed, long timeoutMs, int priority, MessageSelector replySelector, SessionKey wrappedKey, Set wrappedTags) { public SendGarlicJob(RouterContext ctx, GarlicConfig config, Job onSend, Job onSendFailed, ReplyJob onReply, Job onReplyFailed, long timeoutMs, int priority, MessageSelector replySelector, SessionKey wrappedKey, Set<SessionTag> wrappedTags) {
super(ctx); super(ctx);
_log = ctx.logManager().getLog(SendGarlicJob.class); _log = ctx.logManager().getLog(SendGarlicJob.class);
if (config == null) throw new IllegalArgumentException("No config specified"); if (config == null) throw new IllegalArgumentException("No config specified");

View File

@ -112,8 +112,8 @@ public class RouterGenerator {
return info; return info;
} }
static Set createAddresses(int num) { static Set<RouterAddress> createAddresses(int num) {
Set addresses = new HashSet(); Set<RouterAddress> addresses = new HashSet<RouterAddress>();
RouterAddress addr = createTCPAddress(num); RouterAddress addr = createTCPAddress(num);
if (addr != null) if (addr != null)
addresses.add(addr); addresses.add(addr);

View File

@ -24,12 +24,12 @@ public class UDPEndpointTestStandalone {
private final Log _log; private final Log _log;
private UDPEndpoint _endpoints[]; private UDPEndpoint _endpoints[];
private volatile boolean _beginTest; private volatile boolean _beginTest;
private final List _sentNotReceived; private final List<ByteArray> _sentNotReceived;
public UDPEndpointTestStandalone(RouterContext ctx) { public UDPEndpointTestStandalone(RouterContext ctx) {
_context = ctx; _context = ctx;
_log = ctx.logManager().getLog(UDPEndpointTestStandalone.class); _log = ctx.logManager().getLog(UDPEndpointTestStandalone.class);
_sentNotReceived = Collections.synchronizedList(new ArrayList(1000)); _sentNotReceived = Collections.synchronizedList(new ArrayList<ByteArray>(1000));
} }
public void runTest(int numPeers) { public void runTest(int numPeers) {

View File

@ -19,7 +19,7 @@ class UDPFlooder implements Runnable {
private RouterContext _context; private RouterContext _context;
// private Log _log; // private Log _log;
private UDPTransport _transport; private UDPTransport _transport;
private final List _peers; private final List<PeerState> _peers;
private boolean _alive; private boolean _alive;
private static final byte _floodData[] = new byte[4096]; private static final byte _floodData[] = new byte[4096];
@ -27,7 +27,7 @@ class UDPFlooder implements Runnable {
_context = ctx; _context = ctx;
// _log = ctx.logManager().getLog(UDPFlooder.class); // _log = ctx.logManager().getLog(UDPFlooder.class);
_transport = transport; _transport = transport;
_peers = new ArrayList(4); _peers = new ArrayList<PeerState>(4);
ctx.random().nextBytes(_floodData); ctx.random().nextBytes(_floodData);
} }

View File

@ -41,7 +41,7 @@ public class BatchedFragmentTest extends FragmentTest {
@Test @Test
public void testBatched() { public void testBatched() {
PendingGatewayMessage pending1 = createPending(10, false, false); PendingGatewayMessage pending1 = createPending(10, false, false);
ArrayList messages = new ArrayList(); ArrayList<PendingGatewayMessage> messages = new ArrayList<PendingGatewayMessage>();
messages.add(pending1); messages.add(pending1);
PendingGatewayMessage pending2 = createPending(1024, false, false); PendingGatewayMessage pending2 = createPending(1024, false, false);
@ -77,7 +77,7 @@ public class BatchedFragmentTest extends FragmentTest {
@Test @Test
public void testSingle() { public void testSingle() {
PendingGatewayMessage pending = createPending(949, false, false); PendingGatewayMessage pending = createPending(949, false, false);
ArrayList messages = new ArrayList(); ArrayList<PendingGatewayMessage> messages = new ArrayList<PendingGatewayMessage>();
messages.add(pending); messages.add(pending);
TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context); TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context);
@ -103,7 +103,7 @@ public class BatchedFragmentTest extends FragmentTest {
@Test @Test
public void testMultiple() throws Exception { public void testMultiple() throws Exception {
PendingGatewayMessage pending = createPending(2048, false, false); PendingGatewayMessage pending = createPending(2048, false, false);
ArrayList messages = new ArrayList(); ArrayList<PendingGatewayMessage> messages = new ArrayList<PendingGatewayMessage>();
messages.add(pending); messages.add(pending);
TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context); TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context);
@ -176,7 +176,7 @@ public class BatchedFragmentTest extends FragmentTest {
} }
private void runBatch(PendingGatewayMessage pending1, PendingGatewayMessage pending2, PendingGatewayMessage pending3) { private void runBatch(PendingGatewayMessage pending1, PendingGatewayMessage pending2, PendingGatewayMessage pending3) {
ArrayList messages = new ArrayList(); ArrayList<PendingGatewayMessage> messages = new ArrayList<PendingGatewayMessage>();
messages.add(pending1); messages.add(pending1);
TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context); TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context);

View File

@ -54,7 +54,7 @@ public class FragmentTest {
@Test @Test
public void testSingle() { public void testSingle() {
PendingGatewayMessage pending = createPending(949, false, false); PendingGatewayMessage pending = createPending(949, false, false);
ArrayList messages = new ArrayList(); ArrayList<PendingGatewayMessage> messages = new ArrayList<PendingGatewayMessage>();
messages.add(pending); messages.add(pending);
TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context); TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context);
@ -77,7 +77,7 @@ public class FragmentTest {
@Test @Test
public void testMultiple() throws Exception { public void testMultiple() throws Exception {
PendingGatewayMessage pending = createPending(2048, false, false); PendingGatewayMessage pending = createPending(2048, false, false);
ArrayList messages = new ArrayList(); ArrayList<PendingGatewayMessage> messages = new ArrayList<PendingGatewayMessage>();
messages.add(pending); messages.add(pending);
TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context); TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context);
@ -100,7 +100,7 @@ public class FragmentTest {
*/ */
public void runDelayed() { public void runDelayed() {
PendingGatewayMessage pending = createPending(2048, false, false); PendingGatewayMessage pending = createPending(2048, false, false);
ArrayList messages = new ArrayList(); ArrayList<PendingGatewayMessage> messages = new ArrayList<PendingGatewayMessage>();
messages.add(pending); messages.add(pending);
TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context); TunnelGateway.QueuePreprocessor pre = createPreprocessor(_context);
SenderImpl sender = new SenderImpl(); SenderImpl sender = new SenderImpl();
@ -126,7 +126,7 @@ public class FragmentTest {
protected boolean runVaried(int size, boolean includeRouter, boolean includeTunnel) { protected boolean runVaried(int size, boolean includeRouter, boolean includeTunnel) {
PendingGatewayMessage pending = createPending(size, includeRouter, includeTunnel); PendingGatewayMessage pending = createPending(size, includeRouter, includeTunnel);
ArrayList messages = new ArrayList(); ArrayList<PendingGatewayMessage> messages = new ArrayList<PendingGatewayMessage>();
messages.add(pending); messages.add(pending);
DefragmentedReceiverImpl handleReceiver = new DefragmentedReceiverImpl(pending.getData()); DefragmentedReceiverImpl handleReceiver = new DefragmentedReceiverImpl(pending.getData());

View File

@ -48,7 +48,7 @@ public abstract class GatewayTestBase extends RouterTestBase {
public void testSmall() throws Exception { public void testSmall() throws Exception {
int runCount = 1; int runCount = 1;
List messages = new ArrayList(runCount); List<DataMessage> messages = new ArrayList<DataMessage>(runCount);
long start = _context.clock().now(); long start = _context.clock().now();
for (int i = 0; i < runCount; i++) { for (int i = 0; i < runCount; i++) {
@ -59,7 +59,7 @@ public abstract class GatewayTestBase extends RouterTestBase {
Thread.sleep(1000); Thread.sleep(1000);
List received = _receiver.clearReceived(); List<I2NPMessage> received = _receiver.clearReceived();
for (int i = 0; i < messages.size(); i++) { for (int i = 0; i < messages.size(); i++) {
assertTrue(received.contains(((I2NPMessage)messages.get(i)))); assertTrue(received.contains(((I2NPMessage)messages.get(i))));
} }
@ -69,7 +69,7 @@ public abstract class GatewayTestBase extends RouterTestBase {
public void testRouter() throws Exception { public void testRouter() throws Exception {
int runCount = 1; int runCount = 1;
List messages = new ArrayList(runCount); List<DataMessage> messages = new ArrayList<DataMessage>(runCount);
long start = _context.clock().now(); long start = _context.clock().now();
for (int i = 0; i < runCount; i++) { for (int i = 0; i < runCount; i++) {
@ -82,7 +82,7 @@ public abstract class GatewayTestBase extends RouterTestBase {
Thread.sleep(1000); Thread.sleep(1000);
List received = _receiver.clearReceived(); List<I2NPMessage> received = _receiver.clearReceived();
for (int i = 0; i < messages.size(); i++) { for (int i = 0; i < messages.size(); i++) {
assertTrue(received.contains(((I2NPMessage)messages.get(i)))); assertTrue(received.contains(((I2NPMessage)messages.get(i))));
} }
@ -92,7 +92,7 @@ public abstract class GatewayTestBase extends RouterTestBase {
public void testTunnel() throws Exception { public void testTunnel() throws Exception {
int runCount = 1; int runCount = 1;
List messages = new ArrayList(runCount); List<DataMessage> messages = new ArrayList<DataMessage>(runCount);
long start = _context.clock().now(); long start = _context.clock().now();
for (int i = 0; i < runCount; i++) { for (int i = 0; i < runCount; i++) {
@ -107,7 +107,7 @@ public abstract class GatewayTestBase extends RouterTestBase {
Thread.sleep(1000); Thread.sleep(1000);
List received = _receiver.clearReceived(); List<I2NPMessage> received = _receiver.clearReceived();
for (int i = 0; i < messages.size(); i++) { for (int i = 0; i < messages.size(); i++) {
assertTrue(received.contains(((I2NPMessage)messages.get(i)))); assertTrue(received.contains(((I2NPMessage)messages.get(i))));
} }
@ -117,7 +117,7 @@ public abstract class GatewayTestBase extends RouterTestBase {
public void testLarge() throws Exception { public void testLarge() throws Exception {
int runCount = 1; int runCount = 1;
List messages = new ArrayList(runCount); List<DataMessage> messages = new ArrayList<DataMessage>(runCount);
long start = _context.clock().now(); long start = _context.clock().now();
for (int i = 0; i < runCount; i++) { for (int i = 0; i < runCount; i++) {
@ -128,7 +128,7 @@ public abstract class GatewayTestBase extends RouterTestBase {
Thread.sleep(1000); Thread.sleep(1000);
List received = _receiver.clearReceived(); List<I2NPMessage> received = _receiver.clearReceived();
for (int i = 0; i < messages.size(); i++) { for (int i = 0; i < messages.size(); i++) {
assertTrue(received.contains(((I2NPMessage)messages.get(i)))); assertTrue(received.contains(((I2NPMessage)messages.get(i))));
} }
@ -148,11 +148,11 @@ public abstract class GatewayTestBase extends RouterTestBase {
protected class TestReceiver implements TunnelGateway.Receiver, FragmentHandler.DefragmentedReceiver { protected class TestReceiver implements TunnelGateway.Receiver, FragmentHandler.DefragmentedReceiver {
private TunnelCreatorConfig _config; private TunnelCreatorConfig _config;
private FragmentHandler _handler; private FragmentHandler _handler;
private volatile List _received; private volatile List<I2NPMessage> _received;
public TestReceiver(TunnelCreatorConfig config) { public TestReceiver(TunnelCreatorConfig config) {
_config = config; _config = config;
_handler = new FragmentHandler(_context, TestReceiver.this); _handler = new FragmentHandler(_context, TestReceiver.this);
_received = new ArrayList(1000); _received = new ArrayList<I2NPMessage>(1000);
} }
public long receiveEncrypted(byte[] encrypted) { public long receiveEncrypted(byte[] encrypted) {
// fake all the hops... // fake all the hops...
@ -174,9 +174,9 @@ public abstract class GatewayTestBase extends RouterTestBase {
public void receiveComplete(I2NPMessage msg, Hash toRouter, TunnelId toTunnel) { public void receiveComplete(I2NPMessage msg, Hash toRouter, TunnelId toTunnel) {
_received.add(msg); _received.add(msg);
} }
public List clearReceived() { public List<I2NPMessage> clearReceived() {
List rv = _received; List<I2NPMessage> rv = _received;
_received = new ArrayList(); _received = new ArrayList<I2NPMessage>();
return rv; return rv;
} }
@Override @Override

View File

@ -9,7 +9,6 @@ package net.i2p.router.tunnel;
*/ */
import junit.framework.TestCase; import junit.framework.TestCase;
import net.i2p.I2PAppContext;
import net.i2p.data.DataHelper; import net.i2p.data.DataHelper;
import net.i2p.data.Hash; import net.i2p.data.Hash;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;