use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSubstrings1EmptyFinal.
/**
* Test parsing of a request with a Substrings Filter with 1 empty Final element
*/
@Test
public void testRequestWithSubstrings1EmptyFinal() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_empty_final.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
ExprNode filter = searchRequest.getFilter();
assertTrue(filter instanceof SubstringNode);
SubstringNode substringFilter = (SubstringNode) filter;
assertNull(substringFilter.getFinal());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithExtensibleMatchWithMatchingRule.
/**
* Test parsing of a request with a matchingRule attribute
*/
@Test
public void testRequestWithExtensibleMatchWithMatchingRule() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_extensibleMatch_with_matchingRule.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
ExprNode filter = searchRequest.getFilter();
assertTrue(filter instanceof ExtensibleNode);
ExtensibleNode extensibleMatchFilter = (ExtensibleNode) filter;
assertEquals("AMatchingRuleName", extensibleMatchFilter.getMatchingRuleId());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSubstrings1Base64Final.
/**
* Test parsing of a request with a Substrings Filter with 1 Final element
*/
@Test
public void testRequestWithSubstrings1Base64Final() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_base64_final.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
ExprNode filter = searchRequest.getFilter();
assertTrue(filter instanceof SubstringNode);
SubstringNode substringFilter = (SubstringNode) filter;
assertEquals("DSMLv2.0 rocks!!", substringFilter.getFinal().toString());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithAttributes2Attribute.
/**
* Test parsing of a request with an Attributes element with 2 Attribute elements
* @throws NamingException
*/
@Test
public void testRequestWithAttributes2Attribute() throws LdapException {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_attributes_2_attribute.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
List<String> attributes = searchRequest.getAttributes();
assertEquals(2, attributes.size());
String attribute1 = attributes.get(0);
assertEquals("sn", attribute1);
String attribute2 = attributes.get(1);
assertEquals("givenName", attribute2);
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSubstrings1Any1Final.
/**
* Test parsing of a request with a Substrings Filter with 1 Any and 1 Final elements
*/
@Test
public void testRequestWithSubstrings1Any1Final() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_any_1_final.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
ExprNode filter = searchRequest.getFilter();
assertTrue(filter instanceof SubstringNode);
SubstringNode substringFilter = (SubstringNode) filter;
List<String> initials = substringFilter.getAny();
assertEquals(1, initials.size());
assertEquals("kate", initials.get(0));
assertEquals("john", substringFilter.getFinal());
}
Aggregations