int total_length = 0;
for ( int k = 0; k < bstrings.length; k++ )
{
Arrays.fill( bstrings[k], (byte) ( 'a' + k ) );
strings[k] = new UnicodeString( new String(bstrings[k]) );
record.addString( strings[k] );
total_length += 3 + bstrings[k].length;
}
// add overhead of SST record
total_length += 8;
// add overhead of broken strings
total_length += 4;
// add overhead of six records
total_length += ( 6 * 4 );
byte[] content = new byte[record.getRecordSize()];
record.serialize( 0, content );
assertEquals( total_length, content.length );
//Deserialize the record.
RecordInputStream recStream = new RecordInputStream(new ByteArrayInputStream(content));
recStream.nextRecord();
record = new SSTRecord(recStream);
assertEquals( strings.length, record.getNumStrings() );
assertEquals( strings.length, record.getNumUniqueStrings() );
assertEquals( strings.length, record.countStrings() );
for ( int k = 0; k < strings.length; k++ )
{
assertEquals( strings[k], record.getString( k ) );
}
record = new SSTRecord();
bstrings[1] = new byte[bstrings[1].length - 1];
for ( int k = 0; k < bstrings.length; k++ )
{
if ( ( bstrings[k].length % 2 ) == 1 )
{
Arrays.fill( bstrings[k], (byte) ( 'a' + k ) );
strings[k] = new UnicodeString( new String(bstrings[k]) );
}
else
{
char[] data = new char[bstrings[k].length / 2];
Arrays.fill( data, (char) ( '\u2122' + k ) );
strings[k] = new UnicodeString(new String( data ));
}
record.addString( strings[k] );
}
content = new byte[record.getRecordSize()];
record.serialize( 0, content );