From 4d05eea8a9d06056e422f3203b77aefd49a5dcd0 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Thu, 04 Dec 2014 17:11:27 +0000
Subject: [PATCH] OPENDJ-1630 CR-5560 Fix some matching rules and their tests
---
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringOrderingMatchingRuleTest.java | 10 +++++++---
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/DirectoryStringFirstComponentEqualityMatchingRuleTest.java | 9 ++++++---
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringSubstringMatchingRuleTest.java | 3 +++
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java | 2 +-
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleTest.java | 7 +++++--
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java | 9 +++++----
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java | 8 ++++++++
opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringEqualityMatchingRuleTest.java | 9 ++++++---
opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java | 1 +
9 files changed, 42 insertions(+), 16 deletions(-)
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
index 85a7b16..c2acdcc 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImpl.java
@@ -508,6 +508,7 @@
valueBuffer.append(evaluateEscapedChar(reader, escapeChars));
reader.mark();
length = 0;
+ continue;
}
if (delimiterChars != null) {
for (final char delimiterChar : delimiterChars) {
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
index 443627b..bb53236 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/SchemaUtils.java
@@ -771,6 +771,14 @@
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();
}
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java
index 47f5600..98846a0 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/AbstractSubstringMatchingRuleImplTest.java
@@ -152,7 +152,9 @@
{ "**" },
{ "\\g" },
{ "\\0" },
+ { "\\00" },
{ "\\0g" },
+ { gen() },
};
}
@@ -170,10 +172,9 @@
{ "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 },
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/DirectoryStringFirstComponentEqualityMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/DirectoryStringFirstComponentEqualityMatchingRuleTest.java
index 094de8a..bcc92a9 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/DirectoryStringFirstComponentEqualityMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/DirectoryStringFirstComponentEqualityMatchingRuleTest.java
@@ -27,12 +27,14 @@
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} */
@@ -47,8 +49,9 @@
@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 },
};
}
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringEqualityMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringEqualityMatchingRuleTest.java
index 6c8b7c5..0e53965 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringEqualityMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringEqualityMatchingRuleTest.java
@@ -29,11 +29,12 @@
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} */
@@ -41,7 +42,6 @@
@DataProvider(name = "matchingRuleInvalidAttributeValues")
public Object[][] createMatchingRuleInvalidAttributeValues() {
return new Object[][] {
- //{"A2B1"}
};
}
@@ -50,9 +50,12 @@
@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 },
};
}
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringOrderingMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringOrderingMatchingRuleTest.java
index 096d2cc..d89fcd0 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringOrderingMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringOrderingMatchingRuleTest.java
@@ -28,11 +28,12 @@
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} */
@@ -40,8 +41,6 @@
@DataProvider(name = "OrderingMatchingRuleInvalidValues")
public Object[][] createOrderingMatchingRuleInvalidValues() {
return new Object[][] {
- //{"jfhslur"},
- //{"123AB"},
};
}
@@ -50,8 +49,13 @@
@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},
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringSubstringMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringSubstringMatchingRuleTest.java
index d2a2201..e3bbce3 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringSubstringMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/NumericStringSubstringMatchingRuleTest.java
@@ -29,11 +29,13 @@
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
@@ -56,6 +58,7 @@
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 },
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
index f5daa5f..ec290dd 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/SchemaUtilsTest.java
@@ -249,7 +249,7 @@
{ "", "" },
{ " ", "" },
{ " 123 ", "123" },
- { " 123 456 ", "123 456" },
+ { " 123 456 ", "123456" },
};
}
diff --git a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleTest.java b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleTest.java
index 75a85d2..4b37615 100644
--- a/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleTest.java
+++ b/opendj-core/src/test/java/org/forgerock/opendj/ldap/schema/UniqueMemberEqualityMatchingRuleTest.java
@@ -29,11 +29,12 @@
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} */
@@ -41,7 +42,6 @@
@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"}
};
}
@@ -51,6 +51,9 @@
@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",
--
Gitblit v1.10.0