| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.testng.annotations.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | ArrayList<String> referralURLs = new ArrayList<String>(); |
| | | referralURLs.add("ds1.example.com"); |
| | | referralURLs.add("ds2.example.com"); |
| | | referralURLs.add("ds3.example.com"); |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | addResponse = new AddResponseProtocolOp(resultCode, resultMsg, dn, |
| | | referralURLs); |
| | | addResponse = new AddResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | addResponse.toString(buffer); |
| | | |
| | | key.append("AddResponse(resultCode="+resultCode+", " + |
| | | "errorMessage="+resultMsg+", matchedDN="+dn.toString()+", " + |
| | | "referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | key.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | key.append(", "); |
| | | key.append(iterator.next()); |
| | | } |
| | | |
| | | key.append("AddResponse(resultCode=" + resultCode |
| | | + ", " + "errorMessage=" + resultMsg + ", matchedDN=" + dn + ", " |
| | | + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | } |
| | | |
| | | static void join(StringBuilder sb, List<String> referralURLs) |
| | | { |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | sb.append(iterator.next()); |
| | | while (iterator.hasNext()) |
| | | { |
| | | sb.append(", "); |
| | | sb.append(iterator.next()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Test the toString (multi line) method. |
| | | * |