use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithOrFilter.
/**
* Test parsing of a request with an Or Filter
*/
@Test
public void testRequestWithOrFilter() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_or.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 OrNode);
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithGreaterOrEqualFilter.
/**
* Test parsing of a request with an greaterOrEqual Filter
*/
@Test
public void testRequestWithGreaterOrEqualFilter() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_greaterOrEqual.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 GreaterEqNode);
GreaterEqNode<?> greaterEqFilter = (GreaterEqNode<?>) filter;
assertEquals("sn", greaterEqFilter.getAttribute());
assertEquals("foobar", greaterEqFilter.getValue().getValue());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithApproxMatchFilter.
/**
* Test parsing of a request with an approxMatch Filter
*/
@Test
public void testRequestWithApproxMatchFilter() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_approxMatch.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 ApproximateNode);
ApproximateNode<?> approxMatchFilter = (ApproximateNode<?>) filter;
assertEquals("sn", approxMatchFilter.getAttribute());
assertEquals("foobar", approxMatchFilter.getValue().getValue());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSubstrings1Base64Initial.
/**
* Test parsing of a request with a Substrings Filter with 1 Initial element with Base64 value
*/
@Test
public void testRequestWithSubstrings1Base64Initial() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_base64_initial.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.getInitial().toString());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithApproxMatchFilterEmptyValue.
/**
* Test parsing of a request with an approxMatch Filter with empty value
*/
@Test
public void testRequestWithApproxMatchFilterEmptyValue() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_approxMatch_with_empty_value.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 ApproximateNode);
ApproximateNode<?> approxMatchFilter = (ApproximateNode<?>) filter;
assertEquals("sn", approxMatchFilter.getAttribute());
assertEquals("", approxMatchFilter.getValue().getValue());
}
Aggregations