ByteArrayTest.java revision 530e312594f469609337996570cf0ea504554a68
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2014 ForgeRock AS
*/
/**
* Test for {@link ByteArrayBuilder} and {@link ByteArrayScanner} classes.
*/
@SuppressWarnings("javadoc")
public class ByteArrayTest extends DirectoryServerTestCase
{
{
private int next;
private final int endInclusive;
{
this.next = startInclusive;
this.endInclusive = endInclusive;
}
public boolean hasNext()
{
return next <= this.endInclusive;
}
{
}
public void remove() { /* unused */ }
}
{
}
{
}
@Test
public void testBuilderAppendMethodsAndScannerNextMethods() throws Exception
{
final boolean boFalse = false;
final boolean boTrue = true;
final byte by = 80;
final short sh = 42;
final int i = sh + 1;
final long l = i + 1;
byte[] bytes = new ByteArrayBuilder()
.appendByte(by)
.appendInt(i)
.appendLong(l)
.appendIntUTF8(i)
.appendLongUTF8(l)
.toByteArray();
}
@Test
public void testByteArrayScanner_remainingBytes() throws Exception
{
final byte[] bytes = new ByteArrayBuilder()
.toByteArray();
}
@Test
public void testByteArrayScanner_remainingBytesZeroTerminated() throws Exception
{
final byte[] bytes = new ByteArrayBuilder()
.toByteArray();
}
{
}
expectedExceptions = DataFormatException.class)
public void testByteArrayScanner_nextMethods_throwsExceptionWhenNoData(int testNumber) throws Exception
{
}
/**
* TestNG does not like test methods with a return type other than void,
* so used a delegate to simplify the code down below.
*/
{
switch (testNumber)
{
case 0:
case 1:
return scanner.nextBoolean();
case 2:
case 3:
case 4:
return scanner.nextIntUTF8();
case 5:
case 6:
return scanner.nextLongUTF8();
case 7:
default:
return null;
}
}
public void testByteArrayScanner_skipZeroSeparator_throwsExceptionWhenNoData() throws Exception
{
}
public void testByteArrayScanner_skipZeroSeparator_throwsExceptionWhenNoZeroSeparator() throws Exception
{
}
public void testByteArrayScanner_nextCSNUTF8_throwsExceptionWhenInvalidCSN() throws Exception
{
}
public void testByteArrayScanner_nextDN_throwsExceptionWhenInvalidDN() throws Exception
{
}
}