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

Matthew Swift
25.41.2014 797a1775440f6c1a9a8d517120195b43ca5f3a0e
Minor code cleanup:

* suppress missing Javadoc warnings in unit tests
* fix minor bugs in OperatingSystem
* renamed methods called "_" to "b" to avoid JDK8 compiler warnings.
10 files modified
126 ■■■■ changed files
opendj-cli/src/test/java/com/forgerock/opendj/cli/ConsoleApplicationTestCase.java 1 ●●●● patch | view | raw | blame | history
opendj-cli/src/test/java/com/forgerock/opendj/cli/TestSubCommandArgumentParserTestCase.java 1 ●●●● patch | view | raw | blame | history
opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java 1 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/com/forgerock/opendj/util/OperatingSystem.java 44 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/com/forgerock/opendj/util/OperatingSystemTestCase.java 1 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/io/ASN1ReaderTestCase.java 1 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/ByteStringBuilderTestCase.java 64 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/GSERParserTestCase.java 4 ●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImplTest.java 1 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java 8 ●●●● patch | view | raw | blame | history
opendj-cli/src/test/java/com/forgerock/opendj/cli/ConsoleApplicationTestCase.java
@@ -39,6 +39,7 @@
/**
 * Unit tests for the console application class.
 */
@SuppressWarnings("javadoc")
public class ConsoleApplicationTestCase extends CliTestCase {
    final LocalizableMessage msg = LocalizableMessage.raw("Language is the source of misunderstandings.");
opendj-cli/src/test/java/com/forgerock/opendj/cli/TestSubCommandArgumentParserTestCase.java
@@ -42,6 +42,7 @@
/**
 * Unit tests for the SubCommand class.
 */
@SuppressWarnings("javadoc")
public final class TestSubCommandArgumentParserTestCase extends CliTestCase {
    private SubCommandArgumentParser parser;
opendj-cli/src/test/java/com/forgerock/opendj/cli/UtilsTestCase.java
@@ -32,6 +32,7 @@
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
@SuppressWarnings("javadoc")
public class UtilsTestCase extends CliTestCase {
    @Test(expectedExceptions = ClientException.class)
opendj-core/src/main/java/com/forgerock/opendj/util/OperatingSystem.java
@@ -98,10 +98,7 @@
    private boolean isMacOS;
    private boolean isUnixBased;
    private static OperatingSystem os;
    static {
        OperatingSystem.getOperatingSystem();
    }
    private static final OperatingSystem INSTANCE = forName(System.getProperty("INSTANCE.name"));
    /**
     * Creates a new operating system value with the provided name.
@@ -133,16 +130,11 @@
     * @return The operating system for the provided name.
     */
    public static OperatingSystem forName(final String osName) {
        return os = forName2(osName);
    }
    private static OperatingSystem forName2(final String osName) {
        if (osName == null) {
            return UNKNOWN;
        }
        final String lowerName = osName.toLowerCase();
        if ((lowerName.indexOf("solaris") >= 0) || (lowerName.indexOf("sunos") >= 0)) {
            return SOLARIS;
        } else if (lowerName.indexOf("linux") >= 0) {
@@ -163,33 +155,21 @@
            return WINDOWS;
        } else if ((lowerName.indexOf("freebsd") >= 0) || (lowerName.indexOf("free bsd") >= 0)) {
            return FREEBSD;
        } else if ((lowerName.indexOf("macos x") >= 0) || (lowerName.indexOf("mac os x") >= 0)) {
        } else if ((lowerName.indexOf("macos x") >= 0) || (lowerName.indexOf("mac INSTANCE x") >= 0)) {
            return MACOSX;
        } else if (lowerName.indexOf("z/os") >= 0) {
        } else if (lowerName.indexOf("z/INSTANCE") >= 0) {
            return ZOS;
        }
        return UNKNOWN;
    }
    /**
     * Indicates whether the provided operating system is UNIX-based. UNIX-based operating systems include Solaris,
     * Linux, HP-UX, AIX, FreeBSD, and Mac OS X.
     *
     * @param os
     *            The operating system for which to make the determination.
     * @return <CODE>true</CODE> if the provided operating system is UNIX-based, or <CODE>false</CODE> if not.
     */
    public static boolean isUNIXBased(OperatingSystem os) {
        return os.isUnixBased;
    }
    /**
     * Returns the operating system on which the JVM is running.
     *
     * @return The operating system on which the JVM is running
     */
    public static OperatingSystem getOperatingSystem() {
        return OperatingSystem.forName(System.getProperty("os.name"));
        return INSTANCE;
    }
    /**
@@ -198,7 +178,7 @@
     * @return {@code true} if the underlying operating system is a Windows variant, or {@code false} if not.
     */
    public static boolean isWindows() {
        return os.isWindows;
        return INSTANCE.isWindows;
    }
    /**
@@ -207,7 +187,7 @@
     * @return {@code true} if the underlying operating system is Windows Vista, or {@code false} if not.
     */
    public static boolean isVista() {
        return os == WINDOWS_VISTA;
        return INSTANCE == WINDOWS_VISTA;
    }
    /**
@@ -216,7 +196,7 @@
     * @return {@code true} if the underlying operating system is Windows 2008, or {@code false} if not.
     */
    public static boolean isWindows2008() {
        return os == WINDOWS_SERVER_2008;
        return INSTANCE == WINDOWS_SERVER_2008;
    }
    /**
@@ -225,7 +205,7 @@
     * @return {@code true} if the underlying operating system is Windows 7, or {@code false} if not.
     */
    public static boolean isWindows7() {
        return os == WINDOWS7;
        return INSTANCE == WINDOWS7;
    }
    /**
@@ -234,7 +214,7 @@
     * @return {@code true} if we are running under Mac OS and {@code false} otherwise.
     */
    public static boolean isMacOS() {
        return os == MACOSX;
        return INSTANCE.isMacOS;
    }
    /**
@@ -243,7 +223,7 @@
     * @return {@code true} if we are running under Unix and {@code false} otherwise.
     */
    public static boolean isUnix() {
        return os.isUnixBased;
        return INSTANCE.isUnixBased;
    }
    /**
@@ -252,7 +232,7 @@
     * @return {@code true} if the OS is Unix based.
     */
    public static boolean isUnixBased() {
        return os.isUnixBased;
        return INSTANCE.isUnixBased;
    }
    /**
@@ -261,7 +241,7 @@
     * @return {@code true} if the OS is Unknown.
     */
    public static boolean isUnknown() {
        return os == UNKNOWN;
        return INSTANCE == UNKNOWN;
    }
    /**
opendj-core/src/test/java/com/forgerock/opendj/util/OperatingSystemTestCase.java
@@ -34,6 +34,7 @@
/**
 * This class tests the model functionality.
 */
@SuppressWarnings("javadoc")
public class OperatingSystemTestCase extends UtilTestCase {
    // @formatter:off
opendj-core/src/test/java/org/forgerock/opendj/io/ASN1ReaderTestCase.java
@@ -42,6 +42,7 @@
 * An abstract base class for all ASN1Reader test cases.
 */
@Test(groups = { "precommit", "asn1", "sdk" })
@SuppressWarnings("javadoc")
public abstract class ASN1ReaderTestCase extends ForgeRockTestCase {
    /**
opendj-core/src/test/java/org/forgerock/opendj/ldap/ByteStringBuilderTestCase.java
@@ -46,13 +46,13 @@
public class ByteStringBuilderTestCase extends ByteSequenceTestCase {
    //@Checkstyle:off
    private static byte _(int i) {
    private static byte b(int i) {
        return (byte) i;
    }
    //@Checkstyle:on
    private static final byte[] EIGHT_BYTES = new byte[] { _(0x01), _(0x02), _(0x03),
        _(0x04), _(0x05), _(0x06), _(0x07), _(0x08) };
    private static final byte[] EIGHT_BYTES = new byte[] { b(0x01), b(0x02), b(0x03),
        b(0x04), b(0x05), b(0x06), b(0x07), b(0x08) };
    /**
     * ByteSequence data provider.
@@ -66,7 +66,7 @@
        System.arraycopy(builders, 0, addlSequences, 0, builders.length);
        addlSequences[builders.length] =
                new Object[] { new ByteStringBuilder().append(EIGHT_BYTES).subSequence(2, 6),
                    new byte[] { _(0x03), _(0x04), _(0x05), _(0x06) } };
                    new byte[] { b(0x03), b(0x04), b(0x05), b(0x06) } };
        return addlSequences;
    }
@@ -200,7 +200,7 @@
    public void testAsOutputStream() throws Exception {
        final ByteStringBuilder bsb = new ByteStringBuilder();
        final OutputStream os = bsb.asOutputStream();
        os.write(_(0x01));
        os.write(b(0x01));
        os.write(2);
        os.write(new byte[] { 2, 3, 4, 5 }, 1, 2);
        os.close();
@@ -234,11 +234,11 @@
        testBuilderFromStream.append(testStream, 8);
        return new Object[][] {
            { new ByteStringBuilder().append(_(0x00)).append(_(0x01)),
                new byte[] { _(0x00), _(0x01) } },
            { new ByteStringBuilder().append(b(0x00)).append(b(0x01)),
                new byte[] { b(0x00), b(0x01) } },
            { new ByteStringBuilder(5)
                      .append(new byte[] { _(0x01), _(0x02), _(0x03), _(0x04) })
                      .append(new byte[] { _(0x05), _(0x06), _(0x07), _(0x08) }),
                      .append(new byte[] { b(0x01), b(0x02), b(0x03), b(0x04) })
                      .append(new byte[] { b(0x05), b(0x06), b(0x07), b(0x08) }),
                EIGHT_BYTES },
            { new ByteStringBuilder(3).append(EIGHT_BYTES, 0, 3).append(EIGHT_BYTES, 3, 5),
                EIGHT_BYTES },
@@ -248,16 +248,16 @@
                EIGHT_BYTES },
            { testBuilderFromStream, EIGHT_BYTES },
            { new ByteStringBuilder().append(Short.MIN_VALUE).append(Short.MAX_VALUE),
                new byte[] { _(0x80), _(0x00), _(0x7F), _(0xFF) } },
                new byte[] { b(0x80), b(0x00), b(0x7F), b(0xFF) } },
            {
                new ByteStringBuilder(5).append(Integer.MIN_VALUE).append(Integer.MAX_VALUE),
                new byte[] { _(0x80), _(0x00), _(0x00), _(0x00), _(0x7F),
                    _(0xFF), _(0xFF), _(0xFF) } },
                new byte[] { b(0x80), b(0x00), b(0x00), b(0x00), b(0x7F),
                    b(0xFF), b(0xFF), b(0xFF) } },
            {
                new ByteStringBuilder().append(Long.MIN_VALUE).append(Long.MAX_VALUE),
                new byte[] { _(0x80), _(0x00), _(0x00), _(0x00), _(0x00),
                    _(0x00), _(0x00), _(0x00), _(0x7F), _(0xFF), _(0xFF),
                    _(0xFF), _(0xFF), _(0xFF), _(0xFF), _(0xFF) } },
                new byte[] { b(0x80), b(0x00), b(0x00), b(0x00), b(0x00),
                    b(0x00), b(0x00), b(0x00), b(0x7F), b(0xFF), b(0xFF),
                    b(0xFF), b(0xFF), b(0xFF), b(0xFF), b(0xFF) } },
            { new ByteStringBuilder(11).append("this is a").append(" test"),
                "this is a test".getBytes("UTF-8") },
            { new ByteStringBuilder().append((Object) "this is a").append((Object) " test"),
@@ -270,9 +270,9 @@
                        (Object) " test".toCharArray()), "this is a test".getBytes("UTF-8") },
            {
                new ByteStringBuilder().append((Object) EIGHT_BYTES).append((Object) EIGHT_BYTES),
                new byte[] { _(0x01), _(0x02), _(0x03), _(0x04), _(0x05),
                    _(0x06), _(0x07), _(0x08), _(0x01), _(0x02), _(0x03),
                    _(0x04), _(0x05), _(0x06), _(0x07), _(0x08) } },
                new byte[] { b(0x01), b(0x02), b(0x03), b(0x04), b(0x05),
                    b(0x06), b(0x07), b(0x08), b(0x01), b(0x02), b(0x03),
                    b(0x04), b(0x05), b(0x06), b(0x07), b(0x08) } },
            {
                new ByteStringBuilder().appendBERLength(0x00000000).appendBERLength(0x00000001)
                        .appendBERLength(0x0000000F).appendBERLength(0x00000010).appendBERLength(
@@ -282,16 +282,16 @@
                        .appendBERLength(0x00100000).appendBERLength(0x00FFFFFF).appendBERLength(
                                0x01000000).appendBERLength(0x0FFFFFFF).appendBERLength(0x10000000)
                        .appendBERLength(0xFFFFFFFF),
                new byte[] { _(0x00), _(0x01), _(0x0F), _(0x10), _(0x7F),
                    _(0x81), _(0xFF), _(0x82), _(0x01), _(0x00), _(0x82),
                    _(0x0F), _(0xFF), _(0x82), _(0x10), _(0x00), _(0x82),
                    _(0xFF), _(0xFF), _(0x83), _(0x01), _(0x00), _(0x00),
                    _(0x83), _(0x0F), _(0xFF), _(0xFF), _(0x83), _(0x10),
                    _(0x00), _(0x00), _(0x83), _(0xFF), _(0xFF), _(0xFF),
                    _(0x84), _(0x01), _(0x00), _(0x00), _(0x00), _(0x84),
                    _(0x0F), _(0xFF), _(0xFF), _(0xFF), _(0x84), _(0x10),
                    _(0x00), _(0x00), _(0x00), _(0x84), _(0xFF), _(0xFF),
                    _(0xFF), _(0xFF) } }, };
                new byte[] { b(0x00), b(0x01), b(0x0F), b(0x10), b(0x7F),
                    b(0x81), b(0xFF), b(0x82), b(0x01), b(0x00), b(0x82),
                    b(0x0F), b(0xFF), b(0x82), b(0x10), b(0x00), b(0x82),
                    b(0xFF), b(0xFF), b(0x83), b(0x01), b(0x00), b(0x00),
                    b(0x83), b(0x0F), b(0xFF), b(0xFF), b(0x83), b(0x10),
                    b(0x00), b(0x00), b(0x83), b(0xFF), b(0xFF), b(0xFF),
                    b(0x84), b(0x01), b(0x00), b(0x00), b(0x00), b(0x84),
                    b(0x0F), b(0xFF), b(0xFF), b(0xFF), b(0x84), b(0x10),
                    b(0x00), b(0x00), b(0x00), b(0x84), b(0xFF), b(0xFF),
                    b(0xFF), b(0xFF) } }, };
    }
    @Test
@@ -308,21 +308,21 @@
    public void testSetByte() {
        final ByteStringBuilder builder = new ByteStringBuilder();
        builder.append("this is a ByteString");
        builder.setByte(2, _('a'));
        builder.setByte(3, _('t'));
        builder.setByte(2, b('a'));
        builder.setByte(3, b('t'));
        Assert.assertEquals(builder.toByteString().toString(), "that is a ByteString");
    }
    @Test(expectedExceptions = { IndexOutOfBoundsException.class })
    public void testSetByteAtInvalidLowerIndex() {
        final ByteStringBuilder builder = new ByteStringBuilder();
        builder.setByte(-1, _(0));
        builder.setByte(-1, b(0));
    }
    @Test(expectedExceptions = { IndexOutOfBoundsException.class })
    public void testSetByteAtInvalidUpperIndex() {
        final ByteStringBuilder builder = new ByteStringBuilder();
        builder.setByte(builder.length(), _(0));
        builder.setByte(builder.length(), b(0));
    }
    @Test
opendj-core/src/test/java/org/forgerock/opendj/ldap/GSERParserTestCase.java
@@ -27,11 +27,13 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
/**
 * This class tests the GSERParser.
 */
@SuppressWarnings("javadoc")
public class GSERParserTestCase extends SdkTestCase {
    /**
@@ -39,7 +41,7 @@
     */
    @Test(expectedExceptions = { NullPointerException.class })
    public void testGSERParserInitWithNull() throws Exception {
        GSERParser parser = new GSERParser(null);
        new GSERParser(null);
    }
    /**
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CertificateExactMatchingRuleImplTest.java
@@ -38,6 +38,7 @@
/**
 * This class tests the certificateExactMatch matching rule.
 */
@SuppressWarnings("javadoc")
public class CertificateExactMatchingRuleImplTest extends SchemaTestCase {
    /**
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
@@ -95,9 +95,9 @@
    public Object[][] nonAsciiStringProvider() throws Exception {
        final String nonAsciiChars = "ëéèêœ";
        final String nonAsciiCharsReplacement = new String(
                new byte[] { _(0x65), _(0xcc), _(0x88), _(0x65), _(0xcc),
                    _(0x81), _(0x65), _(0xcc), _(0x80), _(0x65), _(0xcc),
                    _(0x82), _(0xc5), _(0x93), }, "UTF8");
                new byte[] { b(0x65), b(0xcc), b(0x88), b(0x65), b(0xcc),
                    b(0x81), b(0x65), b(0xcc), b(0x80), b(0x65), b(0xcc),
                    b(0x82), b(0xc5), b(0x93), }, "UTF8");
        return new Object[][] {
            { nonAsciiChars, false, false, nonAsciiCharsReplacement },
            { nonAsciiChars, false, true,  nonAsciiCharsReplacement },
@@ -158,7 +158,7 @@
    }
    //@Checkstyle:off
    private byte _(int i) {
    private byte b(int i) {
        return (byte) i;
    }
    //@Checkstyle:on