Program: 15660
Project: 15660
Buggy source:
/** 
 * Test of the search resource.
 * @throws Exception 
 */
@Test public void testSearchResource() throws Exception {
  clientUtil.createUser("String_Node_Str");
  String search1AuthToken=clientUtil.login("String_Node_Str");
  WebResource subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  MultivaluedMapImpl postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str","String_Node_Str");
  ClientResponse response=subscriptionResource.put(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  JSONObject json=response.getEntity(JSONObject.class);
  WebResource searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  JSONArray articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(1,articles.length());
  JSONObject article=articles.getJSONObject(0);
  Assert.assertEquals("String_Node_Str",article.getString("String_Node_Str"));
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(0,articles.length());
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(1,articles.length());
  Assert.assertEquals("String_Node_Str",articles.getJSONObject(0).getString("String_Node_Str"));
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(2,articles.length());
  clientUtil.createUser("String_Node_Str");
  String search2AuthToken=clientUtil.login("String_Node_Str");
  subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(search2AuthToken));
  postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.put(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search2AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(2,articles.length());
  clientUtil.createUser("String_Node_Str");
  String search3AuthToken=clientUtil.login("String_Node_Str");
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search3AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(0,articles.length());
}

Fixed version (ground truth):
/** 
 * Test of the search resource.
 * @throws Exception 
 */
@Test public void testSearchResource() throws Exception {
  clientUtil.createUser("String_Node_Str");
  String search1AuthToken=clientUtil.login("String_Node_Str");
  WebResource subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  MultivaluedMapImpl postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str","String_Node_Str");
  ClientResponse response=subscriptionResource.put(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  JSONObject json=response.getEntity(JSONObject.class);
  WebResource searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  JSONArray articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(1,articles.length());
  JSONObject article=articles.getJSONObject(0);
  Assert.assertEquals("String_Node_Str",article.getString("String_Node_Str"));
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(0,articles.length());
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(2,articles.length());
  Assert.assertEquals("String_Node_Str",articles.getJSONObject(0).getString("String_Node_Str"));
  Assert.assertEquals("String_Node_Str",articles.getJSONObject(1).getString("String_Node_Str"));
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search1AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(2,articles.length());
  clientUtil.createUser("String_Node_Str");
  String search2AuthToken=clientUtil.login("String_Node_Str");
  subscriptionResource=resource().path("String_Node_Str");
  subscriptionResource.addFilter(new CookieAuthenticationFilter(search2AuthToken));
  postParams=new MultivaluedMapImpl();
  postParams.add("String_Node_Str","String_Node_Str");
  response=subscriptionResource.put(ClientResponse.class,postParams);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search2AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(2,articles.length());
  clientUtil.createUser("String_Node_Str");
  String search3AuthToken=clientUtil.login("String_Node_Str");
  searchResource=resource().path("String_Node_Str");
  searchResource.addFilter(new CookieAuthenticationFilter(search3AuthToken));
  response=searchResource.get(ClientResponse.class);
  Assert.assertEquals(Status.OK,Status.fromStatusCode(response.getStatus()));
  json=response.getEntity(JSONObject.class);
  articles=json.getJSONArray("String_Node_Str");
  Assert.assertEquals(0,articles.length());
}