Remove ByteBufUtils.readIpv4Address() 14/92714/5
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 25 Sep 2020 10:27:25 +0000 (12:27 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 5 Oct 2020 09:38:41 +0000 (11:38 +0200)
This method is not used anywhere and has a replacement in
readIetfIpv4Address(). Remove it.

Change-Id: Ia18f54b36e4974108cc65bf61207d320b4e7a134
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
openflowjava/openflowjava-util/src/main/java/org/opendaylight/openflowjava/util/ByteBufUtils.java
openflowjava/openflowjava-util/src/test/java/org/opendaylight/openflowjava/util/ByteBufUtilsTest.java

index 9be764dcc2310afb8b29faf095be231d9618ee72..1ce82aa164b9a9163b4abfd79b07a83acbbeb942 100644 (file)
@@ -230,24 +230,6 @@ public abstract class ByteBufUtils {
         return new String(name, StandardCharsets.UTF_8).trim();
     }
 
-    /**
-     * Read an IPv4 address from a buffer and format it into dotted-quad string.
-     *
-     * @param buf Input buffer
-     * @return Dotted-quad string
-     */
-    public static String readIpv4Address(final ByteBuf buf) {
-        final StringBuilder sb = new StringBuilder(EncodeConstants.GROUPS_IN_IPV4_ADDRESS * 4 - 1);
-
-        sb.append(buf.readUnsignedByte());
-        for (int i = 1; i < EncodeConstants.GROUPS_IN_IPV4_ADDRESS; i++) {
-            sb.append('.');
-            sb.append(buf.readUnsignedByte());
-        }
-
-        return sb.toString();
-    }
-
     public static Ipv4Address readIetfIpv4Address(final ByteBuf buf) {
         final byte[] tmp = new byte[4];
         buf.readBytes(tmp);
index 87ef71b87e99e9da2f821d9ea7863a5903dc683c..b02c6644abcd1b277ae2d0e13bc36bcd1ec80210 100644 (file)
@@ -284,25 +284,6 @@ public class ByteBufUtilsTest {
         Assert.assertEquals("Wrong conversion", "", ByteBufUtils.bytesToHexString(empty));
     }
 
-    /**
-     * Test ipv4 address conversion.
-     */
-    @Test(expected = IndexOutOfBoundsException.class)
-    public void testReadIpv4Address() {
-        ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer();
-        buffer.writeByte(10);
-        buffer.writeByte(20);
-        buffer.writeByte(30);
-        buffer.writeByte(40);
-        String ipv4Address = ByteBufUtils.readIpv4Address(buffer);
-        Assert.assertEquals("Wrong conversion", "10.20.30.40", ipv4Address);
-        Assert.assertTrue("Unexpected data", buffer.readableBytes() == 0);
-
-        ByteBuf buffer2 = PooledByteBufAllocator.DEFAULT.buffer();
-        buffer.writeByte(10);
-        ipv4Address = ByteBufUtils.readIpv4Address(buffer2);
-    }
-
     @Test
     public void testSerializeList() {