use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class BooleanMatchingRuleTestCase method testMatchesAnyValue.
/**
* Provides test coverage for the {@code matchesAnyValue} method.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testMatchesAnyValue() throws Exception {
final BooleanMatchingRule mr = BooleanMatchingRule.getInstance();
final ASN1OctetString assertionValue = new ASN1OctetString("TRUE");
assertFalse(mr.matchesAnyValue(assertionValue, null));
assertFalse(mr.matchesAnyValue(assertionValue, new ASN1OctetString[0]));
final ASN1OctetString[] attributeValues = { new ASN1OctetString("not a valid Boolean"), new ASN1OctetString("TRUE") };
assertFalse(mr.matchesAnyValue(null, attributeValues));
assertTrue(mr.matchesAnyValue(assertionValue, attributeValues));
assertTrue(mr.matchesAnyValue(new ASN1OctetString("true"), attributeValues));
assertTrue(mr.matchesAnyValue(new ASN1OctetString("True"), attributeValues));
assertFalse(mr.matchesAnyValue(new ASN1OctetString("FALSE"), attributeValues));
try {
mr.matchesAnyValue(new ASN1OctetString("malformed"), attributeValues);
fail("Expected an LDAP exception when providing a malformed assertion " + "value");
} catch (final LDAPException le) {
// This was expected.
}
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class BooleanMatchingRuleTestCase method testTrueValues.
/**
* Performs a number of tests with values that should resolve to "TRUE".
*
* @param value The value to test.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "trueValues")
public void testTrueValues(String value) throws Exception {
BooleanMatchingRule mr = BooleanMatchingRule.getInstance();
assertTrue(mr.valuesMatch(new ASN1OctetString(value), new ASN1OctetString("TRUE")));
assertEquals(mr.normalize(new ASN1OctetString(value)), new ASN1OctetString("TRUE"));
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class CaseExactStringMatchingRuleTestCase method testNormalizeSubstring.
/**
* Tests the {@code normalizeSubstring} method with the provided information.
*
* @param rawValue The raw value to be normalized.
* @param substringType The substring type to use when performing the
* normalization.
* @param normalizedValue The expected normalized representation of the
* provided value.
*/
@Test(dataProvider = "testNormalizeSubstringValues")
public void testNormalizeSubstring(String rawValue, byte substringType, String normalizedValue) {
ASN1OctetString rawOS = new ASN1OctetString(rawValue);
CaseExactStringMatchingRule matchingRule = CaseExactStringMatchingRule.getInstance();
ASN1OctetString gotOS = matchingRule.normalizeSubstring(rawOS, substringType);
assertEquals(gotOS.stringValue(), normalizedValue);
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class IntegerMatchingRuleTestCase method testMatchesSubstring.
/**
* Tests the {@code matchesSubstring} method to ensure that it throws an
* exception.
*
* @param valueStr The string representation of the value.
* @param bigInt The parsed value.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "validValues", expectedExceptions = { LDAPException.class })
public void testMatchesSubstring(String valueStr, BigInteger bigInt) throws Exception {
IntegerMatchingRule mr = IntegerMatchingRule.getInstance();
mr.matchesSubstring(new ASN1OctetString(valueStr), new ASN1OctetString(valueStr), null, null);
}
use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.
the class NumericStringMatchingRuleTestCase method testNormalizeSubstring.
/**
* Tests the {@code normalizeSubstring} method with the provided information.
*
* @param rawValue The raw value to be normalized.
* @param normalizedValue The expected normalized representation of the
* provided value.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(dataProvider = "testMatchingValues")
public void testNormalizeSubstring(String rawValue, String normalizedValue) throws Exception {
ASN1OctetString rawOS = new ASN1OctetString(rawValue);
NumericStringMatchingRule matchingRule = NumericStringMatchingRule.getInstance();
assertEquals(matchingRule.normalizeSubstring(rawOS, SUBSTRING_TYPE_SUBINITIAL).stringValue(), normalizedValue);
assertEquals(matchingRule.normalizeSubstring(rawOS, SUBSTRING_TYPE_SUBANY).stringValue(), normalizedValue);
assertEquals(matchingRule.normalizeSubstring(rawOS, SUBSTRING_TYPE_SUBFINAL).stringValue(), normalizedValue);
}
Aggregations