diff --git a/core/java/build.xml b/core/java/build.xml index 86e0039ac2f1917f73c60c0d9dea2c04e9d2296c..27ca00e6fe6dcf785957d1de77ea8f236d94bdb7 100644 --- a/core/java/build.xml +++ b/core/java/build.xml @@ -49,6 +49,7 @@ <cobertura-instrument todir="./build/obj_test"> <fileset dir="./build/obj"> <include name="**/*.class"/> + <exclude name="**/*Test.class" /> </fileset> </cobertura-instrument> </target> diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index 69b315a1a478be9ac84877478997734ab6d2e5b9..4e3db770b0674ac6785094181ed6bcee2592ba18 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -179,6 +179,7 @@ public class DataHelper { * @param props source * @return new offset */ + @Deprecated public static int toProperties(byte target[], int offset, Properties props) throws DataFormatException, IOException { if (props != null) { OrderedProperties p = new OrderedProperties(); @@ -219,6 +220,7 @@ public class DataHelper { * @param target returned Properties * @return new offset */ + @Deprecated public static int fromProperties(byte source[], int offset, Properties target) throws DataFormatException, IOException { int size = (int)fromLong(source, offset, 2); offset += 2; @@ -254,6 +256,7 @@ public class DataHelper { * * @throws RuntimeException if either is too long. */ + @Deprecated public static byte[] toProperties(Properties opts) { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(2); @@ -544,6 +547,7 @@ public class DataHelper { } /** @deprecated unused */ + @Deprecated public static byte[] toDate(Date date) throws IllegalArgumentException { if (date == null) return toLong(DATE_LENGTH, 0L); @@ -678,6 +682,7 @@ public class DataHelper { * @throws IOException if there is an IO error writing the boolean * @deprecated unused */ + @Deprecated public static void writeBoolean(OutputStream out, Boolean bool) throws DataFormatException, IOException { if (bool == null) @@ -689,6 +694,7 @@ public class DataHelper { } /** @deprecated unused */ + @Deprecated public static Boolean fromBoolean(byte data[], int offset) { if (data[offset] == BOOLEAN_TRUE) return Boolean.TRUE; @@ -699,11 +705,13 @@ public class DataHelper { } /** @deprecated unused */ + @Deprecated public static void toBoolean(byte data[], int offset, boolean value) { data[offset] = (value ? BOOLEAN_TRUE : BOOLEAN_FALSE); } /** @deprecated unused */ + @Deprecated public static void toBoolean(byte data[], int offset, Boolean value) { if (value == null) data[offset] = BOOLEAN_UNKNOWN; @@ -712,12 +720,16 @@ public class DataHelper { } /** deprecated - used only in DatabaseLookupMessage */ + @Deprecated public static final byte BOOLEAN_TRUE = 0x1; /** deprecated - used only in DatabaseLookupMessage */ + @Deprecated public static final byte BOOLEAN_FALSE = 0x0; /** @deprecated unused */ + @Deprecated public static final byte BOOLEAN_UNKNOWN = 0x2; /** @deprecated unused */ + @Deprecated public static final int BOOLEAN_LENGTH = 1; // @@ -780,6 +792,7 @@ public class DataHelper { * Compare two integers, really just for consistency. * @deprecated inefficient */ + @Deprecated public final static boolean eq(int lhs, int rhs) { return lhs == rhs; } @@ -788,6 +801,7 @@ public class DataHelper { * Compare two longs, really just for consistency. * @deprecated inefficient */ + @Deprecated public final static boolean eq(long lhs, long rhs) { return lhs == rhs; } @@ -796,6 +810,7 @@ public class DataHelper { * Compare two bytes, really just for consistency. * @deprecated inefficient */ + @Deprecated public final static boolean eq(byte lhs, byte rhs) { return lhs == rhs; } @@ -974,6 +989,7 @@ public class DataHelper { * @return true if the line was read, false if eof was reached before a * newline was found */ + @Deprecated public static boolean readLine(InputStream in, StringBuffer buf) throws IOException { return readLine(in, buf, null); } @@ -987,6 +1003,7 @@ public class DataHelper { * Warning - 8KB line length limit as of 0.7.13, @throws IOException if exceeded * @deprecated use StringBuilder version */ + @Deprecated public static boolean readLine(InputStream in, StringBuffer buf, Sha256Standalone hash) throws IOException { int c = -1; int i = 0; diff --git a/core/java/test/net/i2p/data/LeaseSetTest.java b/core/java/test/net/i2p/data/LeaseSetTest.java index 61c3b73c6de2625c97f4427efe47b38f5c3d0aed..30fb8c11fb2041ee3d69076d7b5d1fc4b0f92c22 100644 --- a/core/java/test/net/i2p/data/LeaseSetTest.java +++ b/core/java/test/net/i2p/data/LeaseSetTest.java @@ -25,4 +25,50 @@ public class LeaseSetTest extends StructureTest { return leaseSet; } public DataStructure createStructureToRead() { return new LeaseSet(); } + + public void testGetLeaseInvalid() { + // create test subject + LeaseSet subj = new LeaseSet(); + + // should contain no leases now.. + try { + assertNull(subj.getLease(0)); + } catch(RuntimeException exc) { + // all good + } + + // this shouldn't work either + try { + assertNull(subj.getLease(-1)); + } catch(RuntimeException exc) { + // all good + } + } + + public void testAddLeaseNull() { + // create test subject + LeaseSet subj = new LeaseSet(); + + // now add an null lease + try { + subj.addLease(null); + fail("Failed at failing."); + } catch(IllegalArgumentException exc) { + // all good + } + } + + public void testAddLeaseInvalid() { + // create test subject + LeaseSet subj = new LeaseSet(); + + // try to add completely invalid lease(ie. no data) + try { + subj.addLease(new Lease()); + fail("Failed at failing."); + } catch(IllegalArgumentException exc) { + // all good + } + } + } diff --git a/core/java/test/net/i2p/data/RouterAddressTest.java b/core/java/test/net/i2p/data/RouterAddressTest.java index 65a44f92128aff26350a5467bef22d09e17b1718..aab4a88bb9ac593362200f066a2d4774ffd54d57 100644 --- a/core/java/test/net/i2p/data/RouterAddressTest.java +++ b/core/java/test/net/i2p/data/RouterAddressTest.java @@ -58,6 +58,7 @@ public class RouterAddressTest extends StructureTest { addr.setOptions(options); addr.setTransportStyle("Blah"); assertFalse(addr.equals(null)); + assertFalse(addr.equals("")); } public void testToString(){ @@ -73,5 +74,7 @@ public class RouterAddressTest extends StructureTest { addr.setOptions(options); addr.setTransportStyle("Blah"); addr.toString(); + addr.setOptions(null); + addr.toString(); } }