Program: 69715
Project: 69715
Buggy source:
@Test public void testUploadAttachmentAndRename() throws IOException, URISyntaxException {
  RestConnection conn=new RestConnection();
  assertTrue(conn.login(id1.getName(),"String_Node_Str"));
  URI uri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).queryParam("String_Node_Str",id1.getKey()).queryParam("String_Node_Str","String_Node_Str").queryParam("String_Node_Str","String_Node_Str").build();
  HttpPut method=conn.createPut(uri,MediaType.APPLICATION_JSON,true);
  HttpResponse response=conn.execute(method);
  assertEquals(200,response.getStatusLine().getStatusCode());
  MessageVO message=conn.parse(response,MessageVO.class);
  assertNotNull(message);
  URL portraitUrl=CoursesElementsTest.class.getResource("String_Node_Str");
  assertNotNull(portraitUrl);
  File portrait=new File(portraitUrl.toURI());
  URI attachUri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).path("String_Node_Str").build();
  HttpPost attachMethod=conn.createPost(attachUri,MediaType.APPLICATION_JSON,true);
  conn.addMultipart(attachMethod,"String_Node_Str",portrait);
  HttpResponse attachCode=conn.execute(attachMethod);
  assertEquals(200,attachCode.getStatusLine().getStatusCode());
  EntityUtils.consume(attachCode.getEntity());
  URI attach2Uri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).path("String_Node_Str").build();
  HttpPost attach2Method=conn.createPost(attach2Uri,MediaType.APPLICATION_JSON,true);
  conn.addMultipart(attach2Method,"String_Node_Str",portrait);
  HttpResponse attach2Code=conn.execute(attach2Method);
  assertEquals(200,attach2Code.getStatusLine().getStatusCode());
  EntityUtils.consume(attach2Code.getEntity());
  URI loadUri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).path("String_Node_Str").build();
  HttpGet loadMethod=conn.createGet(loadUri,MediaType.APPLICATION_JSON,true);
  HttpResponse loadResponse=conn.execute(loadMethod);
  assertEquals(200,loadResponse.getStatusLine().getStatusCode());
  InputStream loadBody=loadResponse.getEntity().getContent();
  List<FileVO> files=parseFileArray(loadBody);
  assertNotNull(files);
  assertEquals(2,files.size());
  conn.shutdown();
}

Fixed version (ground truth):
@Test public void testUploadAttachmentAndRename() throws IOException, URISyntaxException {
  RestConnection conn=new RestConnection();
  assertTrue(conn.login(id1.getName(),"String_Node_Str"));
  URI uri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).queryParam("String_Node_Str",id1.getKey()).queryParam("String_Node_Str","String_Node_Str").queryParam("String_Node_Str","String_Node_Str").build();
  HttpPut method=conn.createPut(uri,MediaType.APPLICATION_JSON,true);
  HttpResponse response=conn.execute(method);
  assertEquals(200,response.getStatusLine().getStatusCode());
  MessageVO message=conn.parse(response,MessageVO.class);
  assertNotNull(message);
  URL portraitUrl=CoursesElementsTest.class.getResource("String_Node_Str");
  assertNotNull(portraitUrl);
  File portrait=new File(portraitUrl.toURI());
  URI attachUri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).path("String_Node_Str").build();
  HttpPost attachMethod=conn.createPost(attachUri,MediaType.APPLICATION_JSON);
  conn.addMultipart(attachMethod,"String_Node_Str",portrait);
  HttpResponse attachCode=conn.execute(attachMethod);
  assertEquals(200,attachCode.getStatusLine().getStatusCode());
  EntityUtils.consume(attachCode.getEntity());
  URI attach2Uri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).path("String_Node_Str").build();
  HttpPost attach2Method=conn.createPost(attach2Uri,MediaType.APPLICATION_JSON);
  conn.addMultipart(attach2Method,"String_Node_Str",portrait);
  HttpResponse attach2Code=conn.execute(attach2Method);
  assertEquals(200,attach2Code.getStatusLine().getStatusCode());
  EntityUtils.consume(attach2Code.getEntity());
  URI loadUri=getForumUriBuilder().path("String_Node_Str").path(m1.getKey().toString()).path("String_Node_Str").build();
  HttpGet loadMethod=conn.createGet(loadUri,MediaType.APPLICATION_JSON,true);
  HttpResponse loadResponse=conn.execute(loadMethod);
  assertEquals(200,loadResponse.getStatusLine().getStatusCode());
  InputStream loadBody=loadResponse.getEntity().getContent();
  List<FileVO> files=parseFileArray(loadBody);
  assertNotNull(files);
  assertEquals(2,files.size());
  conn.shutdown();
}