OPENDJ-1630 CR-5560 Fix some matching rules and their tests
Fix AbstractSubstringMatchingRuleImpl.evaluatesEscape() method
Fix SchemaUtils.normalizeNumericStringAttributeValue() method
Fix tests:
- AbstractSubstringMatchingRuleImplTest
- DirectoryStringFirstComponentEqualityMatchingRuleTest
- NumericStringEqualityMatchingRuleTest
- NumericStringOrderingMatchingRuleTest
- NumericStringSubstringMatchingRuleTest
- SchemaUtilsTest
- UniqueMemberEqualityMatchingRuleTest
| | |
| | | valueBuffer.append(evaluateEscapedChar(reader, escapeChars)); |
| | | reader.mark(); |
| | | length = 0; |
| | | continue; |
| | | } |
| | | if (delimiterChars != null) { |
| | | for (final char delimiterChar : delimiterChars) { |
| | |
| | | final StringBuilder buffer = new StringBuilder(); |
| | | prepareUnicode(buffer, value, TRIM, NO_CASE_FOLD); |
| | | |
| | | // Remove any space |
| | | for (int pos = buffer.length() - 1; pos > 0; pos--) { |
| | | char c = buffer.charAt(pos); |
| | | if (c == ' ') { |
| | | buffer.delete(pos, pos + 1); |
| | | } |
| | | } |
| | | |
| | | if (buffer.length() == 0) { |
| | | return ByteString.empty(); |
| | | } |
| | |
| | | { "**" }, |
| | | { "\\g" }, |
| | | { "\\0" }, |
| | | { "\\00" }, |
| | | { "\\0g" }, |
| | | { gen() }, |
| | | }; |
| | | } |
| | | |
| | |
| | | { "this is a string", "this*is*a*string", ConditionResult.TRUE }, |
| | | { "this is a string", "this*my*string", ConditionResult.FALSE }, |
| | | { "this is a string", "string*a*is*this", ConditionResult.FALSE }, |
| | | // FIXME next line is not working (StringIndexOutOfBoundsException), is it incorrect? |
| | | // { "this is a string", "\\00", ConditionResult.FALSE }, |
| | | // FIXME next line is not working (DecodeException), is it incorrect? |
| | | // { "this is a string", gen(), ConditionResult.FALSE }, |
| | | { "this is a string", "string*a*is*this", ConditionResult.FALSE }, |
| | | { "this is a string", "*\\00", ConditionResult.FALSE }, |
| | | { "this is a string", gen() + "*", ConditionResult.FALSE }, |
| | | // initial longer than value |
| | | { "tt", "this*", ConditionResult.FALSE }, |
| | | { "tt", "*this", ConditionResult.FALSE }, |
| | |
| | | |
| | | import static org.forgerock.opendj.ldap.schema.SchemaConstants.EMR_DIRECTORY_STRING_FIRST_COMPONENT_OID; |
| | | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the DirectoryStringFirstComponentEqualityMatchingRule. |
| | | */ |
| | | //TODO: fix matching rule so that commented data in data providers pass |
| | | @Test |
| | | public class DirectoryStringFirstComponentEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | | return new Object[][] { |
| | | //{"(1.2.8.5 NAME 'testtype' DESC 'full type')", "1.2.8.5", ConditionResult.TRUE }, |
| | | //{"(1.2.8.5 NAME 'testtype' DESC 'full type')", "something", ConditionResult.FALSE }, |
| | | { "('full type' 'other value')", "other value", ConditionResult.FALSE }, |
| | | { "('full type' 'other value')", "something", ConditionResult.FALSE }, |
| | | { "('full type' 'other value')", "full type", ConditionResult.TRUE }, |
| | | }; |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the NumericStringEqualityMatchingRule. |
| | | */ |
| | | //TODO: fix matching rule so that commented data in data providers pass |
| | | @Test |
| | | public class NumericStringEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { |
| | | //{"A2B1"} |
| | | }; |
| | | } |
| | | |
| | |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | | return new Object[][] { |
| | | // non-numeric characters are tolerated and treated as significant |
| | | {"A2B1", "A2B1", ConditionResult.TRUE }, |
| | | {"A2B1", "A2b1", ConditionResult.FALSE }, |
| | | {"1234567890", "1234567890", ConditionResult.TRUE }, |
| | | {" 1234567890 ", "1234567890", ConditionResult.TRUE }, |
| | | //{" 123 4567890 ", "1234567890", ConditionResult.TRUE }, |
| | | {" 123 4567890 ", "1234567890", ConditionResult.TRUE }, |
| | | {"1234", "5678", ConditionResult.FALSE }, |
| | | }; |
| | | } |
| | |
| | | import static org.forgerock.opendj.ldap.schema.SchemaConstants.OMR_NUMERIC_STRING_OID; |
| | | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the NumericStringOrderingMatchingRule. |
| | | */ |
| | | //TODO: fix matching rule so that commented data in data providers pass |
| | | @Test |
| | | public class NumericStringOrderingMatchingRuleTest extends OrderingMatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @DataProvider(name = "OrderingMatchingRuleInvalidValues") |
| | | public Object[][] createOrderingMatchingRuleInvalidValues() { |
| | | return new Object[][] { |
| | | //{"jfhslur"}, |
| | | //{"123AB"}, |
| | | }; |
| | | } |
| | | |
| | |
| | | @DataProvider(name = "Orderingmatchingrules") |
| | | public Object[][] createOrderingMatchingRuleTestData() { |
| | | return new Object[][] { |
| | | // non-numeric characters are tolerated and treated as significant |
| | | {"jfhslur", "JFH", 1}, |
| | | {"123AB", "2", -1}, |
| | | {"1", "999999999999999999999", -1}, |
| | | {"1", "9", -1}, |
| | | {"10", "9", -1}, |
| | | {"1 0", "9", -1}, |
| | | {"1", " 1 ", 0}, |
| | | {"0", "1", -1}, |
| | | {"1", "0", 1}, |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the NumericStringSubstringMatchingRule. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test |
| | | public class NumericStringSubstringMatchingRuleTest extends SubstringMatchingRuleTest { |
| | | |
| | | @Override |
| | |
| | | public Object[][] createSubstringFinalMatchData() { |
| | | return new Object[][] { |
| | | {"123456789", "123456789", ConditionResult.TRUE }, |
| | | {"12 345 6789", "123456789", ConditionResult.TRUE }, |
| | | {"123456789", "456789", ConditionResult.TRUE }, |
| | | {"123456789", "567", ConditionResult.FALSE }, |
| | | {"123456789", "123", ConditionResult.FALSE }, |
| | |
| | | { "", "" }, |
| | | { " ", "" }, |
| | | { " 123 ", "123" }, |
| | | { " 123 456 ", "123 456" }, |
| | | { " 123 456 ", "123456" }, |
| | | }; |
| | | } |
| | | |
| | |
| | | |
| | | import org.forgerock.opendj.ldap.ConditionResult; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * Test the UniqueMemberEqualityMatchingRule. |
| | | */ |
| | | //TODO: fix matching rule so that commented data in data providers pass |
| | | @Test |
| | | public class UniqueMemberEqualityMatchingRuleTest extends MatchingRuleTest { |
| | | |
| | | /** {@inheritDoc} */ |
| | |
| | | @DataProvider(name = "matchingRuleInvalidAttributeValues") |
| | | public Object[][] createMatchingRuleInvalidAttributeValues() { |
| | | return new Object[][] { |
| | | //{"1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB#'123'B"}, |
| | | {"1.3.6.1.4.1.1466.01"} |
| | | }; |
| | | } |
| | |
| | | @DataProvider(name = "matchingrules") |
| | | public Object[][] createMatchingRuleTest() { |
| | | return new Object[][] { |
| | | // non-bit string content on optional uid is tolerated |
| | | { "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB#'123'B", |
| | | "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB#'123'B", ConditionResult.TRUE }, |
| | | { "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB#'0101'B", |
| | | "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB#'0101'B", ConditionResult.TRUE }, |
| | | { "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB#'0101'B", |