mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Ludovic Poitou
10.49.2014 97d03c6a0cdda49879b39511a7b601126cff512f
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestAddResponseProtocolOp.java
@@ -22,22 +22,27 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS.
 */
package org.opends.server.protocols.ldap;
import org.opends.server.protocols.asn1.*;
import static org.opends.server.util.ServerConstants.EOL;
import org.opends.server.types.*;
import org.opends.server.core.DirectoryServer;
import org.opends.server.DirectoryServerTestCase;
import org.opends.messages.Message;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1;
import org.opends.server.protocols.asn1.ASN1Reader;
import org.opends.server.protocols.asn1.ASN1Writer;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Iterator;
import static org.testng.Assert.*;
import org.testng.annotations.*;
import static org.opends.server.util.ServerConstants.EOL;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/**
 * This class defines a set of tests for the
@@ -45,11 +50,6 @@
 */
public class TestAddResponseProtocolOp extends DirectoryServerTestCase {
  /**
   * The protocol op type for add requests.
   */
  private static final byte OP_TYPE_ADD_REQUEST = 0x68;
  /**
   * The protocol op type for add responses.
   */
  private static final byte OP_TYPE_ADD_RESPONSE = 0x69;
@@ -70,8 +70,11 @@
  private DN dn;
  @BeforeClass
  public void setupDN()
  public void setupDN() throws Exception
  {
    // Starts the server if not already started
    TestCaseUtils.startServer();
    //Setup the DN to use in the response tests.
    AttributeType attribute =
@@ -118,7 +121,6 @@
  public void testConstructors() throws Exception
  {
    AddResponseProtocolOp addResponse;
    ArrayList<LDAPAttribute> attributes;
    //Test to make sure the constructor with result code param works.
    addResponse = new AddResponseProtocolOp(resultCode);
@@ -131,7 +133,7 @@
    assertEquals(addResponse.getResultCode(), resultCode);
    //Test to make sure the constructor with result code, message, dn, and
    //referal params works.
    //referral params works.
    ArrayList<String> referralURLs = new ArrayList<String>();
    referralURLs.add("ds1.example.com");
    referralURLs.add("ds2.example.com");
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestCompareResponseProtocolOp.java
@@ -22,22 +22,27 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS.
 */
package org.opends.server.protocols.ldap;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.*;
import org.opends.server.types.*;
import static org.opends.server.util.ServerConstants.EOL;
import org.opends.messages.Message;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1;
import org.opends.server.protocols.asn1.ASN1Reader;
import org.opends.server.protocols.asn1.ASN1Writer;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Iterator;
import static org.opends.server.util.ServerConstants.EOL;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/**
 * This class defines a set of tests for the
 * org.opends.server.protocol.ldap.CompareRequestProtocolOp class.
@@ -45,13 +50,6 @@
public class TestCompareResponseProtocolOp extends LdapTestCase
{
  /**
   * The protocol op type for compare requests.
   */
  public static final byte OP_TYPE_COMPARE_REQUEST = 0x6E;
  /**
   * The protocol op type for compare responses.
   */
  public static final byte OP_TYPE_COMPARE_RESPONSE = 0x6F;
@@ -72,15 +70,15 @@
  private DN dn;
  @BeforeClass
  public void setupDN()
  public void setupDN() throws Exception
  {
    //Setup the DN to use in the response tests.
    // Starts the server if not already started
    TestCaseUtils.startServer();
    //Setup the DN to use in the response tests.
    AttributeType attribute =
        DirectoryServer.getDefaultAttributeType("testAttribute");
    AttributeValue attributeValue = AttributeValues.create(attribute, "testValue");
    RDN[] rdns = new RDN[1];
    rdns[0] = RDN.create(attribute, attributeValue);
    dn = new DN(rdns);
@@ -120,11 +118,8 @@
  @Test
  public void testConstructors() throws Exception
  {
    CompareResponseProtocolOp compareResponse;
    ArrayList<LDAPAttribute> attributes;
    //Test to make sure the constructor with result code param works.
    compareResponse = new CompareResponseProtocolOp(resultCode);
    CompareResponseProtocolOp compareResponse = new CompareResponseProtocolOp(resultCode);
    assertEquals(compareResponse.getResultCode(), resultCode);
    //Test to make sure the constructor with result code and error message
@@ -134,7 +129,7 @@
    assertEquals(compareResponse.getResultCode(), resultCode);
    //Test to make sure the constructor with result code, message, dn, and
    //referal params works.
    //referral params works.
    ArrayList<String> referralURLs = new ArrayList<String>();
    referralURLs.add("ds1.example.com");
    referralURLs.add("ds2.example.com");
@@ -369,7 +364,6 @@
  @Test
  public void TestToStringMultiLine() throws Exception
  {
    CompareResponseProtocolOp compareResponse;
    StringBuilder buffer = new StringBuilder();
    StringBuilder key = new StringBuilder();
@@ -380,8 +374,8 @@
    int indent = 5;
    int i;
    compareResponse = new CompareResponseProtocolOp(resultCode, resultMsg, dn,
                                                  referralURLs);
    CompareResponseProtocolOp compareResponse =
        new CompareResponseProtocolOp(resultCode, resultMsg, dn, referralURLs);
    compareResponse.toString(buffer, indent);
    StringBuilder indentBuf = new StringBuilder(indent);
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestDeleteResponseProtocolOp.java
@@ -22,20 +22,27 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS.
 */
package org.opends.server.protocols.ldap;
import static org.testng.Assert.*;
import org.testng.annotations.*;
import org.opends.server.protocols.asn1.*;
import org.opends.server.types.*;
import org.opends.server.core.DirectoryServer;
import static org.opends.server.util.ServerConstants.EOL;
import org.opends.messages.Message;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1;
import org.opends.server.protocols.asn1.ASN1Reader;
import org.opends.server.protocols.asn1.ASN1Writer;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.Iterator;
import static org.opends.server.util.ServerConstants.EOL;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/**
 * This class defines a set of tests for the
 * org.opends.server.protocol.ldap.DeleteResponseProtocolOp class.
@@ -43,11 +50,6 @@
public class TestDeleteResponseProtocolOp extends LdapTestCase
{
  /**
   * The protocol op type for delete response.
   */
  public static final byte OP_TYPE_DELETE_REQUEST = 0x4A;
  /**
   * The protocol op type for delete responses.
   */
  public static final byte OP_TYPE_DELETE_RESPONSE = 0x6B;
@@ -62,14 +64,17 @@
   */
  private static final Message resultMsg = Message.raw("Test Successful");
/**
  /**
   * The DN to use for delete result operations
   */
  private DN dn;
  @BeforeClass
  public void setupDN()
  public void setupDN() throws Exception
  {
    // Starts the server if not already started
    TestCaseUtils.startServer();
    //Setup the DN to use in the response tests.
    AttributeType attribute =
@@ -116,11 +121,8 @@
  @Test
  public void testConstructors() throws Exception
  {
    DeleteResponseProtocolOp deleteResponse;
    ArrayList<LDAPAttribute> attributes;
    //Test to make sure the constructor with result code param works.
    deleteResponse = new DeleteResponseProtocolOp(resultCode);
    DeleteResponseProtocolOp deleteResponse = new DeleteResponseProtocolOp(resultCode);
    assertEquals(deleteResponse.getResultCode(), resultCode);
    //Test to make sure the constructor with result code and error message
@@ -130,7 +132,7 @@
    assertEquals(deleteResponse.getResultCode(), resultCode);
    //Test to make sure the constructor with result code, message, dn, and
    //referal params works.
    //referral params works.
    ArrayList<String> referralURLs = new ArrayList<String>();
    referralURLs.add("ds1.example.com");
    referralURLs.add("ds2.example.com");
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestModifyDNResponseProtocolOp.java
@@ -22,23 +22,28 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS.
 */
package org.opends.server.protocols.ldap;
import org.opends.server.types.*;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.*;
import static org.opends.server.util.ServerConstants.EOL;
import org.opends.server.DirectoryServerTestCase;
import org.opends.messages.Message;
import org.opends.server.DirectoryServerTestCase;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1;
import org.opends.server.protocols.asn1.ASN1Reader;
import org.opends.server.protocols.asn1.ASN1Writer;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Iterator;
import static org.opends.server.util.ServerConstants.EOL;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/**
 * This class defines a set of tests for the
 * org.opends.server.protocol.ldap.ModifyDNResponseProtocolOp class.
@@ -72,15 +77,15 @@
  private DN dn;
  @BeforeClass
  public void setupDN()
  public void setupDN() throws Exception
  {
    //Setup the DN to use in the response tests.
    // Starts the server if not already started
    TestCaseUtils.startServer();
    //Setup the DN to use in the response tests.
    AttributeType attribute =
        DirectoryServer.getDefaultAttributeType("testAttribute");
    AttributeValue attributeValue = AttributeValues.create(attribute, "testValue");
    RDN[] rdns = new RDN[1];
    rdns[0] = RDN.create(attribute, attributeValue);
    dn = new DN(rdns);
@@ -120,11 +125,8 @@
  @Test
  public void testConstructors() throws Exception
  {
    ModifyDNResponseProtocolOp modifyResponse;
    ArrayList<LDAPAttribute> attributes;
    //Test to make sure the constructor with result code param works.
    modifyResponse = new ModifyDNResponseProtocolOp(resultCode);
    ModifyDNResponseProtocolOp modifyResponse = new ModifyDNResponseProtocolOp(resultCode);
    assertEquals(modifyResponse.getResultCode(), resultCode);
    //Test to make sure the constructor with result code and error message
@@ -134,7 +136,7 @@
    assertEquals(modifyResponse.getResultCode(), resultCode);
    //Test to make sure the constructor with result code, message, dn, and
    //referal params works.
    //referral params works.
    ArrayList<String> referralURLs = new ArrayList<String>();
    referralURLs.add("ds1.example.com");
    referralURLs.add("ds2.example.com");
@@ -330,7 +332,6 @@
  @Test
  public void TestToStringSingleLine() throws Exception
  {
    ModifyDNResponseProtocolOp modifyResponse;
    StringBuilder buffer = new StringBuilder();
    StringBuilder key = new StringBuilder();
@@ -339,8 +340,8 @@
    referralURLs.add("ds2.example.com");
    referralURLs.add("ds3.example.com");
    modifyResponse = new ModifyDNResponseProtocolOp(resultCode, resultMsg, dn,
                                                    referralURLs);
    ModifyDNResponseProtocolOp modifyResponse =
        new ModifyDNResponseProtocolOp(resultCode, resultMsg, dn, referralURLs);
    modifyResponse.toString(buffer);
    key.append("ModifyDNResponse(resultCode="+resultCode+", " +
opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestModifyResponseProtocolOp.java
@@ -22,22 +22,27 @@
 *
 *
 *      Copyright 2006-2008 Sun Microsystems, Inc.
 *      Portions copyright 2014 ForgeRock AS.
 */
package org.opends.server.protocols.ldap;
import org.opends.server.types.*;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.*;
import static org.opends.server.util.ServerConstants.EOL;
import org.opends.messages.Message;
import org.opends.server.TestCaseUtils;
import org.opends.server.core.DirectoryServer;
import org.opends.server.protocols.asn1.ASN1;
import org.opends.server.protocols.asn1.ASN1Reader;
import org.opends.server.protocols.asn1.ASN1Writer;
import org.opends.server.types.*;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Iterator;
import static org.opends.server.util.ServerConstants.EOL;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
/**
 * This class defines a set of tests for the
 * org.opends.server.protocol.ldap.ModifyResponseProtocolOp class.
@@ -45,13 +50,6 @@
public class TestModifyResponseProtocolOp extends LdapTestCase
{
  /**
   * The protocol op type for modify requests.
   */
  public static final byte OP_TYPE_MODIFY_REQUEST = 0x66;
  /**
   * The protocol op type for modify responses.
   */
  public static final byte OP_TYPE_MODIFY_RESPONSE = 0x67;
@@ -72,8 +70,11 @@
  private DN dn;
  @BeforeClass
  public void setupDN()
  public void setupDN() throws Exception
  {
    // Starts the server if not already started
    TestCaseUtils.startServer();
    //Setup the DN to use in the response tests.
    AttributeType attribute =
@@ -120,11 +121,8 @@
  @Test
  public void testConstructors() throws Exception
  {
    ModifyResponseProtocolOp modifyResponse;
    ArrayList<LDAPAttribute> attributes;
    //Test to make sure the constructor with result code param works.
    modifyResponse = new ModifyResponseProtocolOp(resultCode);
    ModifyResponseProtocolOp modifyResponse = new ModifyResponseProtocolOp(resultCode);
    assertEquals(modifyResponse.getResultCode(), resultCode);
    //Test to make sure the constructor with result code and error message
@@ -134,7 +132,7 @@
    assertEquals(modifyResponse.getResultCode(), resultCode);
    //Test to make sure the constructor with result code, message, dn, and
    //referal params works.
    //referral params works.
    ArrayList<String> referralURLs = new ArrayList<String>();
    referralURLs.add("ds1.example.com");
    referralURLs.add("ds2.example.com");