Map<String,String[]> args = new HashMap<String, String[]>();
args.put( SolrParams.STREAM_BODY, new String[] {body1} );
// Make sure it got a single stream in and out ok
List<ContentStream> streams = new ArrayList<ContentStream>();
parser.buildRequestFrom( new MultiMapSolrParams( args ), streams );
assertEquals( 1, streams.size() );
assertEquals( body1, IOUtils.toString( streams.get(0).getStream() ) );
// Now add three and make sure they come out ok
streams = new ArrayList<ContentStream>();
args.put( SolrParams.STREAM_BODY, new String[] {body1,body2,body3} );
parser.buildRequestFrom( new MultiMapSolrParams( args ), streams );
assertEquals( 3, streams.size() );
ArrayList<String> input = new ArrayList<String>();
ArrayList<String> output = new ArrayList<String>();
input.add( body1 );
input.add( body2 );
input.add( body3 );
output.add( IOUtils.toString( streams.get(0).getStream() ) );
output.add( IOUtils.toString( streams.get(1).getStream() ) );
output.add( IOUtils.toString( streams.get(2).getStream() ) );
// sort them so the output is consistent
Collections.sort( input );
Collections.sort( output );
assertEquals( input.toString(), output.toString() );
// set the contentType and make sure tat gets set
String ctype = "text/xxx";
streams = new ArrayList<ContentStream>();
args.put( SolrParams.STREAM_CONTENTTYPE, new String[] {ctype} );
parser.buildRequestFrom( new MultiMapSolrParams( args ), streams );
for( ContentStream s : streams ) {
assertEquals( ctype, s.getContentType() );
}
}