int size = optionalFieldValueList.size();
for ( int i = 0; i < size; i++ )
{
KrbCredInfo expected = new KrbCredInfo();
expected.setKey( key );
Map<String, Field> krbCredInfoFieldNameMap = getFieldMap( expected );
List<FieldValueHolder> presentFieldList = new ArrayList<FieldValueHolder>();
FieldValueHolder fieldValHolder = optionalFieldValueList.get( i );
presentFieldList.add( fieldValHolder );
Field f = krbCredInfoFieldNameMap.get( Strings.toLowerCase( fieldValHolder.fieldName ) );
f.set( expected, fieldValHolder.value );
for ( int j = i + 1; j < size; j++ )
{
fieldValHolder = optionalFieldValueList.get( j );
presentFieldList.add( fieldValHolder );
f = krbCredInfoFieldNameMap.get( Strings.toLowerCase( fieldValHolder.fieldName ) );
f.set( expected, fieldValHolder.value );
}
ByteBuffer stream = ByteBuffer.allocate( expected.computeLength() );
expected.encode( stream );
stream.flip();
Asn1Decoder decoder = new Asn1Decoder();
KrbCredInfoContainer container = new KrbCredInfoContainer();
container.setStream( stream );
try
{
decoder.decode( stream, container );
}
catch ( DecoderException e )
{
// NOTE: keep this sysout for easy debugging (no need to setup a logger)
System.out.println( "failed sequence:\n" + expected );
throw e;
}
KrbCredInfo actual = container.getKrbCredInfo();
assertValues( presentFieldList, actual );
}
}