TestSSTDeserializerpublic class TestSSTDeserializer extends TestCase Exercise the SSTDeserializer class. |
Fields Summary |
---|
private String | _test_file_path | private static final String | _test_file_path_property |
Constructors Summary |
---|
public TestSSTDeserializer(String s)
super( s );
|
Methods Summary |
---|
private byte[] | joinArray(byte[] array1, byte[] array2)
byte[] bigArray = new byte[array1.length+array2.length];
System.arraycopy(array1, 0, bigArray, 0, array1.length);
System.arraycopy(array2, 0, bigArray, array1.length, array2.length);
return bigArray;
| protected void | setUp()
_test_file_path = System.getProperty( _test_file_path_property );
| public void | testContinuationWithNoOverlap()
byte[] header = HexRead.readData( _test_file_path + File.separator + "evencontinuation.txt", "header" );
byte[] continueBytes = HexRead.readData( _test_file_path + File.separator + "evencontinuation.txt", "continue1" );
continueBytes = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continueBytes.length, continueBytes);
TestcaseRecordInputStream in = new TestcaseRecordInputStream((short)0, (short)header.length, joinArray(header, continueBytes));
IntMapper strings = new IntMapper();
SSTDeserializer deserializer = new SSTDeserializer( strings );
deserializer.manufactureStrings( 2, in);
assertEquals( "At a dinner party or", strings.get( 0 ) + "" );
assertEquals( "At a dinner party", strings.get( 1 ) + "" );
| public void | testExtendedStrings()
byte[] header = HexRead.readData( _test_file_path + File.separator + "extendedtextstrings.txt", "rich-header" );
byte[] continueBytes = HexRead.readData( _test_file_path + File.separator + "extendedtextstrings.txt", "rich-continue1" );
continueBytes = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continueBytes.length, continueBytes);
TestcaseRecordInputStream in = new TestcaseRecordInputStream((short)0, (short)header.length, joinArray(header, continueBytes));
IntMapper strings = new IntMapper();
SSTDeserializer deserializer = new SSTDeserializer( strings );
deserializer.manufactureStrings( 1, in);
assertEquals( "At a dinner party orAt At At ", strings.get( 0 ) + "" );
header = HexRead.readData( _test_file_path + File.separator + "extendedtextstrings.txt", "norich-header" );
continueBytes = HexRead.readData( _test_file_path + File.separator + "extendedtextstrings.txt", "norich-continue1" );
continueBytes = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continueBytes.length, continueBytes);
in = new TestcaseRecordInputStream((short)0, (short)header.length, joinArray(header, continueBytes));
strings = new IntMapper();
deserializer = new SSTDeserializer( strings );
deserializer.manufactureStrings( 1, in);
assertEquals( "At a dinner party orAt At At ", strings.get( 0 ) + "" );
| public void | testSpanRichTextToPlainText()
byte[] header = HexRead.readData( _test_file_path + File.separator + "richtextdata.txt", "header" );
byte[] continueBytes = HexRead.readData( _test_file_path + File.separator + "richtextdata.txt", "continue1" );
continueBytes = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continueBytes.length, continueBytes);
TestcaseRecordInputStream in = new TestcaseRecordInputStream((short)0, (short)header.length, joinArray(header, continueBytes));
IntMapper strings = new IntMapper();
SSTDeserializer deserializer = new SSTDeserializer( strings );
deserializer.manufactureStrings(1, in );
assertEquals( "At a dinner party orAt At At ", strings.get( 0 ) + "" );
| public void | testStringAcross2Continuations()Strings can actually span across more than one continuation.
byte[] header = HexRead.readData( _test_file_path + File.separator + "stringacross2continuations.txt", "header" );
byte[] continue1 = HexRead.readData( _test_file_path + File.separator + "stringacross2continuations.txt", "continue1" );
continue1 = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continue1.length, continue1);
byte[] continue2 = HexRead.readData( _test_file_path + File.separator + "stringacross2continuations.txt", "continue2" );
continue2 = TestcaseRecordInputStream.mergeDataAndSid(ContinueRecord.sid, (short)continue2.length, continue2);
byte[] bytes = joinArray(header, continue1);
bytes = joinArray(bytes, continue2);
TestcaseRecordInputStream in = new TestcaseRecordInputStream((short)0, (short)header.length, bytes);
IntMapper strings = new IntMapper();
SSTDeserializer deserializer = new SSTDeserializer( strings );
deserializer.manufactureStrings( 2, in);
assertEquals( "At a dinner party or", strings.get( 0 ) + "" );
assertEquals( "At a dinner partyAt a dinner party", strings.get( 1 ) + "" );
|
|