use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class SimpleMatchingRuleTestCase method testMatchesSubAny.
/**
* Tests the {@code matchesSubstring} method with a number of value pairs
* that should be considered matches using a subAny element.
*
* @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 testMatchesSubAny(String value1, String value2) throws Exception {
ASN1OctetString value1OS = new ASN1OctetString(value1.trim());
ASN1OctetString value2OS = new ASN1OctetString(value2.trim());
CaseIgnoreStringMatchingRule matchingRule = CaseIgnoreStringMatchingRule.getInstance();
assertTrue(matchingRule.matchesSubstring(value1OS, null, new ASN1OctetString[] { value2OS }, null));
if (matchingRule.normalize(value1OS).getValue().length == 0) {
return;
}
value2OS = new ASN1OctetString(value2.trim() + 'x');
assertFalse(matchingRule.matchesSubstring(value1OS, null, new ASN1OctetString[] { value2OS }, null));
value1OS = new ASN1OctetString(value1.trim() + 'x');
value2OS = new ASN1OctetString(value2.trim());
assertTrue(matchingRule.matchesSubstring(value1OS, null, new ASN1OctetString[] { value2OS }, null));
value1OS = new ASN1OctetString('x' + value1.trim());
assertTrue(matchingRule.matchesSubstring(value1OS, null, new ASN1OctetString[] { value2OS }, null));
value1OS = new ASN1OctetString('x' + value1.trim() + 'x');
assertTrue(matchingRule.matchesSubstring(value1OS, null, new ASN1OctetString[] { value2OS }, null));
value1OS = new ASN1OctetString('x' + value1.trim());
value2OS = new ASN1OctetString(value2.trim() + 'x');
assertFalse(matchingRule.matchesSubstring(value1OS, null, new ASN1OctetString[] { value2OS }, null));
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class SimpleMatchingRuleTestCase method testMatchesSubFinal.
/**
* Tests the {@code matchesSubstring} method with a number of value pairs
* that should be considered matches using a subFinal element.
*
* @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 testMatchesSubFinal(String value1, String value2) throws Exception {
ASN1OctetString value1OS = new ASN1OctetString(value1.trim());
ASN1OctetString value2OS = new ASN1OctetString(value2.trim());
CaseIgnoreStringMatchingRule matchingRule = CaseIgnoreStringMatchingRule.getInstance();
assertTrue(matchingRule.matchesSubstring(value1OS, null, null, value2OS));
if (matchingRule.normalize(value1OS).getValue().length == 0) {
return;
}
value2OS = new ASN1OctetString(value2.trim() + 'x');
assertFalse(matchingRule.matchesSubstring(value1OS, null, null, value2OS));
value1OS = new ASN1OctetString(value1.trim() + 'x');
value2OS = new ASN1OctetString(value2.trim());
assertFalse(matchingRule.matchesSubstring(value1OS, null, null, value2OS));
value1OS = new ASN1OctetString('x' + value1.trim());
assertTrue(matchingRule.matchesSubstring(value1OS, null, null, value2OS));
value1OS = new ASN1OctetString('x' + value1.trim() + 'x');
assertFalse(matchingRule.matchesSubstring(value1OS, null, null, value2OS));
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class TelephoneNumberMatchingRuleTestCase method testNormalizeInvalid.
/**
* Tests the telephone number matching rule with a number of invalid values.
*
* @param invalidValue An invalid value.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "testInvalidValues", expectedExceptions = { LDAPException.class })
public void testNormalizeInvalid(String invalidValue) throws Exception {
TelephoneNumberMatchingRule matchingRule = TelephoneNumberMatchingRule.getInstance();
matchingRule.normalize(new ASN1OctetString(invalidValue));
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class TelephoneNumberMatchingRuleTestCase method testOrderingMatching.
/**
* Tests the telephone number matching rule to ensure that it does not allow
* ordering matching.
*
* @param value1 The first value to compare.
* @param value2 The second value to compare.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "testMatchingValues", expectedExceptions = { LDAPException.class })
public void testOrderingMatching(String value1, String value2) throws Exception {
ASN1OctetString value1OS = new ASN1OctetString(value1);
ASN1OctetString value2OS = new ASN1OctetString(value2);
TelephoneNumberMatchingRule matchingRule = TelephoneNumberMatchingRule.getInstance();
matchingRule.compareValues(value1OS, value2OS);
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class TelephoneNumberMatchingRuleTestCase method testMatchingValues.
/**
* Tests the telephone number 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);
TelephoneNumberMatchingRule matchingRule = TelephoneNumberMatchingRule.getInstance();
assertTrue(matchingRule.valuesMatch(value1OS, value2OS), value1 + ", " + value2);
}
Aggregations