* Test array put i.e. the put that takes an array of entities to
* put.
*/
public void testArrayPut() throws Exception {
SimpleHTTPMessageEntities entities =
new SimpleHTTPMessageEntities();
String name1 = "name1";
String name2 = "name2";
String name3 = "name3";
HeaderImpl header1 = new HeaderImpl(name1);
HeaderImpl header2 = new HeaderImpl(name1);
HeaderImpl header3 = new HeaderImpl(name2);
HeaderImpl header4 = new HeaderImpl(name3);
entities.add(header1);
header1.setValue("value1");
entities.add(header2);
header2.setValue("value2");
entities.add(header3);
entities.add(header4);
Header headers [] = new Header[3];
headers[0] = new HeaderImpl(name1);
headers[1] = new HeaderImpl(name1);
headers[2] = new HeaderImpl(name2);
// Putting the headers array should replace header1, header2 and
// header3 and return these three replaced entities. In addition
// entities should consist of the three headers in the headers array
// and header4.
HTTPMessageEntity replaced [] = entities.put(headers);
assertEquals("Expected 3 replaced entities", 3, replaced.length);
assertEquals("Expected there to be 4 entities in entities", 4,
entities.size());
// Check the replaced entities.
List replacedList = Arrays.asList(replaced);
List expectedList = new ArrayList();
expectedList.add(header1);