}
public void test_encodeValues() {
// simple filter
filter = new Filter(Filter.APPROX_MATCH_FILTER);
filter.setValue(new AttributeTypeAndValuePair("cn", "test"));
ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);
// composite filter
filter = new Filter(Filter.AND_FILTER);
Filter equal = new Filter(Filter.EQUALITY_MATCH_FILTER);
equal.setValue(new AttributeTypeAndValuePair("sn", "tom"));
filter.addChild(equal);
Filter substring = new Filter(Filter.SUBSTRINGS_FILTER);
SubstringFilter sub = new SubstringFilter("o");
sub.addAny("harmony");
sub.addFinal("good");
substring.setValue(sub);
filter.addChild(substring);
Filter present = new Filter(Filter.PRESENT_FILTER);
present.setValue("objectClass");
filter.addChild(present);
ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);
// more complex filter
Filter or = new Filter(Filter.OR_FILTER);
Filter not = new Filter(Filter.NOT_FILTER);
Filter greater = new Filter(Filter.GREATER_OR_EQUAL_FILTER);
greater.setValue(new AttributeTypeAndValuePair("cn", "hello"));
not.setValue(greater);
or.addChild(not);
Filter less = new Filter(Filter.LESS_OR_EQUAL_FILTER);
less.setValue(new AttributeTypeAndValuePair("o", "apache"));
or.addChild(less);
filter.addChild(or);
ASN1TestUtils.checkEncode(filter, LdapASN1Constant.Filter);
}