Search in sources :

Example 1 with SearchRequestDsml

use of org.apache.directory.api.dsmlv2.request.SearchRequestDsml in project directory-ldap-api by apache.

the class SearchRequestTest method testRequestWithNestedNodes.

/**
 * Test parsing of a request with a nested nodes DIRSHARED-137
 */
@Test
public void testRequestWithNestedNodes() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(SearchRequestTest.class.getResource("filters/request_with_nested_connector_nodes.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchRequestDsml searchRequest = (SearchRequestDsml) parser.getBatchRequest().getCurrentRequest();
    ExprNode filter = searchRequest.getFilter();
    assertTrue(filter instanceof AndNode);
    assertEquals("(&(|(sn=*foo*)(cn=*foo*))(|(ou=*josopuram*)(o=*k*)))", filter.toString());
// System.out.println( searchRequest.toDsml( new DefaultElement( "root" ) ).asXML() );
}
Also used : ExprNode(org.apache.directory.api.ldap.model.filter.ExprNode) SearchRequestDsml(org.apache.directory.api.dsmlv2.request.SearchRequestDsml) AndNode(org.apache.directory.api.ldap.model.filter.AndNode) Dsmlv2Parser(org.apache.directory.api.dsmlv2.Dsmlv2Parser) LdapException(org.apache.directory.api.ldap.model.exception.LdapException) Test(org.junit.Test) AbstractTest(org.apache.directory.api.dsmlv2.AbstractTest)

Aggregations

AbstractTest (org.apache.directory.api.dsmlv2.AbstractTest)1 Dsmlv2Parser (org.apache.directory.api.dsmlv2.Dsmlv2Parser)1 SearchRequestDsml (org.apache.directory.api.dsmlv2.request.SearchRequestDsml)1 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)1 AndNode (org.apache.directory.api.ldap.model.filter.AndNode)1 ExprNode (org.apache.directory.api.ldap.model.filter.ExprNode)1 Test (org.junit.Test)1