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

matthew_swift
07.56.2009 9008dca31797ba1b05fa3ed6cacb540ef175c666
opends/tests/unit-tests-testng/src/server/org/opends/server/protocols/asn1/ASN1ReaderTestCase.java
@@ -67,8 +67,6 @@
   *
   * @return  A list of byte arrays with encoded ASN.1 elements that can be
   *          decoded as octet strings.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @DataProvider(name = "elementArrays")
  public Object[][] getElementArrays()
@@ -102,6 +100,17 @@
        };
  }
  /**
   * Gets the reader to be use for the unit tests.
   *
   * @param b
   *          The array of bytes to be read.
   * @param maxElementSize
   *          The max element size.
   * @return The reader to be use for the unit tests.
   * @throws IOException
   *           In an unexpected IO exception occurred.
   */
  abstract ASN1Reader getReader(byte[] b, int maxElementSize)
      throws IOException;
@@ -213,6 +222,20 @@
    getReader(b, 0).readInteger();
  }
  /**
   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
   * a short array.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(expectedExceptions = { ASN1Exception.class })
  public void testDecodeShortArrayAsEnumerated()
      throws Exception
  {
    byte[] b = new byte[0];
    getReader(b, 0).readEnumerated();
  }
  /**
@@ -232,6 +255,22 @@
  /**
   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
   * a long length array.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(expectedExceptions = { ASN1Exception.class })
  public void testDecodeLongLengthArrayAsEnumerated()
      throws Exception
  {
    byte[] b = { 0x02, (byte) 0x85, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00 };
    getReader(b, 0).readEnumerated();
  }
  /**
   * Tests the <CODE>decodeAsInteger</CODE> method that takes a byte array with
   * a truncated length array.
   *
@@ -248,6 +287,22 @@
  /**
   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
   * a truncated length array.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(expectedExceptions = { ASN1Exception.class })
  public void testDecodeTruncatedLengthArrayAsEnumerated()
      throws Exception
  {
    byte[] b = { 0x02, (byte) 0x82, 0x00 };
    getReader(b, 0).readEnumerated();
  }
  /**
   * Tests the <CODE>decodeAsInteger</CODE> method that takes a byte array with
   * a length mismatch.
   *
@@ -262,6 +317,20 @@
  }
  /**
   * Tests the <CODE>readEnumerated</CODE> method that takes a byte array with
   * a length mismatch.
   *
   * @throws  Exception  If an unexpected problem occurs.
   */
  @Test(expectedExceptions = { ASN1Exception.class })
  public void testDecodeLengthMismatchArrayAsEnumerated()
      throws Exception
  {
    byte[] b = { 0x02, (byte) 0x81, 0x01 };
    getReader(b, 0).readEnumerated();
  }
  /**
   * Tests the <CODE>decodeAsBoolean</CODE> method that takes a byte array
   * argument with valid arrays.
   *