use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithExtensibleMatchWithDnAttributesFalse.
/**
* Test parsing of a request with typesOnly to false
*/
@Test
public void testRequestWithExtensibleMatchWithDnAttributesFalse() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_extensibleMatch_with_dnAttributes_false.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;
assertFalse(extensibleMatchFilter.hasDnAttributes());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWith1ControlBase64Value.
/**
* Test parsing of a request with a (optional) Control element with Base64 value
*/
@Test
public void testRequestWith1ControlBase64Value() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_1_control_base64_value.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(1, searchRequest.getControls().size());
Control control = controls.get("1.2.840.113556.1.4.643");
assertNotNull(control);
assertTrue(control.isCritical());
assertEquals("1.2.840.113556.1.4.643", control.getOid());
assertEquals("DSMLv2.0 rocks!!", Strings.utf8ToString(((DsmlControl<?>) control).getValue()));
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithScopeWholeSubtree.
/**
* Test parsing of a request with scope attribute to WholeSubtree value
* @throws NamingException
*/
@Test
public void testRequestWithScopeWholeSubtree() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_scope_wholeSubtree.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
assertEquals(SearchScope.SUBTREE, searchRequest.getScope());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithDerefAliasesDerefAlways.
/**
* Test parsing of a request with derefAliases attribute to derefAlways value
* @throws NamingException
*/
@Test
public void testRequestWithDerefAliasesDerefAlways() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_derefAliases_derefAlways.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
assertEquals(AliasDerefMode.DEREF_ALWAYS, searchRequest.getDerefAliases());
}
use of org.apache.directory.api.dsmlv2.Dsmlv2Parser in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithExtensibleMatchFilterBase64Value.
/**
* Test parsing of a request with an ExtensibleMatch Filter
*/
@Test
public void testRequestWithExtensibleMatchFilterBase64Value() {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("filters/request_with_extensibleMatch_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 ExtensibleNode);
ExtensibleNode extensibleMatchFilter = (ExtensibleNode) filter;
assertEquals("DSMLv2.0 rocks!!", extensibleMatchFilter.getValue().getValue());
assertEquals(false, extensibleMatchFilter.hasDnAttributes());
}
Aggregations