Search in sources :

Example 16 with SubstringNode

use of org.apache.directory.api.ldap.model.filter.SubstringNode 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());
}
Also used : ExprNode(org.apache.directory.api.ldap.model.filter.ExprNode) SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) SubstringNode(org.apache.directory.api.ldap.model.filter.SubstringNode) 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)

Example 17 with SubstringNode

use of org.apache.directory.api.ldap.model.filter.SubstringNode in project directory-ldap-api by apache.

the class SearchRequestTest method testRequestWithSubstrings1Initial1Final.

/**
 * Test parsing of a request with a Substrings Filter with 1 Initial and 1 Final elements
 */
@Test
public void testRequestWithSubstrings1Initial1Final() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_initial_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;
    assertEquals("jack", substringFilter.getInitial());
    assertEquals("john", substringFilter.getFinal());
}
Also used : ExprNode(org.apache.directory.api.ldap.model.filter.ExprNode) SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) SubstringNode(org.apache.directory.api.ldap.model.filter.SubstringNode) 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)

Example 18 with SubstringNode

use of org.apache.directory.api.ldap.model.filter.SubstringNode in project directory-ldap-api by apache.

the class SearchRequestTest method testRequestWithSubstrings1Initial.

/**
 * Test parsing of a request with a Substrings Filter with 1 Initial element
 */
@Test
public void testRequestWithSubstrings1Initial() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_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("jack", substringFilter.getInitial().toString());
}
Also used : ExprNode(org.apache.directory.api.ldap.model.filter.ExprNode) SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) SubstringNode(org.apache.directory.api.ldap.model.filter.SubstringNode) 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)

Example 19 with SubstringNode

use of org.apache.directory.api.ldap.model.filter.SubstringNode in project directory-ldap-api by apache.

the class SearchRequestTest method testRequestWithSubstringsFilter.

/**
 * Test parsing of a request with an Substrings Filter
 */
@Test
public void testRequestWithSubstringsFilter() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings.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("sn", substringFilter.getAttribute());
}
Also used : ExprNode(org.apache.directory.api.ldap.model.filter.ExprNode) SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) SubstringNode(org.apache.directory.api.ldap.model.filter.SubstringNode) 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)

Example 20 with SubstringNode

use of org.apache.directory.api.ldap.model.filter.SubstringNode in project directory-ldap-api by apache.

the class SearchRequestTest method testRequestWithSubstrings1EmptyAny.

/**
 * Test parsing of a request with a Substrings Filter with 1 empty Any element
 */
@Test
public void testRequestWithSubstrings1EmptyAny() {
    Dsmlv2Parser parser = null;
    try {
        parser = newParser();
        parser.setInput(SearchRequestTest.class.getResource("filters/request_with_substrings_1_empty_any.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(0, initials.size());
}
Also used : ExprNode(org.apache.directory.api.ldap.model.filter.ExprNode) SearchRequest(org.apache.directory.api.ldap.model.message.SearchRequest) SubstringNode(org.apache.directory.api.ldap.model.filter.SubstringNode) 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

SubstringNode (org.apache.directory.api.ldap.model.filter.SubstringNode)32 ExprNode (org.apache.directory.api.ldap.model.filter.ExprNode)29 SearchRequest (org.apache.directory.api.ldap.model.message.SearchRequest)26 Test (org.junit.Test)26 AbstractTest (org.apache.directory.api.dsmlv2.AbstractTest)14 Dsmlv2Parser (org.apache.directory.api.dsmlv2.Dsmlv2Parser)14 LdapException (org.apache.directory.api.ldap.model.exception.LdapException)14 DecoderException (org.apache.directory.api.asn1.DecoderException)13 ByteBuffer (java.nio.ByteBuffer)12 Asn1Decoder (org.apache.directory.api.asn1.ber.Asn1Decoder)12 LdapMessageContainer (org.apache.directory.api.ldap.codec.api.LdapMessageContainer)12 SearchRequestDecorator (org.apache.directory.api.ldap.codec.decorators.SearchRequestDecorator)12 AbstractCodecServiceTest (org.apache.directory.api.ldap.codec.osgi.AbstractCodecServiceTest)12 EncoderException (org.apache.directory.api.asn1.EncoderException)11 AndNode (org.apache.directory.api.ldap.model.filter.AndNode)7 EqualityNode (org.apache.directory.api.ldap.model.filter.EqualityNode)6 OrNode (org.apache.directory.api.ldap.model.filter.OrNode)6 PresenceNode (org.apache.directory.api.ldap.model.filter.PresenceNode)5 Value (org.apache.directory.api.ldap.model.entry.Value)4 ApproximateNode (org.apache.directory.api.ldap.model.filter.ApproximateNode)4