use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithGreaterOrEqualFilterBase64Value.
/**
* Test parsing of a request with an greaterOrEqual Filter with base64 value
*/
@Test
public void testRequestWithGreaterOrEqualFilterBase64Value() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_greaterOrEqual_base64_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 GreaterEqNode);
GreaterEqNode<?> greaterEqFilter = (GreaterEqNode<?>) filter;
assertEquals("sn", greaterEqFilter.getAttribute());
assertEquals("DSMLv2.0 rocks!!", greaterEqFilter.getValue().getValue());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWith2Controls.
/**
* Test parsing of a request with 2 (optional) Control elements
*/
@Test
public void testRequestWith2Controls() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_2_controls.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
Map<String, Control> controls = searchRequest.getControls();
assertEquals(2, searchRequest.getControls().size());
Control control = controls.get("1.2.840.113556.1.4.789");
assertNotNull(control);
assertFalse(control.isCritical());
assertEquals("1.2.840.113556.1.4.789", control.getOid());
assertEquals("Some other text", Strings.utf8ToString(((DsmlControl<?>) control).getValue()));
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithSizeLimitAttribute.
/**
* Test parsing of a request with the sizeLimit (optional) attribute
* @throws NamingException
*/
@Test
public void testRequestWithSizeLimitAttribute() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_sizeLimit_attribute.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
assertEquals(1000, searchRequest.getSizeLimit());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithTypesOnlyRdn0.
/**
* Test parsing of a request with typesOnly to 0
*/
@Test
public void testRequestWithTypesOnlyRdn0() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_typesOnly_0.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
assertFalse(searchRequest.getTypesOnly());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithEqualityMatchFilterWithEmptyValue.
/**
* Test parsing of a request with an Equality Filter with an empty value
*/
@Test
public void testRequestWithEqualityMatchFilterWithEmptyValue() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_equalityMatch_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 EqualityNode);
EqualityNode<?> equalityFilter = (EqualityNode<?>) filter;
assertEquals("sn", equalityFilter.getAttribute());
assertEquals("", equalityFilter.getValue().getValue());
}
Aggregations