From 524c375944b1a312f4ca0a39e4dc2882725a03e4 Mon Sep 17 00:00:00 2001 From: zzz <zzz@mail.i2p> Date: Mon, 8 Oct 2018 12:43:58 +0000 Subject: [PATCH] Data: Drop long-deprecated and unused boolean methods and related tests --- core/java/src/net/i2p/data/DataHelper.java | 82 ------------------- .../test/junit/net/i2p/data/BooleanTest.java | 43 ---------- .../junit/net/i2p/data/DataTestSuite.java | 1 - 3 files changed, 126 deletions(-) delete mode 100644 core/java/test/junit/net/i2p/data/BooleanTest.java diff --git a/core/java/src/net/i2p/data/DataHelper.java b/core/java/src/net/i2p/data/DataHelper.java index aec75835d4..8f9e4bc081 100644 --- a/core/java/src/net/i2p/data/DataHelper.java +++ b/core/java/src/net/i2p/data/DataHelper.java @@ -930,88 +930,6 @@ public class DataHelper { } } - /** Read in a boolean as specified by the I2P data structure spec. - * A boolean is 1 byte that is either 0 (false), 1 (true), or 2 (null) - * @param in stream to read from - * @throws DataFormatException if the boolean is not valid - * @throws IOException if there is an IO error reading the boolean - * @return boolean value, or null - * @deprecated unused - */ - @Deprecated - public static Boolean readBoolean(InputStream in) throws DataFormatException, IOException { - int val = in.read(); - switch (val) { - case -1: - throw new EOFException("EOF reading boolean"); - case 0: - return Boolean.FALSE; - case 1: - return Boolean.TRUE; - case 2: - return null; - default: - throw new DataFormatException("Uhhh.. readBoolean read a value that isn't a known ternary val (0,1,2): " - + val); - } - } - - /** Write out a boolean as specified by the I2P data structure spec. - * A boolean is 1 byte that is either 0 (false), 1 (true), or 2 (null) - * @param out stream to write to - * @param bool boolean value, or null - * @throws DataFormatException if the boolean is not valid - * @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) - writeLong(out, 1, BOOLEAN_UNKNOWN); - else if (Boolean.TRUE.equals(bool)) - writeLong(out, 1, BOOLEAN_TRUE); - else - writeLong(out, 1, BOOLEAN_FALSE); - } - - /** @deprecated unused */ - @Deprecated - public static Boolean fromBoolean(byte data[], int offset) { - if (data[offset] == BOOLEAN_TRUE) - return Boolean.TRUE; - else if (data[offset] == BOOLEAN_FALSE) - return Boolean.FALSE; - else - return null; - } - - /** @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; - else - data[offset] = (value.booleanValue() ? BOOLEAN_TRUE : BOOLEAN_FALSE); - } - - /** deprecated - used only in DatabaseLookupMessage */ - public static final byte BOOLEAN_TRUE = 0x1; - /** deprecated - used only in DatabaseLookupMessage */ - 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; - // // The following comparator helpers make it simpler to write consistently comparing // functions for objects based on their value, not JVM memory address diff --git a/core/java/test/junit/net/i2p/data/BooleanTest.java b/core/java/test/junit/net/i2p/data/BooleanTest.java deleted file mode 100644 index 418be5e81a..0000000000 --- a/core/java/test/junit/net/i2p/data/BooleanTest.java +++ /dev/null @@ -1,43 +0,0 @@ -package net.i2p.data; -/* - * free (adj.): unencumbered; not under the control of others - * Written by jrandom in 2003 and released into the public domain - * with no warranty of any kind, either expressed or implied. - * It probably won't make your computer catch on fire, or eat - * your children, but it might. Use at your own risk. - * - */ - -import static org.junit.Assert.*; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; - -import org.junit.Test; - -/** - * Test harness for the boolean structure - * - * @author jrandom - */ -public class BooleanTest { - @SuppressWarnings("deprecation") - @Test - public void testBoolean() throws Exception{ - byte[] temp = null; - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - DataHelper.writeBoolean(baos, Boolean.TRUE); - temp = baos.toByteArray(); - - - Boolean b = null; - ByteArrayInputStream bais = new ByteArrayInputStream(temp); - - b = DataHelper.readBoolean(bais); - - assertEquals(Boolean.TRUE, b); - } - -} diff --git a/core/java/test/junit/net/i2p/data/DataTestSuite.java b/core/java/test/junit/net/i2p/data/DataTestSuite.java index d06e92b0ee..fbd5a544da 100644 --- a/core/java/test/junit/net/i2p/data/DataTestSuite.java +++ b/core/java/test/junit/net/i2p/data/DataTestSuite.java @@ -6,7 +6,6 @@ import org.junit.runner.RunWith; @RunWith(Suite.class) @Suite.SuiteClasses({ Base64Test.class, - BooleanTest.class, CertificateTest.class, DataHelperTest.class, DataStructureImplTest.class, -- GitLab