From 24ae66df6d33f96fe19ac754412570ca7d624949 Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Wed, 20 Nov 2013 23:06:17 +0000 Subject: [PATCH] Core JUnit tests: type arguments, unused imports --- .../test/junit/net/i2p/client/I2PSessionTest.java | 4 ++-- .../client/naming/BlockfileNamingServiceTest.java | 1 - .../test/junit/net/i2p/crypto/ElGamalTest.java | 4 ++-- .../java/test/junit/net/i2p/crypto/SHA256Test.java | 1 - .../net/i2p/crypto/SessionEncryptionTest.java | 14 +++++++------- core/java/test/junit/net/i2p/data/PayloadTest.java | 3 --- .../test/junit/net/i2p/data/RouterAddressTest.java | 1 - .../test/junit/net/i2p/data/RouterInfoTest.java | 8 ++++---- .../net/i2p/data/SimpleDataStructureTest.java | 3 --- .../i2p/data/i2cp/MessagePayloadMessageTest.java | 3 --- .../data/i2cp/SendMessageExpiresMessageTest.java | 3 --- .../net/i2p/data/i2cp/SendMessageMessageTest.java | 3 --- .../test/junit/net/i2p/stat/SimpleStatDumper.java | 12 ++++++------ .../test/junit/net/i2p/stat/StatLogSplitter.java | 6 +++--- 14 files changed, 24 insertions(+), 42 deletions(-) diff --git a/core/java/test/junit/net/i2p/client/I2PSessionTest.java b/core/java/test/junit/net/i2p/client/I2PSessionTest.java index 7f06a4234e..a3a2cd6035 100644 --- a/core/java/test/junit/net/i2p/client/I2PSessionTest.java +++ b/core/java/test/junit/net/i2p/client/I2PSessionTest.java @@ -24,7 +24,7 @@ import net.i2p.data.Destination; * */ public class I2PSessionTest extends TestCase implements I2PSessionListener{ - private Set _s; + private Set<String> _s; public void setUp(){ @@ -56,7 +56,7 @@ public class I2PSessionTest extends TestCase implements I2PSessionListener{ session.setSessionListener(this); - _s = new HashSet(); + _s = new HashSet<String>(); _s.add("a"); _s.add("b"); _s.add("c"); diff --git a/core/java/test/junit/net/i2p/client/naming/BlockfileNamingServiceTest.java b/core/java/test/junit/net/i2p/client/naming/BlockfileNamingServiceTest.java index 70234f81f0..3a36036928 100644 --- a/core/java/test/junit/net/i2p/client/naming/BlockfileNamingServiceTest.java +++ b/core/java/test/junit/net/i2p/client/naming/BlockfileNamingServiceTest.java @@ -5,7 +5,6 @@ import junit.framework.TestCase; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; diff --git a/core/java/test/junit/net/i2p/crypto/ElGamalTest.java b/core/java/test/junit/net/i2p/crypto/ElGamalTest.java index 337dec3801..2bb886338b 100644 --- a/core/java/test/junit/net/i2p/crypto/ElGamalTest.java +++ b/core/java/test/junit/net/i2p/crypto/ElGamalTest.java @@ -156,7 +156,7 @@ public class ElGamalTest extends TestCase{ String msg = "Hello world"; byte encrypted[] = _context.elGamalAESEngine().encryptAESBlock(msg.getBytes(), sessionKey, iv, null, null, 64); - Set foundTags = new HashSet(); + Set<SessionTag> foundTags = new HashSet<SessionTag>(); SessionKey foundKey = new SessionKey(); byte decrypted[] = null; try{ @@ -338,7 +338,7 @@ public class ElGamalTest extends TestCase{ PrivateKey privKey = (PrivateKey)kp[1]; SessionKey sessionKey = ctx.keyGenerator().generateSessionKey(); for (int i = 0; i < 10; i++) { - Set tags = new HashSet(5); + Set<SessionTag> tags = new HashSet<SessionTag>(5); if (i == 0) { for (int j = 0; j < 5; j++) tags.add(new SessionTag(true)); diff --git a/core/java/test/junit/net/i2p/crypto/SHA256Test.java b/core/java/test/junit/net/i2p/crypto/SHA256Test.java index 7d98b29ee8..fd612b5d0f 100644 --- a/core/java/test/junit/net/i2p/crypto/SHA256Test.java +++ b/core/java/test/junit/net/i2p/crypto/SHA256Test.java @@ -10,7 +10,6 @@ package net.i2p.crypto; import junit.framework.TestCase; import net.i2p.I2PAppContext; -import net.i2p.data.DataHelper; import net.i2p.data.Hash; /** * @author Comwiz diff --git a/core/java/test/junit/net/i2p/crypto/SessionEncryptionTest.java b/core/java/test/junit/net/i2p/crypto/SessionEncryptionTest.java index b86188937a..ace051aa78 100644 --- a/core/java/test/junit/net/i2p/crypto/SessionEncryptionTest.java +++ b/core/java/test/junit/net/i2p/crypto/SessionEncryptionTest.java @@ -81,11 +81,11 @@ public class SessionEncryptionTest extends TestCase{ SessionTag tag3 = new SessionTag(true); SessionTag tag4 = new SessionTag(true); - HashSet firstTags = new HashSet(); + HashSet<SessionTag> firstTags = new HashSet<SessionTag>(); firstTags.add(tag1); firstTags.add(tag2); - HashSet secondTags = new HashSet(); + HashSet<SessionTag> secondTags = new HashSet<SessionTag>(); secondTags.add(tag3); secondTags.add(tag4); @@ -180,11 +180,11 @@ public class SessionEncryptionTest extends TestCase{ SessionTag tag3 = new SessionTag(true); SessionTag tag4 = new SessionTag(true); - HashSet firstTags = new HashSet(); + HashSet<SessionTag> firstTags = new HashSet<SessionTag>(); firstTags.add(tag1); firstTags.add(tag2); - HashSet secondTags = new HashSet(); + HashSet<SessionTag> secondTags = new HashSet<SessionTag>(); secondTags.add(tag3); secondTags.add(tag4); @@ -271,7 +271,7 @@ public class SessionEncryptionTest extends TestCase{ SessionKey curKey = _context.sessionKeyManager().createSession(pubKey); for (int i = 0; i < 1000; i++) { - Set tags = null; + Set<SessionTag> tags = null; SessionKey nextKey = null; curKey = _context.sessionKeyManager().getCurrentKey(pubKey); SessionTag curTag = _context.sessionKeyManager().consumeNextAvailableTag(pubKey, curKey); @@ -302,8 +302,8 @@ public class SessionEncryptionTest extends TestCase{ } } - private Set generateNewTags(int numTags) { - Set tags = new HashSet(numTags); + private Set<SessionTag> generateNewTags(int numTags) { + Set<SessionTag> tags = new HashSet<SessionTag>(numTags); for (int i = 0; i < numTags; i++) tags.add(new SessionTag(true)); return tags; diff --git a/core/java/test/junit/net/i2p/data/PayloadTest.java b/core/java/test/junit/net/i2p/data/PayloadTest.java index ebdf66dfce..143c794b3b 100644 --- a/core/java/test/junit/net/i2p/data/PayloadTest.java +++ b/core/java/test/junit/net/i2p/data/PayloadTest.java @@ -8,9 +8,6 @@ package net.i2p.data; * */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - /** * Test harness for loading / storing Payload objects * diff --git a/core/java/test/junit/net/i2p/data/RouterAddressTest.java b/core/java/test/junit/net/i2p/data/RouterAddressTest.java index 1dd4896fdf..15a1e79290 100644 --- a/core/java/test/junit/net/i2p/data/RouterAddressTest.java +++ b/core/java/test/junit/net/i2p/data/RouterAddressTest.java @@ -9,7 +9,6 @@ package net.i2p.data; */ import java.io.ByteArrayOutputStream; -import java.util.Date; import java.util.Properties; /** diff --git a/core/java/test/junit/net/i2p/data/RouterInfoTest.java b/core/java/test/junit/net/i2p/data/RouterInfoTest.java index 0dbba64bce..6874ffa672 100644 --- a/core/java/test/junit/net/i2p/data/RouterInfoTest.java +++ b/core/java/test/junit/net/i2p/data/RouterInfoTest.java @@ -23,9 +23,9 @@ public class RouterInfoTest extends StructureTest { private final static Log _log = new Log(RouterInfoTest.class); public DataStructure createDataStructure() throws DataFormatException { RouterInfo info = new RouterInfo(); - HashSet addresses = new HashSet(); + HashSet<RouterAddress> addresses = new HashSet<RouterAddress>(); DataStructure structure = (new RouterAddressTest()).createDataStructure(); - addresses.add(structure); + addresses.add((RouterAddress) structure); info.setAddresses(addresses); PublicKey pubKey = null; @@ -57,9 +57,9 @@ public class RouterInfoTest extends StructureTest { options.setProperty("netConnectionSpeed", "OC12"); info.setOptions(options); - HashSet peers = new HashSet(); + HashSet<Hash> peers = new HashSet<Hash>(); structure = (new HashTest()).createDataStructure(); - peers.add(structure); + peers.add((Hash) structure); info.setPeers(peers); info.setPublished(System.currentTimeMillis()); diff --git a/core/java/test/junit/net/i2p/data/SimpleDataStructureTest.java b/core/java/test/junit/net/i2p/data/SimpleDataStructureTest.java index 4cf8233429..5e0d1cae0c 100644 --- a/core/java/test/junit/net/i2p/data/SimpleDataStructureTest.java +++ b/core/java/test/junit/net/i2p/data/SimpleDataStructureTest.java @@ -8,9 +8,6 @@ package net.i2p.data; * */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - import junit.framework.TestCase; /** diff --git a/core/java/test/junit/net/i2p/data/i2cp/MessagePayloadMessageTest.java b/core/java/test/junit/net/i2p/data/i2cp/MessagePayloadMessageTest.java index d863ebe9ba..11a9f2892b 100644 --- a/core/java/test/junit/net/i2p/data/i2cp/MessagePayloadMessageTest.java +++ b/core/java/test/junit/net/i2p/data/i2cp/MessagePayloadMessageTest.java @@ -8,9 +8,6 @@ package net.i2p.data.i2cp; * */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - import net.i2p.data.StructureTest; import net.i2p.data.DataStructure; import net.i2p.data.DataFormatException; diff --git a/core/java/test/junit/net/i2p/data/i2cp/SendMessageExpiresMessageTest.java b/core/java/test/junit/net/i2p/data/i2cp/SendMessageExpiresMessageTest.java index 5a5908df2d..fa487b9c85 100644 --- a/core/java/test/junit/net/i2p/data/i2cp/SendMessageExpiresMessageTest.java +++ b/core/java/test/junit/net/i2p/data/i2cp/SendMessageExpiresMessageTest.java @@ -8,9 +8,6 @@ package net.i2p.data.i2cp; * */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - import net.i2p.data.StructureTest; import net.i2p.data.DataStructure; import net.i2p.data.DataFormatException; diff --git a/core/java/test/junit/net/i2p/data/i2cp/SendMessageMessageTest.java b/core/java/test/junit/net/i2p/data/i2cp/SendMessageMessageTest.java index 1b867832ad..e5798da43e 100644 --- a/core/java/test/junit/net/i2p/data/i2cp/SendMessageMessageTest.java +++ b/core/java/test/junit/net/i2p/data/i2cp/SendMessageMessageTest.java @@ -8,9 +8,6 @@ package net.i2p.data.i2cp; * */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - import net.i2p.data.StructureTest; import net.i2p.data.DataStructure; import net.i2p.data.DataFormatException; diff --git a/core/java/test/junit/net/i2p/stat/SimpleStatDumper.java b/core/java/test/junit/net/i2p/stat/SimpleStatDumper.java index eb48e5fce8..fd47800f22 100644 --- a/core/java/test/junit/net/i2p/stat/SimpleStatDumper.java +++ b/core/java/test/junit/net/i2p/stat/SimpleStatDumper.java @@ -21,9 +21,9 @@ public class SimpleStatDumper { } private static void dumpFrequencies(I2PAppContext ctx, StringBuilder buf) { - Set frequencies = new TreeSet(ctx.statManager().getFrequencyNames()); - for (Iterator iter = frequencies.iterator(); iter.hasNext();) { - String name = (String) iter.next(); + Set<String> frequencies = new TreeSet<String>(ctx.statManager().getFrequencyNames()); + for (Iterator<String> iter = frequencies.iterator(); iter.hasNext();) { + String name = iter.next(); FrequencyStat freq = ctx.statManager().getFrequency(name); buf.append('\n'); buf.append(freq.getGroupName()).append('.').append(freq.getName()).append(": ") @@ -41,9 +41,9 @@ public class SimpleStatDumper { } private static void dumpRates(I2PAppContext ctx, StringBuilder buf) { - Set rates = new TreeSet(ctx.statManager().getRateNames()); - for (Iterator iter = rates.iterator(); iter.hasNext();) { - String name = (String) iter.next(); + Set<String> rates = new TreeSet<String>(ctx.statManager().getRateNames()); + for (Iterator<String> iter = rates.iterator(); iter.hasNext();) { + String name = iter.next(); RateStat rate = ctx.statManager().getRate(name); buf.append('\n'); buf.append(rate.getGroupName()).append('.').append(rate.getName()).append(": ") diff --git a/core/java/test/junit/net/i2p/stat/StatLogSplitter.java b/core/java/test/junit/net/i2p/stat/StatLogSplitter.java index c1b202fc60..4e4c53a47a 100644 --- a/core/java/test/junit/net/i2p/stat/StatLogSplitter.java +++ b/core/java/test/junit/net/i2p/stat/StatLogSplitter.java @@ -29,7 +29,7 @@ public class StatLogSplitter { } private static void splitLog(String filename) { - Map outputFiles = new HashMap(4); + Map<String, FileWriter> outputFiles = new HashMap<String, FileWriter>(4); try { BufferedReader in = new BufferedReader(new FileReader(filename)); String line; @@ -68,8 +68,8 @@ public class StatLogSplitter { } catch (IOException ioe) { ioe.printStackTrace(); } - for (Iterator iter = outputFiles.values().iterator(); iter.hasNext(); ) { - FileWriter out = (FileWriter)iter.next(); + for (Iterator<FileWriter> iter = outputFiles.values().iterator(); iter.hasNext(); ) { + FileWriter out = iter.next(); try { out.close(); } catch (IOException ioe) {} } } -- GitLab