mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Nicolas Capponi
23.04.2014 f1dded7d397dbab3cf6088f0654aec93610c8610
Fix issue in method ByteStringBuilder#append(DataInput, int) added in r11047
2 files modified
14 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java 2 ●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/ByteStringBuilderTestCase.java 12 ●●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/ByteStringBuilder.java
@@ -494,7 +494,7 @@
        ensureAdditionalCapacity(length);
        stream.readFully(buffer, this.length, length);
        this.length = length;
        this.length += length;
    }
    /**
opendj-core/src/test/java/org/forgerock/opendj/ldap/ByteStringBuilderTestCase.java
@@ -27,6 +27,8 @@
package org.forgerock.opendj.ldap;
import java.io.ByteArrayInputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
@@ -122,6 +124,15 @@
        Assert.assertEquals(bsb.append(stream, 10), 5);
    }
    @Test
    public void testAppendDataInputWithNonEmptyBuilder() throws Exception {
        final ByteStringBuilder bsb = new ByteStringBuilder();
        bsb.append((byte) 0);
        final DataInput stream = new DataInputStream(new ByteArrayInputStream(new byte[5]));
        bsb.append(stream, 5);
        Assert.assertEquals(bsb.length(), 6);
    }
    @Test(dataProvider = "builderProvider", expectedExceptions = IndexOutOfBoundsException.class)
    public void testClear(final ByteStringBuilder bs, final byte[] ba) {
        bs.clear();
@@ -180,6 +191,7 @@
        Assert.assertTrue(Arrays.equals(trimmedArray, ba));
    }
    @SuppressWarnings("unused")
    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testInvalidCapacity() {
        new ByteStringBuilder(-1);