diff --git a/router/java/test/junit/net/i2p/data/i2np/DateMessage.java b/router/java/test/junit/net/i2p/data/i2np/DateMessage.java index 3b84d40570e3cdde25e0051030ff2f28e01d0975..f78b98998a0401d47d9a4e5cbdfb5d3f7dfb68fd 100644 --- a/router/java/test/junit/net/i2p/data/i2np/DateMessage.java +++ b/router/java/test/junit/net/i2p/data/i2np/DateMessage.java @@ -29,7 +29,7 @@ public class DateMessage extends I2NPMessageImpl { public long getNow() { return _now; } public void setNow(long now) { _now = now; } - public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException, IOException { + public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException { if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message"); int curIndex = offset; diff --git a/router/java/test/junit/net/i2p/data/i2np/TunnelCreateMessage.java b/router/java/test/junit/net/i2p/data/i2np/TunnelCreateMessage.java index 4d0008642ef6ee06e87cd843c591b28b43b10189..8d63a037f1c47ffc773ef68b75f8534cec014cb1 100644 --- a/router/java/test/junit/net/i2p/data/i2np/TunnelCreateMessage.java +++ b/router/java/test/junit/net/i2p/data/i2np/TunnelCreateMessage.java @@ -49,7 +49,6 @@ public class TunnelCreateMessage extends I2NPMessageImpl { public static final long MAX_NONCE_VALUE = ((1l << 32l) - 1l); private static final Hash INVALID_HASH = new Hash(new byte[Hash.HASH_LENGTH]); // all 0s - private static final TunnelId INVALID_TUNNEL = TunnelId.INVALID; public TunnelCreateMessage(I2PAppContext context) { super(context); @@ -83,7 +82,7 @@ public class TunnelCreateMessage extends I2NPMessageImpl { public Properties getOptions() { return _options; } public void setOptions(Properties opts) { _options = opts; } - public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException, IOException { + public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException { if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message"); if (DataHelper.eq(INVALID_HASH.getData(), 0, data, offset, Hash.HASH_LENGTH)) { @@ -161,9 +160,13 @@ public class TunnelCreateMessage extends I2NPMessageImpl { length += SessionKey.KEYSIZE_BYTES; // layerKey length += SessionKey.KEYSIZE_BYTES; // ivKey - if (_optionsCache == null) - _optionsCache = DataHelper.toProperties(_options); - length += _optionsCache.length; + if (_optionsCache == null) { + try { + _optionsCache = DataHelper.toProperties(_options); + length += _optionsCache.length; + } catch (DataFormatException dfe) { + } + } length += Hash.HASH_LENGTH; // replyGateway length += 4; // replyTunnel @@ -200,8 +203,13 @@ public class TunnelCreateMessage extends I2NPMessageImpl { System.arraycopy(_ivKey.getData(), 0, data, offset, SessionKey.KEYSIZE_BYTES); offset += SessionKey.KEYSIZE_BYTES; - if (_optionsCache == null) - _optionsCache = DataHelper.toProperties(_options); + if (_optionsCache == null) { + try { + _optionsCache = DataHelper.toProperties(_options); + } catch (DataFormatException dfe) { + throw new I2NPMessageException("Error reading the options", dfe); + } + } System.arraycopy(_optionsCache, 0, data, offset, _optionsCache.length); offset += _optionsCache.length; diff --git a/router/java/test/junit/net/i2p/data/i2np/TunnelCreateStatusMessage.java b/router/java/test/junit/net/i2p/data/i2np/TunnelCreateStatusMessage.java index 07185f3406763aea73cb7897040ddba095d0dc90..a60bc4a72eea93b178d480b8bf71955363778589 100644 --- a/router/java/test/junit/net/i2p/data/i2np/TunnelCreateStatusMessage.java +++ b/router/java/test/junit/net/i2p/data/i2np/TunnelCreateStatusMessage.java @@ -50,7 +50,7 @@ public class TunnelCreateStatusMessage extends I2NPMessageImpl { public long getNonce() { return _nonce; } public void setNonce(long nonce) { _nonce = nonce; } - public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException, IOException { + public void readMessage(byte data[], int offset, int dataSize, int type) throws I2NPMessageException { if (type != MESSAGE_TYPE) throw new I2NPMessageException("Message type is incorrect for this message"); int curIndex = offset; diff --git a/router/java/test/junit/net/i2p/router/SSUDemo.java b/router/java/test/junit/net/i2p/router/SSUDemo.java index 603f54c0d163ae881968aa62bee5a712f1a5b3af..a1972094adc06b1cf5cdbffab8a0dc4284ced1e6 100644 --- a/router/java/test/junit/net/i2p/router/SSUDemo.java +++ b/router/java/test/junit/net/i2p/router/SSUDemo.java @@ -237,7 +237,7 @@ public class SSUDemo { public int getType() { return MESSAGE_TYPE; } protected int calculateWrittenLength() { return _data.length; } - public void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException, IOException { + public void readMessage(byte[] data, int offset, int dataSize, int type) throws I2NPMessageException { _data = new byte[dataSize]; System.arraycopy(data, offset, _data, 0, dataSize); } diff --git a/router/java/test/junit/net/i2p/router/message/SendGarlicJob.java b/router/java/test/junit/net/i2p/router/message/SendGarlicJob.java index f4839a522decc94eb7ec5846b2627db723c098f8..fb2c363e2a770ff86fe01c43e1145b698e54c6d4 100644 --- a/router/java/test/junit/net/i2p/router/message/SendGarlicJob.java +++ b/router/java/test/junit/net/i2p/router/message/SendGarlicJob.java @@ -12,6 +12,7 @@ import java.util.HashSet; import java.util.Set; import net.i2p.data.SessionKey; +import net.i2p.data.SessionTag; import net.i2p.data.i2np.GarlicMessage; import net.i2p.router.Job; import net.i2p.router.JobImpl; @@ -38,7 +39,7 @@ public class SendGarlicJob extends JobImpl { private MessageSelector _replySelector; private GarlicMessage _message; private SessionKey _wrappedKey; - private Set _wrappedTags; + private Set<SessionTag> _wrappedTags; /** * diff --git a/router/java/test/junit/net/i2p/router/tunnel/BuildMessageTest.java b/router/java/test/junit/net/i2p/router/tunnel/BuildMessageTest.java index 6e107418a09f37d2d1597db2dab7a85cfa88f48e..11b4d260bf6b9604b486eb4b05744735b4d2d37b 100644 --- a/router/java/test/junit/net/i2p/router/tunnel/BuildMessageTest.java +++ b/router/java/test/junit/net/i2p/router/tunnel/BuildMessageTest.java @@ -50,16 +50,15 @@ public class BuildMessageTest { _replyTunnel = 42; // populate and encrypt the message - BuildMessageGenerator gen = new BuildMessageGenerator(); TunnelBuildMessage msg = new TunnelBuildMessage(ctx); - for (int i = 0; i < BuildMessageGenerator.ORDER.length; i++) { + for (int i = 0; i < order.size(); i++) { int hop = ((Integer)order.get(i)).intValue(); PublicKey key = null; if (hop < _pubKeys.length) key = _pubKeys[hop]; - gen.createRecord(i, hop, msg, cfg, _replyRouter, _replyTunnel, ctx, key); + BuildMessageGenerator.createRecord(i, hop, msg, cfg, _replyRouter, _replyTunnel, ctx, key); } - gen.layeredEncrypt(ctx, msg, cfg, order); + BuildMessageGenerator.layeredEncrypt(ctx, msg, cfg, order); log.debug("\n================================================================" + "\nMessage fully encrypted" + @@ -86,10 +85,9 @@ public class BuildMessageTest { long time = req.readRequestTime(); long now = (ctx.clock().now() / (60l*60l*1000l)) * (60*60*1000); int ourSlot = -1; - - BuildResponseRecord resp = new BuildResponseRecord(); - byte reply[] = resp.create(ctx, 0, req.readReplyKey(), req.readReplyIV(), -1); - for (int j = 0; j < TunnelBuildMessage.RECORD_COUNT; j++) { + + byte reply[] = BuildResponseRecord.create(ctx, 0, req.readReplyKey(), req.readReplyIV(), -1); + for (int j = 0; j < TunnelBuildMessage.MAX_RECORD_COUNT; j++) { if (msg.getRecord(j) == null) { ourSlot = j; msg.setRecord(j, new ByteArray(reply)); @@ -111,11 +109,10 @@ public class BuildMessageTest { // now all of the replies are populated, toss 'em into a reply message and handle it TunnelBuildReplyMessage reply = new TunnelBuildReplyMessage(ctx); - for (int i = 0; i < TunnelBuildMessage.RECORD_COUNT; i++) + for (int i = 0; i < TunnelBuildMessage.MAX_RECORD_COUNT; i++) reply.setRecord(i, msg.getRecord(i)); - - BuildReplyHandler handler = new BuildReplyHandler(); - int statuses[] = handler.decrypt(ctx, reply, cfg, order); + + int statuses[] = BuildReplyHandler.decrypt(ctx, reply, cfg, order); if (statuses == null) throw new RuntimeException("bar"); boolean allAgree = true; for (int i = 0; i < cfg.getLength(); i++) {