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

Jean-Noel Rouvignac
06.41.2014 0093f3526b3e3427a6a8a0e4a97a6b27f7906bb8
SubstringMatchingRuleTest.java:
Added strings() + used it in all subclasses.
5 files modified
236 ■■■■ changed files
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleTest.java 56 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleTest.java 52 ●●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleTest.java 64 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleTest.java 60 ●●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java 4 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactIA5SubstringMatchingRuleTest.java
@@ -33,14 +33,16 @@
/**
 * Test the CaseExactIA5SubstringMatchingRule.
 */
@SuppressWarnings("javadoc")
public class CaseExactIA5SubstringMatchingRuleTest extends SubstringMatchingRuleTest {
    @Override
    @DataProvider(name = "substringInvalidAssertionValues")
    public Object[][] createMatchingRuleInvalidAssertionValues() {
        return new Object[][] { { "12345678\uFFFD", new String[0], null },
            { null, new String[] { "12345678\uFFFD" }, null },
            { null, new String[0], "12345678\uFFFD" }, };
        return new Object[][] {
            { "12345678\uFFFD", new String[0], null },
            { null, strings("12345678\uFFFD"), null },
            { null, strings(), "12345678\uFFFD" }, };
    }
    @Override
@@ -49,13 +51,12 @@
        return new Object[][] { { "12345678\uFFFD" }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringFinalMatchData")
    public Object[][] createSubstringFinalMatchData() {
        return new Object[][] { { "this is a value", "value", ConditionResult.TRUE },
        return new Object[][] {
            { "this is a value", "value", ConditionResult.TRUE },
            { "this is a value", "alue", ConditionResult.TRUE },
            { "this is a value", "ue", ConditionResult.TRUE },
            { "this is a value", "e", ConditionResult.TRUE },
@@ -68,13 +69,12 @@
            { "end with space    ", "space", ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringInitialMatchData")
    public Object[][] createSubstringInitialMatchData() {
        return new Object[][] { { "this is a value", "this", ConditionResult.TRUE },
        return new Object[][] {
            { "this is a value", "this", ConditionResult.TRUE },
            { "this is a value", "th", ConditionResult.TRUE },
            { "this is a value", "t", ConditionResult.TRUE },
            { "this is a value", "is", ConditionResult.FALSE },
@@ -85,33 +85,29 @@
            { "this is a value", "THIS", ConditionResult.FALSE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringMiddleMatchData")
    public Object[][] createSubstringMiddleMatchData() {
        return new Object[][] {
            { "this is a value", new String[] { "this" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "is" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "a" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "value" }, ConditionResult.TRUE },
            { "this is a value", new String[] { " " }, ConditionResult.TRUE },
            { "this is a value", new String[] { "this", "is", "a", "value" }, ConditionResult.TRUE },
            { "this is a value", strings("this"), ConditionResult.TRUE },
            { "this is a value", strings("is"), ConditionResult.TRUE },
            { "this is a value", strings("a"), ConditionResult.TRUE },
            { "this is a value", strings("value"), ConditionResult.TRUE },
            { "this is a value", strings(" "), ConditionResult.TRUE },
            { "this is a value", strings("this", "is", "a", "value"), ConditionResult.TRUE },
            // The matching rule requires ordered non overlapping substrings
            // Issue #730 was not valid.
            { "this is a value", new String[] { "value", "this" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "this is" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "his is", "a val", }, ConditionResult.TRUE },
            { "this is a value", new String[] { "not", }, ConditionResult.FALSE },
            { "this is a value", new String[] { "THIS", }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "not" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "    " }, ConditionResult.TRUE }, };
            { "this is a value", strings("value", "this"), ConditionResult.FALSE },
            { "this is a value", strings("this", "this is"), ConditionResult.FALSE },
            { "this is a value", strings("his is", "a val"), ConditionResult.TRUE },
            { "this is a value", strings("not"), ConditionResult.FALSE },
            { "this is a value", strings("THIS"), ConditionResult.FALSE },
            { "this is a value", strings("this", "not"), ConditionResult.FALSE },
            { "this is a value", strings("    "), ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    protected MatchingRule getRule() {
        return Schema.getCoreSchema().getMatchingRule(SMR_CASE_EXACT_IA5_OID);
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseExactSubstringMatchingRuleTest.java
@@ -33,6 +33,7 @@
/**
 * Test the CaseExactSubstringMatchingRule class.
 */
@SuppressWarnings("javadoc")
public class CaseExactSubstringMatchingRuleTest extends SubstringMatchingRuleTest {
    @Override
@@ -47,13 +48,12 @@
        return new Object[][] {};
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringFinalMatchData")
    public Object[][] createSubstringFinalMatchData() {
        return new Object[][] { { "this is a value", "value", ConditionResult.TRUE },
        return new Object[][] {
            { "this is a value", "value", ConditionResult.TRUE },
            { "this is a value", "alue", ConditionResult.TRUE },
            { "this is a value", "ue", ConditionResult.TRUE },
            { "this is a value", "e", ConditionResult.TRUE },
@@ -66,13 +66,12 @@
            { "end with space    ", "space", ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringInitialMatchData")
    public Object[][] createSubstringInitialMatchData() {
        return new Object[][] { { "this is a value", "this", ConditionResult.TRUE },
        return new Object[][] {
            { "this is a value", "this", ConditionResult.TRUE },
            { "this is a value", "th", ConditionResult.TRUE },
            { "this is a value", "t", ConditionResult.TRUE },
            { "this is a value", "is", ConditionResult.FALSE },
@@ -83,34 +82,29 @@
            { "this is a value", "THIS", ConditionResult.FALSE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringMiddleMatchData")
    public Object[][] createSubstringMiddleMatchData() {
        return new Object[][] {
            { "this is a value", new String[] { "this" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "is" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "a" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "value" }, ConditionResult.TRUE },
            { "this is a value", new String[] { " " }, ConditionResult.TRUE },
            { "this is a value", new String[] { "this", "is", "a", "value" }, ConditionResult.TRUE },
            // The matching rule requires ordered non overlapping
            // substrings.
            { "this is a value", strings("this"), ConditionResult.TRUE },
            { "this is a value", strings("is"), ConditionResult.TRUE },
            { "this is a value", strings("a"), ConditionResult.TRUE },
            { "this is a value", strings("value"), ConditionResult.TRUE },
            { "this is a value", strings(" "), ConditionResult.TRUE },
            { "this is a value", strings("this", "is", "a", "value"), ConditionResult.TRUE },
            // The matching rule requires ordered non overlapping substrings.
            // Issue #730 was not valid.
            { "this is a value", new String[] { "value", "this" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "this is" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "his is", "a val", }, ConditionResult.TRUE },
            { "this is a value", new String[] { "not", }, ConditionResult.FALSE },
            { "this is a value", new String[] { "THIS", }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "not" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "    " }, ConditionResult.TRUE }, };
            { "this is a value", strings("value", "this"), ConditionResult.FALSE },
            { "this is a value", strings("this", "this is"), ConditionResult.FALSE },
            { "this is a value", strings("his is", "a val"), ConditionResult.TRUE },
            { "this is a value", strings("not"), ConditionResult.FALSE },
            { "this is a value", strings("THIS"), ConditionResult.FALSE },
            { "this is a value", strings("this", "not"), ConditionResult.FALSE },
            { "this is a value", strings("    "), ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    protected MatchingRule getRule() {
        return Schema.getCoreSchema().getMatchingRule(SMR_CASE_EXACT_OID);
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreIA5SubstringMatchingRuleTest.java
@@ -33,13 +33,14 @@
/**
 * Test the CaseIgnoreIA5SubstringMatchingRule.
 */
@SuppressWarnings("javadoc")
public class CaseIgnoreIA5SubstringMatchingRuleTest extends SubstringMatchingRuleTest {
    @DataProvider(name = "substringInvalidAssertionValues")
    public Object[][] createMatchingRuleInvalidAssertionValues() {
        return new Object[][] { { "12345678\uFFFD", new String[0], null },
            { null, new String[] { "12345678\uFFFD" }, null },
            { null, new String[0], "12345678\uFFFD" }, };
            { null, strings("12345678\uFFFD"), null },
            { null, strings(), "12345678\uFFFD" }, };
    }
    @DataProvider(name = "substringInvalidAttributeValues")
@@ -47,13 +48,12 @@
        return new Object[][] { { "12345678\uFFFD" }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringFinalMatchData")
    public Object[][] createSubstringFinalMatchData() {
        return new Object[][] { { "this is a value", "value", ConditionResult.TRUE },
        return new Object[][] {
            { "this is a value", "value", ConditionResult.TRUE },
            { "this is a value", "alue", ConditionResult.TRUE },
            { "this is a value", "ue", ConditionResult.TRUE },
            { "this is a value", "e", ConditionResult.TRUE },
@@ -72,13 +72,12 @@
            { "end with space    ", "SPACE", ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringInitialMatchData")
    public Object[][] createSubstringInitialMatchData() {
        return new Object[][] { { "this is a value", "this", ConditionResult.TRUE },
        return new Object[][] {
            { "this is a value", "this", ConditionResult.TRUE },
            { "this is a value", "th", ConditionResult.TRUE },
            { "this is a value", "t", ConditionResult.TRUE },
            { "this is a value", "is", ConditionResult.FALSE },
@@ -93,38 +92,33 @@
            { "this is a value", "THIS", ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringMiddleMatchData")
    public Object[][] createSubstringMiddleMatchData() {
        return new Object[][] {
            { "this is a value", new String[] { "this" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "is" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "a" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "value" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "THIS" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "IS" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "A" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "VALUE" }, ConditionResult.TRUE },
            { "this is a value", new String[] { " " }, ConditionResult.TRUE },
            { "this is a value", new String[] { "this", "is", "a", "value" }, ConditionResult.TRUE },
            // The matching rule requires ordered non overlapping
            // substrings.
            { "this is a value", strings("this"), ConditionResult.TRUE },
            { "this is a value", strings("is"), ConditionResult.TRUE },
            { "this is a value", strings("a"), ConditionResult.TRUE },
            { "this is a value", strings("value"), ConditionResult.TRUE },
            { "this is a value", strings("THIS"), ConditionResult.TRUE },
            { "this is a value", strings("IS"), ConditionResult.TRUE },
            { "this is a value", strings("A"), ConditionResult.TRUE },
            { "this is a value", strings("VALUE"), ConditionResult.TRUE },
            { "this is a value", strings(" "), ConditionResult.TRUE },
            { "this is a value", strings("this", "is", "a", "value"), ConditionResult.TRUE },
            // The matching rule requires ordered non overlapping substrings.
            // Issue #730 was not valid.
            { "this is a value", new String[] { "value", "this" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "this is" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "IS", "a", "VALue" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "his IS", "A val", }, ConditionResult.TRUE },
            { "this is a value", new String[] { "not", }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "not" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "    " }, ConditionResult.TRUE }, };
            { "this is a value", strings("value", "this"), ConditionResult.FALSE },
            { "this is a value", strings("this", "this is"), ConditionResult.FALSE },
            { "this is a value", strings("this", "IS", "a", "VALue"), ConditionResult.TRUE },
            { "this is a value", strings("his IS", "A val"), ConditionResult.TRUE },
            { "this is a value", strings("not"), ConditionResult.FALSE },
            { "this is a value", strings("this", "not"), ConditionResult.FALSE },
            { "this is a value", strings("    "), ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    protected MatchingRule getRule() {
        return Schema.getCoreSchema().getMatchingRule(SMR_CASE_IGNORE_IA5_OID);
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/CaseIgnoreSubstringMatchingRuleTest.java
@@ -33,6 +33,7 @@
/**
 * Test the CaseIgnoreSubstringMatchingRule.
 */
@SuppressWarnings("javadoc")
public class CaseIgnoreSubstringMatchingRuleTest extends SubstringMatchingRuleTest {
    @DataProvider(name = "substringInvalidAssertionValues")
@@ -45,13 +46,12 @@
        return new Object[][] {};
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringFinalMatchData")
    public Object[][] createSubstringFinalMatchData() {
        return new Object[][] { { "this is a value", "value", ConditionResult.TRUE },
        return new Object[][] {
            { "this is a value", "value", ConditionResult.TRUE },
            { "this is a value", "alue", ConditionResult.TRUE },
            { "this is a value", "ue", ConditionResult.TRUE },
            { "this is a value", "e", ConditionResult.TRUE },
@@ -70,13 +70,12 @@
            { "end with space    ", "SPACE", ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringInitialMatchData")
    public Object[][] createSubstringInitialMatchData() {
        return new Object[][] { { "this is a value", "this", ConditionResult.TRUE },
        return new Object[][] {
            { "this is a value", "this", ConditionResult.TRUE },
            { "this is a value", "th", ConditionResult.TRUE },
            { "this is a value", "t", ConditionResult.TRUE },
            { "this is a value", "is", ConditionResult.FALSE },
@@ -91,38 +90,33 @@
            { "this is a value", "THIS", ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    @DataProvider(name = "substringMiddleMatchData")
    public Object[][] createSubstringMiddleMatchData() {
        return new Object[][] {
            { "this is a value", new String[] { "this" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "is" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "a" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "value" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "THIS" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "IS" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "A" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "VALUE" }, ConditionResult.TRUE },
            { "this is a value", new String[] { " " }, ConditionResult.TRUE },
            { "this is a value", new String[] { "this", "is", "a", "value" }, ConditionResult.TRUE },
            // The matching rule requires ordered non overlapping
            // substrings.
            { "this is a value", strings("this"), ConditionResult.TRUE },
            { "this is a value", strings("is"), ConditionResult.TRUE },
            { "this is a value", strings("a"), ConditionResult.TRUE },
            { "this is a value", strings("value"), ConditionResult.TRUE },
            { "this is a value", strings("THIS"), ConditionResult.TRUE },
            { "this is a value", strings("IS"), ConditionResult.TRUE },
            { "this is a value", strings("A"), ConditionResult.TRUE },
            { "this is a value", strings("VALUE"), ConditionResult.TRUE },
            { "this is a value", strings(" "), ConditionResult.TRUE },
            { "this is a value", strings("this", "is", "a", "value"), ConditionResult.TRUE },
            // The matching rule requires ordered non overlapping substrings.
            // Issue #730 was not valid.
            { "this is a value", new String[] { "value", "this" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "this is" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "IS", "a", "VALue" }, ConditionResult.TRUE },
            { "this is a value", new String[] { "his IS", "A val", }, ConditionResult.TRUE },
            { "this is a value", new String[] { "not", }, ConditionResult.FALSE },
            { "this is a value", new String[] { "this", "not" }, ConditionResult.FALSE },
            { "this is a value", new String[] { "    " }, ConditionResult.TRUE }, };
            { "this is a value", strings("value", "this"), ConditionResult.FALSE },
            { "this is a value", strings("this", "this is"), ConditionResult.FALSE },
            { "this is a value", strings("this", "IS", "a", "VALue"), ConditionResult.TRUE },
            { "this is a value", strings("his IS", "A val"), ConditionResult.TRUE },
            { "this is a value", strings("not"), ConditionResult.FALSE },
            { "this is a value", strings("this", "not"), ConditionResult.FALSE },
            { "this is a value", strings("    "), ConditionResult.TRUE }, };
    }
    /**
     * {@inheritDoc}
     */
    /** {@inheritDoc} */
    @Override
    protected MatchingRule getRule() {
        return Schema.getCoreSchema().getMatchingRule(SMR_CASE_IGNORE_OID);
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SubstringMatchingRuleTest.java
@@ -219,4 +219,8 @@
     * @return An instance of the matching rule to test.
     */
    protected abstract MatchingRule getRule();
    protected String[] strings(String... strings) {
        return strings;
    }
}