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

Jean-Noel Rouvignac
13.32.2015 cccd29885e414f5dff42fb11101d64abe9870ca4
Code cleanup
4 files modified
55 ■■■■ changed files
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java 23 ●●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxTest.java 14 ●●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/JPEGSyntaxTest.java 15 ●●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java 3 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSyntaxTestCase.java
@@ -22,11 +22,11 @@
 *
 *
 *      Copyright 2009 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS.
 *      Portions copyright 2014-2015 ForgeRock AS.
 */
package org.forgerock.opendj.ldap.schema;
import static org.testng.Assert.fail;
import static org.testng.Assert.*;
import org.forgerock.i18n.LocalizableMessageBuilder;
import org.forgerock.opendj.ldap.ByteString;
@@ -34,9 +34,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
 * Syntax tests.
 */
/** Syntax tests. */
@SuppressWarnings("javadoc")
public abstract class AbstractSyntaxTestCase extends AbstractSchemaTestCase {
    /**
@@ -49,27 +47,22 @@
    @DataProvider(name = "acceptableValues")
    public abstract Object[][] createAcceptableValues();
    /**
     * Test the normalization and the approximate comparison.
     */
    /** Test the normalization and the approximate comparison. */
    @Test(dataProvider = "acceptableValues")
    public void testAcceptableValues(final String value, final Boolean result) throws Exception {
        // Make sure that the specified class can be instantiated as a task.
        final Syntax syntax = getRule();
        final LocalizableMessageBuilder reason = new LocalizableMessageBuilder();
        // test the valueIsAcceptable method
        final Boolean liveResult = syntax.valueIsAcceptable(ByteString.valueOf(value), reason);
        if (!liveResult.equals(result)) {
            fail(syntax + ".valueIsAcceptable gave bad result for " + value + "reason : " + reason);
        }
        assertEquals(liveResult, result,
            syntax + ".valueIsAcceptable gave bad result for " + value + "reason : " + reason);
    }
    /**
     * Get an instance of the attribute syntax that muste be tested.
     * Get an instance of the attribute syntax that must be tested.
     *
     * @return An instance of the attribute syntax that muste be tested.
     * @return An instance of the attribute syntax that must be tested.
     */
    protected abstract Syntax getRule() throws SchemaException, DecodeException;
}
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/BitStringSyntaxTest.java
@@ -31,17 +31,21 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
 * Bit string syntax tests.
 */
/** Bit string syntax tests. */
@Test
public class BitStringSyntaxTest extends AbstractSyntaxTestCase {
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "acceptableValues")
    public Object[][] createAcceptableValues() {
        return new Object[][] { { "'0101'B", true }, { "'1'B", true }, { "'0'B", true }, { "invalid", false },
            { "1", false }, { "'010100000111111010101000'B", true }, };
        return new Object[][] {
            { "'0101'B", true },
            { "'1'B", true },
            { "'0'B", true },
            { "invalid", false },
            { "1", false },
            { "'010100000111111010101000'B", true },
        };
    }
    /** {@inheritDoc} */
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/JPEGSyntaxTest.java
@@ -86,15 +86,12 @@
            "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAMAAAAoyzS7AAAABlBMVEX/JgAAAAAP"
            + "IsinAAAACklEQVQImWNgAAAAAgAB9HFkpgAAAABJRU5ErkJggg==";
        try {
            return new Object[][] {
                { ByteString.valueOfBase64(nonImage), false },
                { ByteString.valueOfBase64(jfifImage), true },
                { ByteString.valueOfBase64(exifImage), true },
                { ByteString.valueOfBase64(pngImage), false } };
        } catch (Exception e) {
            return new Object[][] {};
        }
        return new Object[][] {
            { ByteString.valueOfBase64(nonImage), false },
            { ByteString.valueOfBase64(jfifImage), true },
            { ByteString.valueOfBase64(exifImage), true },
            { ByteString.valueOfBase64(pngImage), false }
        };
    }
    /** Test acceptable values for this syntax when not allowing malformed JPEG photos. */
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaBuilderTestCase.java
@@ -1200,7 +1200,8 @@
        // directoryOperation can't inherit from userApplications
        scBuild.addAttributeType("(1.2.8.5 NAME 'testtype' DESC 'full type' OBSOLETE SUP cn "
                + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch" + " SUBSTR caseIgnoreSubstringsMatch"
                + " EQUALITY caseIgnoreMatch ORDERING caseIgnoreOrderingMatch"
                + " SUBSTR caseIgnoreSubstringsMatch"
                + " SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE"
                + " NO-USER-MODIFICATION USAGE directoryOperation )", true);
        scBuild.addSchema(Schema.getCoreSchema(), false);