From 5257ffd06c2ea4ef456b114a41233e59da72dc44 Mon Sep 17 00:00:00 2001
From: coulbeck <coulbeck@localhost>
Date: Wed, 06 Sep 2006 19:25:53 +0000
Subject: [PATCH] More unit test coverage for SearchRequestProtocolOp.

---
 opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestSearchProtocolOp.java |   69 ++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestSearchProtocolOp.java b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestSearchProtocolOp.java
index 855890d..8ff7d89 100644
--- a/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestSearchProtocolOp.java
+++ b/opendj-sdk/opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/ldap/TestSearchProtocolOp.java
@@ -118,6 +118,12 @@
   }
 
   @Test (expectedExceptions = LDAPException.class)
+  public void testInvalidSearchRequestSequence() throws Exception
+  {
+    ProtocolOp.decode(new ASN1Integer(OP_TYPE_SEARCH_REQUEST, 0));
+  }
+
+  @Test (expectedExceptions = LDAPException.class)
   public void testInvalidSearchRequestTooManyElements() throws Exception
   {
     ASN1Element element = buildSearchRequestProtocolOp().encode();
@@ -153,4 +159,67 @@
     ProtocolOp.decode(new ASN1Sequence(OP_TYPE_SEARCH_REQUEST, elements));
   }
 
+  @Test (expectedExceptions = LDAPException.class)
+  public void testInvalidSearchRequestElement1() throws Exception
+  {
+    ASN1Element element = buildSearchRequestProtocolOp().encode();
+    ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
+    elements.set(1, new ASN1OctetString());
+    ProtocolOp.decode(new ASN1Sequence(OP_TYPE_SEARCH_REQUEST, elements));
+  }
+
+  @Test (expectedExceptions = LDAPException.class)
+  public void testInvalidSearchRequestElement2() throws Exception
+  {
+    ASN1Element element = buildSearchRequestProtocolOp().encode();
+    ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
+    elements.set(2, new ASN1OctetString());
+    ProtocolOp.decode(new ASN1Sequence(OP_TYPE_SEARCH_REQUEST, elements));
+  }
+
+  @Test (expectedExceptions = LDAPException.class)
+  public void testInvalidSearchRequestElement3() throws Exception
+  {
+    ASN1Element element = buildSearchRequestProtocolOp().encode();
+    ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
+    elements.set(3, new ASN1OctetString());
+    ProtocolOp.decode(new ASN1Sequence(OP_TYPE_SEARCH_REQUEST, elements));
+  }
+
+  @Test (expectedExceptions = LDAPException.class)
+  public void testInvalidSearchRequestElement4() throws Exception
+  {
+    ASN1Element element = buildSearchRequestProtocolOp().encode();
+    ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
+    elements.set(4, new ASN1OctetString());
+    ProtocolOp.decode(new ASN1Sequence(OP_TYPE_SEARCH_REQUEST, elements));
+  }
+
+  @Test (expectedExceptions = LDAPException.class)
+  public void testInvalidSearchRequestElement5() throws Exception
+  {
+    ASN1Element element = buildSearchRequestProtocolOp().encode();
+    ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
+    elements.set(5, new ASN1OctetString());
+    ProtocolOp.decode(new ASN1Sequence(OP_TYPE_SEARCH_REQUEST, elements));
+  }
+
+  @Test (expectedExceptions = LDAPException.class)
+  public void testInvalidSearchRequestElement6() throws Exception
+  {
+    ASN1Element element = buildSearchRequestProtocolOp().encode();
+    ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
+    elements.set(6, new ASN1OctetString());
+    ProtocolOp.decode(new ASN1Sequence(OP_TYPE_SEARCH_REQUEST, elements));
+  }
+
+  @Test (expectedExceptions = LDAPException.class)
+  public void testInvalidSearchRequestElement7() throws Exception
+  {
+    ASN1Element element = buildSearchRequestProtocolOp().encode();
+    ArrayList<ASN1Element> elements = ((ASN1Sequence)element).elements();
+    elements.set(7, new ASN1OctetString("cn"));
+    ProtocolOp.decode(new ASN1Sequence(OP_TYPE_SEARCH_REQUEST, elements));
+  }
+
 }

--
Gitblit v1.10.0