public class UTF8UtilTest extends BaseTestCase
skipFully
and skipUntilEOF
behaves
correctly on Derby's modfied UTF-8 encoded streams.
These tests are dependent on the behavior of ReaderToUTF8Stream
.
Note that this class inserts two bytes at the start of the user/application
stream to encode the length of the stream. These two bytes may be zero, even
if the stream is short enough for its length to be encoded.
Also note that the lengths chosen for large streams are just suitably large integers. The point is to choose them large enough to make sure buffer boundaries are crossed.
ReaderToUTF8Stream
,
UTF8Util
Modifier and Type | Field and Description |
---|---|
private static int |
HEADER_LENGTH
Hardcoded header length.
|
private static java.lang.String |
TYPENAME
Type name passed to
ReaderToUTF8Stream . |
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
Constructor and Description |
---|
UTF8UtilTest(java.lang.String name)
Creates a test of the specified name.
|
Modifier and Type | Method and Description |
---|---|
static junit.framework.Test |
suite()
Returns a suite of tests.
|
void |
testEqualityOfModifedUTF8AndASCII()
Ensure the assumption that the default looping alphabet stream and the
modified UTF-8 encoding is equal.
|
void |
testInvalidUTF8Encoding()
Tries to read a stream of data where there is an invalid UTF-8 encoded
byte.
|
void |
testMissingSecondByteOfThree()
Tries to skip characters where the data is incomplete.
|
void |
testMissingSecondByteOfTwo()
Tries to skip characters where the data is incomplete.
|
void |
testMissingThirdByteOfThree()
Tries to skip characters where the data is incomplete.
|
void |
testMixedSkipOnStreamTamil()
Tests a sequence of skip calls.
|
void |
testSkipFullyOnInvalidStreamCJK()
Tests that
skipFully throws exception if there is a UTF-8
encoding error in the stream |
void |
testSkipFullyOnTooShortStreamCJK()
Tests that
skipFully throws exception if the stream contains
less characters than the requested number of characters to skip. |
void |
testSkipFullyOnValidLongStreamCJK()
Tests that
skipFully successfully skips the requested
characters and returns the correct number of bytes skipped. |
void |
testSkippingInvalidEncodingWorks()
Demonstrates that skipping incorrectly encoded character sequences
works because the stream is not checked for well-formedness.
|
void |
testSkipUntilEOFOnLongStreamASCII() |
void |
testSkipUntilEOFOnLongStreamCJK() |
void |
testSkipUntilEOFOnShortStreamASCII() |
void |
testSkipUntilEOFOnShortStreamCJK() |
void |
testSkipUntilEOFOnZeroLengthStream() |
alarm, assertDirectoryDeleted, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertLaunchedJUnitTestMethod, assertLaunchedJUnitTestMethod, assertSameNullness, assertSecurityManager, assertThrowableEquals, currentDirectory, execJavaCmd, execJavaCmd, execJavaCmd, fail, getClassVersionMajor, getEmmaJar, getFailureFolder, getFilesWith, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, hasInterruptibleIO, isCVM, isIBMJVM, isJ9Platform, isJava5, isJava7, isPhoneME, isPlatform, isSunJVM, isWindowsPlatform, newAssertionFailedError, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeFiles, removeSystemProperty, runBare, runsWithEmma, runsWithJaCoCo, setSystemErr, setSystemOut, setSystemProperty, sleep, sleepAtLeastOneTick, traceit, vmAtLeast
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, setUp, tearDown, toString
private static final java.lang.String TYPENAME
ReaderToUTF8Stream
.private static final int HEADER_LENGTH
true
in the constructor.public UTF8UtilTest(java.lang.String name)
public void testEqualityOfModifedUTF8AndASCII() throws java.io.IOException
If this assumption is broken, several of the other tests will fail.
java.io.IOException
public void testSkipUntilEOFOnZeroLengthStream() throws java.io.IOException
java.io.IOException
public void testSkipUntilEOFOnShortStreamASCII() throws java.io.IOException
java.io.IOException
public void testSkipUntilEOFOnShortStreamCJK() throws java.io.IOException
java.io.IOException
public void testSkipUntilEOFOnLongStreamASCII() throws java.io.IOException
java.io.IOException
public void testSkipUntilEOFOnLongStreamCJK() throws java.io.IOException
java.io.IOException
public void testSkipFullyOnValidLongStreamCJK() throws java.io.IOException
skipFully
successfully skips the requested
characters and returns the correct number of bytes skipped.java.io.IOException
- if the test fails for some unexpected reasonpublic void testSkipFullyOnTooShortStreamCJK() throws java.io.IOException
skipFully
throws exception if the stream contains
less characters than the requested number of characters to skip.java.io.IOException
- if the test fails for some unexpected reasonpublic void testSkipFullyOnInvalidStreamCJK() throws java.io.IOException
skipFully
throws exception if there is a UTF-8
encoding error in the streamjava.io.IOException
- if the test fails for some unexpected reasonpublic void testMixedSkipOnStreamTamil() throws java.io.IOException
java.io.IOException
public void testMissingSecondByteOfTwo() throws java.io.IOException
In this test, the encoding states there is a character represented by two bytes present. However, only one byte is provided.
java.io.IOException
public void testMissingSecondByteOfThree() throws java.io.IOException
In this test, the encoding states there is a character represented by three bytes present. However, only one byte is provided.
java.io.IOException
public void testMissingThirdByteOfThree() throws java.io.IOException
In this test, the encoding states there is a character represented by three bytes present. However, only two bytes are provided.
java.io.IOException
public void testInvalidUTF8Encoding() throws java.io.IOException
java.io.IOException
public void testSkippingInvalidEncodingWorks() throws java.io.IOException
java.io.IOException
public static junit.framework.Test suite()
Apache Derby V10.13 Internals - Copyright © 2004,2016 The Apache Software Foundation. All Rights Reserved.