use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class CaseIgnoreListMatchingRuleTestCase method testCompareValues.
/**
* Provides test coverage for the {@code compareValues} method.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testCompareValues() throws Exception {
CaseIgnoreListMatchingRule mr = CaseIgnoreListMatchingRule.getInstance();
mr.compareValues(new ASN1OctetString("foo"), new ASN1OctetString("bar"));
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class CaseIgnoreListMatchingRuleTestCase method testNoItems.
/**
* Performs a set of tests with a list with no items.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testNoItems() throws Exception {
CaseIgnoreListMatchingRule mr = CaseIgnoreListMatchingRule.getInstance();
try {
mr.valuesMatch(new ASN1OctetString("foo"), new ASN1OctetString(""));
fail("Expected an exception from valuesMatch");
} catch (LDAPException le) {
// This was expected.
}
try {
mr.matchesSubstring(new ASN1OctetString(""), new ASN1OctetString("foo"), null, null);
fail("Expected an exception from matchesSubstring");
} catch (LDAPException le) {
// This was expected.
}
try {
CaseIgnoreListMatchingRule.getItems(new ASN1OctetString(""));
fail("Expected an exception from getItems with an octet string");
} catch (LDAPException le) {
// This was expected.
}
try {
CaseIgnoreListMatchingRule.getItems("");
fail("Expected an exception from getItems with a string");
} catch (LDAPException le) {
// This was expected.
}
try {
CaseIgnoreListMatchingRule.getLowercaseItems(new ASN1OctetString(""));
fail("Expected an exception from getLowercaseItems with an octet string");
} catch (LDAPException le) {
// This was expected.
}
try {
CaseIgnoreListMatchingRule.getLowercaseItems("");
fail("Expected an exception from getLowercaseItems with a string");
} catch (LDAPException le) {
// This was expected.
}
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class CaseIgnoreListMatchingRuleTestCase method testSingleItem.
/**
* Performs a set of tests with a list with a single item.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testSingleItem() throws Exception {
CaseIgnoreListMatchingRule mr = CaseIgnoreListMatchingRule.getInstance();
ASN1OctetString normValue = new ASN1OctetString("foo");
assertEquals(mr.normalize(new ASN1OctetString("foo")), normValue);
assertEquals(mr.normalize(new ASN1OctetString("Foo")), normValue);
assertEquals(mr.normalize(new ASN1OctetString("FOO")), normValue);
assertEquals(mr.normalize(new ASN1OctetString(" foo ")), normValue);
assertEquals(mr.normalize(new ASN1OctetString(" fOo ")), normValue);
assertTrue(mr.valuesMatch(new ASN1OctetString("foo"), normValue));
assertTrue(mr.valuesMatch(new ASN1OctetString("Foo"), normValue));
assertTrue(mr.valuesMatch(new ASN1OctetString("FOO"), normValue));
assertTrue(mr.valuesMatch(new ASN1OctetString(" foo "), normValue));
assertTrue(mr.valuesMatch(new ASN1OctetString(" fOo "), normValue));
assertTrue(mr.valuesMatch(new ASN1OctetString(" fOo "), normValue));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), new ASN1OctetString("f"), null, null));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), new ASN1OctetString("F"), null, null));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), new ASN1OctetString("foo"), null, null));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), new ASN1OctetString("FOO"), null, null));
assertFalse(mr.matchesSubstring(new ASN1OctetString("foo"), new ASN1OctetString("oo"), null, null));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), null, null, new ASN1OctetString("o")));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), null, null, new ASN1OctetString("O")));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), null, null, new ASN1OctetString("foo")));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), null, null, new ASN1OctetString("FOO")));
assertFalse(mr.matchesSubstring(new ASN1OctetString("foo"), null, null, new ASN1OctetString("f")));
assertFalse(mr.matchesSubstring(new ASN1OctetString("foo"), null, null, new ASN1OctetString("fo")));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), null, new ASN1OctetString[] { new ASN1OctetString("foo") }, null));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), null, new ASN1OctetString[] { new ASN1OctetString("FOO") }, null));
assertTrue(mr.matchesSubstring(new ASN1OctetString("foo"), new ASN1OctetString("f"), new ASN1OctetString[] { new ASN1OctetString("o") }, new ASN1OctetString("o")));
assertFalse(mr.matchesSubstring(new ASN1OctetString("foo"), new ASN1OctetString("f"), new ASN1OctetString[] { new ASN1OctetString("oo") }, new ASN1OctetString("o")));
List<String> items = CaseIgnoreListMatchingRule.getItems(new ASN1OctetString("Foo"));
assertNotNull(items);
assertEquals(items.size(), 1);
assertEquals(items.get(0), "Foo");
items = CaseIgnoreListMatchingRule.getLowercaseItems(new ASN1OctetString("Foo"));
assertNotNull(items);
assertEquals(items.size(), 1);
assertEquals(items.get(0), "foo");
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class CaseIgnoreStringMatchingRuleTestCase method testMatchingValues.
/**
* Tests the case ignore string matching rule with a number of value pairs
* that should be considered matches.
*
* @param value1 The first value to compare.
* @param value2 The second value to compare.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "testMatchingValues")
public void testMatchingValues(String value1, String value2) throws Exception {
ASN1OctetString value1OS = new ASN1OctetString(value1);
ASN1OctetString value2OS = new ASN1OctetString(value2);
CaseIgnoreStringMatchingRule matchingRule = CaseIgnoreStringMatchingRule.getInstance();
assertTrue(matchingRule.valuesMatch(value1OS, value2OS));
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class CaseIgnoreStringMatchingRuleTestCase method testNonMatchingValues.
/**
* Tests the case ignore string matching rule with a number of value pairs
* that should not be considered matches.
*
* @param value1 The first value to compare.
* @param value2 The second value to compare.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "testNonMatchingValues")
public void testNonMatchingValues(String value1, String value2) throws Exception {
ASN1OctetString value1OS = new ASN1OctetString(value1);
ASN1OctetString value2OS = new ASN1OctetString(value2);
CaseIgnoreStringMatchingRule matchingRule = CaseIgnoreStringMatchingRule.getInstance();
assertFalse(matchingRule.valuesMatch(value1OS, value2OS));
}
Aggregations