Program: 40095
Project: 40095
Buggy source:
@Test public void testREST() throws IOException, URISyntaxException {
  RESTResource resource;
  byte[] content;
  String tdId, tdId2, td;
  Map<String,String> parameters=new HashMap<String,String>();
  parameters.put("String_Node_Str",baseUri);
  String tdUri="String_Node_Str";
  URL path=Repository.class.getClassLoader().getResource("String_Node_Str");
  content=getThingDescription(path.toURI());
  resource=tdch.post(new URI(baseUri + "String_Node_Str"),parameters,new ByteArrayInputStream(content));
  tdId=resource.path;
  td=ThingDescriptionUtils.getThingDescriptionIdFromUri(tdUri);
  Assert.assertEquals("String_Node_Str",baseUri + tdId,td);
  String tdUri2="String_Node_Str";
  path=Repository.class.getClassLoader().getResource("String_Node_Str");
  content=getThingDescription(path.toURI());
  resource=tdch.post(new URI(baseUri + "String_Node_Str"),parameters,new ByteArrayInputStream(content));
  tdId2=resource.path;
  td=ThingDescriptionUtils.getThingDescriptionIdFromUri(tdUri2);
  Assert.assertEquals("String_Node_Str",baseUri + tdId2,td);
  Set<String> tdIds;
  JsonObject fanQR;
  parameters.clear();
  parameters.put("String_Node_Str","String_Node_Str");
  resource=tdch.get(new URI(baseUri + "String_Node_Str"),parameters);
  fanQR=JSON.parse(resource.content);
  tdIds=fanQR.keys();
  Assert.assertFalse("String_Node_Str",tdIds.isEmpty());
  Assert.assertTrue("String_Node_Str",tdIds.contains(tdId));
  parameters.clear();
  parameters.put("String_Node_Str","String_Node_Str");
  resource=tdch.get(new URI(baseUri + "String_Node_Str"),parameters);
  fanQR=JSON.parse(resource.content);
  tdIds=fanQR.keys();
  Assert.assertFalse("String_Node_Str",tdIds.isEmpty());
  Assert.assertTrue("String_Node_Str",tdIds.contains(tdId));
  Assert.assertFalse("String_Node_Str",tdIds.contains(tdId2));
  ThingDescriptionHandler tdh=new ThingDescriptionHandler(tdId,Repository.get().servers);
  resource=tdh.get(new URI(baseUri + tdId),null);
  JsonObject o=JSON.parse(resource.content);
  JsonValue v=o.get("String_Node_Str").getAsArray().get(0);
  Assert.assertEquals("String_Node_Str","String_Node_Str" + tdUri + "String_Node_Str",v.toString());
  path=Repository.class.getClassLoader().getResource("String_Node_Str");
  content=getThingDescription(path.toURI());
  tdh.put(new URI(baseUri + tdId),new HashMap<String,String>(),new ByteArrayInputStream(content));
  RESTResource resource2=tdh.get(new URI(baseUri + tdId),null);
  JsonObject o2=JSON.parse(resource2.content);
  JsonValue v2=o2.get("String_Node_Str");
  Assert.assertEquals("String_Node_Str","String_Node_Str",v2.toString());
  tdh.delete(new URI(baseUri + tdId),null,null);
  td=ThingDescriptionUtils.getThingDescriptionIdFromUri(tdUri);
  Assert.assertEquals("String_Node_Str","String_Node_Str",td);
  tdh.delete(new URI(baseUri + tdId2),null,null);
  td=ThingDescriptionUtils.getThingDescriptionIdFromUri(tdUri2);
  Assert.assertEquals("String_Node_Str","String_Node_Str",td);
}

Fixed version (ground truth):
@Test public void testREST() throws IOException, URISyntaxException {
  RESTResource resource;
  byte[] content;
  String tdId, tdId2, td;
  Map<String,String> parameters=new HashMap<String,String>();
  parameters.put("String_Node_Str",baseUri);
  String tdUri="String_Node_Str";
  InputStream in=Repository.get().getClass().getClassLoader().getResourceAsStream("String_Node_Str");
  resource=tdch.post(new URI(baseUri + "String_Node_Str"),parameters,in);
  tdId=resource.path;
  td=ThingDescriptionUtils.getThingDescriptionIdFromUri(tdUri);
  Assert.assertEquals("String_Node_Str",baseUri + tdId,td);
  String tdUri2="String_Node_Str";
  in=Repository.get().getClass().getClassLoader().getResourceAsStream("String_Node_Str");
  resource=tdch.post(new URI(baseUri + "String_Node_Str"),parameters,in);
  tdId2=resource.path;
  td=ThingDescriptionUtils.getThingDescriptionIdFromUri(tdUri2);
  Assert.assertEquals("String_Node_Str",baseUri + tdId2,td);
  Set<String> tdIds;
  JsonObject fanQR;
  parameters.clear();
  parameters.put("String_Node_Str","String_Node_Str");
  resource=tdch.get(new URI(baseUri + "String_Node_Str"),parameters);
  fanQR=JSON.parse(resource.content);
  tdIds=fanQR.keys();
  Assert.assertFalse("String_Node_Str",tdIds.isEmpty());
  Assert.assertTrue("String_Node_Str",tdIds.contains(tdId));
  parameters.clear();
  parameters.put("String_Node_Str","String_Node_Str");
  resource=tdch.get(new URI(baseUri + "String_Node_Str"),parameters);
  fanQR=JSON.parse(resource.content);
  tdIds=fanQR.keys();
  Assert.assertFalse("String_Node_Str",tdIds.isEmpty());
  Assert.assertTrue("String_Node_Str",tdIds.contains(tdId));
  Assert.assertFalse("String_Node_Str",tdIds.contains(tdId2));
  ThingDescriptionHandler tdh=new ThingDescriptionHandler(tdId,Repository.get().servers);
  resource=tdh.get(new URI(baseUri + tdId),null);
  JsonObject o=JSON.parse(resource.content);
  JsonValue v=o.get("String_Node_Str").getAsArray().get(0);
  Assert.assertEquals("String_Node_Str","String_Node_Str" + tdUri + "String_Node_Str",v.toString());
  in=Repository.get().getClass().getClassLoader().getResourceAsStream("String_Node_Str");
  content=IOUtils.toByteArray(in);
  tdh.put(new URI(baseUri + tdId),new HashMap<String,String>(),new ByteArrayInputStream(content));
  RESTResource resource2=tdh.get(new URI(baseUri + tdId),null);
  JsonObject o2=JSON.parse(resource2.content);
  JsonValue v2=o2.get("String_Node_Str");
  Assert.assertEquals("String_Node_Str","String_Node_Str",v2.toString());
  tdh.delete(new URI(baseUri + tdId),null,null);
  td=ThingDescriptionUtils.getThingDescriptionIdFromUri(tdUri);
  Assert.assertEquals("String_Node_Str","String_Node_Str",td);
  tdh.delete(new URI(baseUri + tdId2),null,null);
  td=ThingDescriptionUtils.getThingDescriptionIdFromUri(tdUri2);
  Assert.assertEquals("String_Node_Str","String_Node_Str",td);
}