Search in sources :

Example 86 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class SearchResultDoneTest method testResponseWith2Referrals.

/**
 * Test parsing of a response with 2 Referral elements
 */
@Test
public void testResponseWith2Referrals() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResultDoneTest.class.getResource("response_with_2_referrals.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchResultDone searchResultDone = ((SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated()).getSearchResultDone();
    LdapResult ldapResult = searchResultDone.getLdapResult();
    Collection<String> referrals = ldapResult.getReferral().getLdapUrls();
    assertEquals(2, referrals.size());
    try {
        assertTrue(referrals.contains(new LdapUrl("ldap://www.apache.org/").toString()));
    } catch (LdapURLEncodingException e) {
        fail();
    }
    try {
        assertTrue(referrals.contains(new LdapUrl("ldap://www.apple.com/").toString()));
    } catch (LdapURLEncodingException e) {
        fail();
    }
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) LdapResult(org.apache.directory.api.ldap.model.message.LdapResult) SearchResultDone(org.apache.directory.api.ldap.model.message.SearchResultDone) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) SearchResponse(org.apache.directory.api.dsmlv2.response.SearchResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 87 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class SearchResultReferenceTest method testResponseWith1Ref.

/**
 * Test parsing of a Response with 1 Ref
 */
@Test
public void testResponseWith1Ref() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResultReferenceTest.class.getResource("response_with_1_ref.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchResultReference searchResultReference = ((SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated()).getCurrentSearchResultReference();
    Collection<String> references = searchResultReference.getReferral().getLdapUrls();
    assertEquals(1, references.size());
    try {
        assertTrue(references.contains(new LdapUrl("ldap://localhost").toString()));
    } catch (LdapURLEncodingException e) {
        fail();
    }
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) SearchResultReference(org.apache.directory.api.ldap.model.message.SearchResultReference) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) SearchResponse(org.apache.directory.api.dsmlv2.response.SearchResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 88 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class SearchResultReferenceTest method testResponseWith2Ref.

/**
 * Test parsing of a Response with 2 Ref
 */
@Test
public void testResponseWith2Ref() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(SearchResultReferenceTest.class.getResource("response_with_2_ref.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    SearchResultReference searchResultReference = ((SearchResponse) parser.getBatchResponse().getCurrentResponse().getDecorated()).getCurrentSearchResultReference();
    Collection<String> references = searchResultReference.getReferral().getLdapUrls();
    assertEquals(2, references.size());
    try {
        assertTrue(references.contains(new LdapUrl("ldap://localhost").toString()));
    } catch (LdapURLEncodingException e) {
        fail();
    }
    try {
        assertTrue(references.contains(new LdapUrl("ldap://www.apache.org").toString()));
    } catch (LdapURLEncodingException e) {
        fail();
    }
}
Also used : LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) SearchResultReference(org.apache.directory.api.ldap.model.message.SearchResultReference) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) SearchResponse(org.apache.directory.api.dsmlv2.response.SearchResponse) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 89 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class CompareResponseTest method testResponseWith1Referral.

/**
 * Test parsing of a response with a Referral
 */
@Test
public void testResponseWith1Referral() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(CompareResponseTest.class.getResource("response_with_1_referral.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    CompareResponse compareResponse = (CompareResponse) parser.getBatchResponse().getCurrentResponse();
    LdapResult ldapResult = compareResponse.getLdapResult();
    Collection<String> referrals = ldapResult.getReferral().getLdapUrls();
    assertEquals(1, referrals.size());
    try {
        assertTrue(referrals.contains(new LdapUrl("ldap://www.apache.org/").toString()));
    } catch (LdapURLEncodingException e) {
        fail();
    }
}
Also used : CompareResponse(org.apache.directory.api.ldap.model.message.CompareResponse) LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) LdapResult(org.apache.directory.api.ldap.model.message.LdapResult) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Example 90 with LdapUrl

use of org.apache.directory.api.ldap.model.url.LdapUrl in project directory-ldap-api by apache.

the class CompareResponseTest method testResponseWith1ReferralAndAnErrorMessage.

/**
 * Test parsing of a response with a Referral and an Error Message
 */
@Test
public void testResponseWith1ReferralAndAnErrorMessage() {
    Dsmlv2ResponseParser parser = null;
    try {
        parser = new Dsmlv2ResponseParser(getCodec());
        parser.setInput(CompareResponseTest.class.getResource("response_with_1_referral_and_error_message.xml").openStream(), "UTF-8");
        parser.parse();
    } catch (Exception e) {
        fail(e.getMessage());
    }
    CompareResponse compareResponse = (CompareResponse) parser.getBatchResponse().getCurrentResponse();
    LdapResult ldapResult = compareResponse.getLdapResult();
    Collection<String> referrals = ldapResult.getReferral().getLdapUrls();
    assertEquals(1, referrals.size());
    try {
        assertTrue(referrals.contains(new LdapUrl("ldap://www.apache.org/").toString()));
    } catch (LdapURLEncodingException e) {
        fail();
    }
}
Also used : CompareResponse(org.apache.directory.api.ldap.model.message.CompareResponse) LdapUrl(org.apache.directory.api.ldap.model.url.LdapUrl) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Dsmlv2ResponseParser(org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser) LdapResult(org.apache.directory.api.ldap.model.message.LdapResult) LdapURLEncodingException(org.apache.directory.api.ldap.model.exception.LdapURLEncodingException) Test(org.junit.Test) AbstractResponseTest(org.apache.directory.api.dsmlv2.AbstractResponseTest)

Aggregations

LdapUrl (org.apache.directory.api.ldap.model.url.LdapUrl)98 Test (org.junit.Test)95 LdapURLEncodingException (org.apache.directory.api.ldap.model.exception.LdapURLEncodingException)27 AbstractResponseTest (org.apache.directory.api.dsmlv2.AbstractResponseTest)24 Dsmlv2ResponseParser (org.apache.directory.api.dsmlv2.Dsmlv2ResponseParser)24 LdapResult (org.apache.directory.api.ldap.model.message.LdapResult)23 DecoderException (org.apache.directory.api.asn1.DecoderException)5 SearchResponse (org.apache.directory.api.dsmlv2.response.SearchResponse)5 Dn (org.apache.directory.api.ldap.model.name.Dn)5 Extension (org.apache.directory.api.ldap.model.url.LdapUrl.Extension)5 BindResponse (org.apache.directory.api.ldap.model.message.BindResponse)3 CompareResponse (org.apache.directory.api.ldap.model.message.CompareResponse)3 DeleteResponse (org.apache.directory.api.ldap.model.message.DeleteResponse)3 ExtendedResponse (org.apache.directory.api.ldap.model.message.ExtendedResponse)3 ModifyDnResponse (org.apache.directory.api.ldap.model.message.ModifyDnResponse)3 ModifyResponse (org.apache.directory.api.ldap.model.message.ModifyResponse)3 SearchResultDone (org.apache.directory.api.ldap.model.message.SearchResultDone)3 SearchResultReference (org.apache.directory.api.ldap.model.message.SearchResultReference)3 TLV (org.apache.directory.api.asn1.ber.tlv.TLV)2 Referral (org.apache.directory.api.ldap.model.message.Referral)2