From da858da50aefe76503db3d9e3b8bb92fd92af5e2 Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Sat, 23 Sep 2006 15:57:02 +0000
Subject: [PATCH] Remove unused method from AbandonRequestOp class. Added toString helper in LdapTestCase class. Changed TestBindResponseProtocolOp.java/TestUnbindRequestProtocolOp.java to use toString helper method. Cleaned up unneeded start server call in TestUnbindRequestProtocolOp.java.

---
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java                |   50 +++++++++++++++---------
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestUnbindRequestProtocolOp.java |   22 +----------
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestBindResponseProtocolOp.java  |    4 -
 3 files changed, 34 insertions(+), 42 deletions(-)

diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java
index 7fac489..775fe68 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/LdapTestCase.java
@@ -87,21 +87,21 @@
    * @param index The index into the element to write to.
    * @throws Exception If the protocol op decode can't write the sequence.
    */
-static void 
+  static void 
   badIntegerElement(ProtocolOp op, byte type, int index) throws Exception {
-      ASN1Element element = op.encode();
-      ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
-      elements.set(index, new ASN1Long(Long.MAX_VALUE));
-      ProtocolOp.decode(new ASN1Sequence(type, elements));
+	  ASN1Element element = op.encode();
+	  ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
+	  elements.set(index, new ASN1Long(Long.MAX_VALUE));
+	  ProtocolOp.decode(new ASN1Sequence(type, elements));
   }
-  
+
   /**
    * Generate an exception by adding an element.
- * @param op The op.
- * @param type The type of sequence.
- * @throws Exception If the protocol op decode has too many elements.
- */
-static void 
+   * @param op The op.
+   * @param type The type of sequence.
+   * @throws Exception If the protocol op decode has too many elements.
+   */
+  static void 
   tooManyElements(ProtocolOp op, byte type) throws Exception
   {
 	  ASN1Element element = op.encode();
@@ -110,18 +110,30 @@
 	  ProtocolOp.decode(new ASN1Sequence(type, elements));
   }
 
-/**
- * Generate an excepting by removing an element.
- * @param op The op.
- * @param type The type of sequence.
- * @throws Exception If the protocol op decode has too few elements.
- */
-static void 
+  /**
+   * Generate an exception by removing an element.
+   * @param op The op.
+   * @param type The type of sequence.
+   * @throws Exception If the protocol op decode has too few elements.
+   */
+  static void 
   tooFewElements(ProtocolOp op, byte type) throws Exception
   {
 	  ASN1Element element = op.encode();
 	  ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
-      elements.remove(0);
+	  elements.remove(0);
 	  ProtocolOp.decode(new ASN1Sequence(type, elements));
   }
+
+  /**
+   * Test toString methods.
+   * @param op The op.
+   * @throws Exception If the toString method fails.
+   */
+  static void 
+  toString(ProtocolOp op) throws Exception {
+	  StringBuilder sb = new StringBuilder();
+	  op.toString(sb);
+	  op.toString(sb, 1);
+  }
 }
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestBindResponseProtocolOp.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestBindResponseProtocolOp.java
index 84a4302..b54043c 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestBindResponseProtocolOp.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestBindResponseProtocolOp.java
@@ -80,9 +80,7 @@
             new BindResponseProtocolOp(okCode.getIntValue(),
                     message, responseDn, referralURLs, 
                     serverSASLCredentials);
-        StringBuilder sb = new StringBuilder();
-        r.toString(sb);
-        r.toString(sb, 1);
+        toString(r);
     }
 
     @Test (expectedExceptions = LDAPException.class)
diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestUnbindRequestProtocolOp.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestUnbindRequestProtocolOp.java
index da452a5..76bd3f4 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestUnbindRequestProtocolOp.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestUnbindRequestProtocolOp.java
@@ -26,32 +26,16 @@
  */
 package org.opends.server.protocols.ldap;
 
-import org.opends.server.TestCaseUtils;
 import org.opends.server.protocols.asn1.ASN1Element;
 import org.opends.server.protocols.ldap.UnbindRequestProtocolOp;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 import static org.testng.Assert.*;
 
 
 public class TestUnbindRequestProtocolOp  extends LdapTestCase {
 
-    /**
-     * Once-only initialization.
-     * 
-     * @throws Exception
-     *           If an unexpected error occurred.
-     */
-    @BeforeClass
-    public void setUp() throws Exception {
-        // This test suite depends on having the schema available, so we'll
-        // start the server.TestBindResponseProtocolOp
-        TestCaseUtils.startServer();
-    }
-
-
   @Test()
-  public void testUnbindRequest() throws Exception {
+  public void testUnbindEncodeDecodeRequest() throws Exception {
       UnbindRequestProtocolOp req = new UnbindRequestProtocolOp();
       ASN1Element reqElem=req.encode();
       ProtocolOp reqOp= ProtocolOp.decode(reqElem);
@@ -64,8 +48,6 @@
   {
       UnbindRequestProtocolOp r = 
           new UnbindRequestProtocolOp();
-      StringBuilder sb = new StringBuilder();
-      r.toString(sb);
-      r.toString(sb, 1);
+      toString(r);
   }
 }

--
Gitblit v1.10.0