Program: 180542
Project: 180542
Buggy source:
@Test public void testCloneAndLink() throws IOException, SAXException, JSONException, URISyntaxException {
  URIish uri=new URIish(gitDir.toURL());
  String name=null;
  WebRequest request=getPostGitCloneRequest(uri,name);
  WebResponse response=webConversation.getResponse(request);
  assertEquals(HttpURLConnection.HTTP_CREATED,response.getResponseCode());
  String location=response.getHeaderField(ProtocolConstants.HEADER_LOCATION);
  assertNotNull(location);
  JSONObject clone=new JSONObject(response.getText());
  String contentLocation=clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
  assertNotNull(contentLocation);
  URI workspaceLocation=createWorkspace(getMethodName());
  ServletTestingSupport.allowedPrefixes=contentLocation;
  String projectName=getMethodName();
  JSONObject body=new JSONObject();
  body.put(ProtocolConstants.KEY_CONTENT_LOCATION,contentLocation);
  InputStream in=new StringBufferInputStream(body.toString());
  request=new PostMethodWebRequest(workspaceLocation.toString(),in,"String_Node_Str");
  if (projectName != null)   request.setHeaderField(ProtocolConstants.HEADER_SLUG,projectName);
  request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION,"String_Node_Str");
  setAuthentication(request);
  response=webConversation.getResponse(request);
  assertEquals(HttpURLConnection.HTTP_CREATED,response.getResponseCode());
  JSONObject newProject=new JSONObject(response.getText());
  String projectContentLocation=newProject.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
  assertNotNull(projectContentLocation);
  request=getGetFilesRequest(projectContentLocation);
  response=webConversation.getResponse(request);
  assertEquals(HttpURLConnection.HTTP_OK,response.getResponseCode());
  JSONObject project=new JSONObject(response.getText());
  String childrenLocation=project.getString(ProtocolConstants.KEY_CHILDREN_LOCATION);
  assertNotNull(childrenLocation);
  request=getGetFilesRequest(childrenLocation);
  response=webConversation.getResponse(request);
  assertEquals(HttpURLConnection.HTTP_OK,response.getResponseCode());
  List<JSONObject> children=getDirectoryChildren(new JSONObject(response.getText()));
  String[] expectedChildren=new String[]{Constants.DOT_GIT,"String_Node_Str","String_Node_Str"};
  assertEquals("String_Node_Str",expectedChildren.length,children.size());
  assertEquals(expectedChildren[0],children.get(0).getString(ProtocolConstants.KEY_NAME));
  assertEquals(expectedChildren[1],children.get(1).getString(ProtocolConstants.KEY_NAME));
  assertEquals(expectedChildren[2],children.get(2).getString(ProtocolConstants.KEY_NAME));
}

Fixed version (ground truth):
@Test public void testCloneAndLink() throws IOException, SAXException, JSONException, URISyntaxException {
  URIish uri=new URIish(gitDir.toURL());
  String name=null;
  WebRequest request=getPostGitCloneRequest(uri,name);
  WebResponse response=webConversation.getResponse(request);
  assertEquals(HttpURLConnection.HTTP_CREATED,response.getResponseCode());
  String location=response.getHeaderField(ProtocolConstants.HEADER_LOCATION);
  assertNotNull(location);
  JSONObject clone=new JSONObject(response.getText());
  String contentLocation=clone.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
  assertNotNull(contentLocation);
  URI workspaceLocation=createWorkspace(getMethodName());
  ServletTestingSupport.allowedPrefixes=contentLocation;
  String projectName=getMethodName();
  JSONObject body=new JSONObject();
  body.put(ProtocolConstants.KEY_CONTENT_LOCATION,contentLocation);
  InputStream in=new StringBufferInputStream(body.toString());
  request=new PostMethodWebRequest(workspaceLocation.toString(),in,"String_Node_Str");
  if (projectName != null)   request.setHeaderField(ProtocolConstants.HEADER_SLUG,projectName);
  request.setHeaderField(ProtocolConstants.HEADER_ORION_VERSION,"String_Node_Str");
  setAuthentication(request);
  response=webConversation.getResponse(request);
  assertEquals(HttpURLConnection.HTTP_CREATED,response.getResponseCode());
  JSONObject newProject=new JSONObject(response.getText());
  String projectContentLocation=newProject.getString(ProtocolConstants.KEY_CONTENT_LOCATION);
  assertNotNull(projectContentLocation);
  request=getGetFilesRequest(projectContentLocation);
  response=webConversation.getResponse(request);
  assertEquals(HttpURLConnection.HTTP_OK,response.getResponseCode());
  JSONObject project=new JSONObject(response.getText());
  String childrenLocation=project.getString(ProtocolConstants.KEY_CHILDREN_LOCATION);
  assertNotNull(childrenLocation);
  request=getGetFilesRequest(childrenLocation);
  response=webConversation.getResponse(request);
  assertEquals(HttpURLConnection.HTTP_OK,response.getResponseCode());
  List<JSONObject> children=getDirectoryChildren(new JSONObject(response.getText()));
  String[] expectedChildren=new String[]{Constants.DOT_GIT,"String_Node_Str","String_Node_Str"};
  assertEquals("String_Node_Str",expectedChildren.length,children.size());
  assertNotNull(getChildByName(children,expectedChildren[0]));
  assertNotNull(getChildByName(children,expectedChildren[1]));
  assertNotNull(getChildByName(children,expectedChildren[2]));
}