Program: 8112
Project: 8112
Buggy source:
/** 
 * This tests that the collector returns the correct HTTP codes for invalid requests
 */
@Test public void testBadRequests() throws Exception {
  final String name="String_Node_Str";
  final String prefix="String_Node_Str";
  final String path="String_Node_Str";
  final int port=PortDetector.findFreePort();
  CConfiguration configuration=new CConfiguration();
  configuration.set(Constants.CONFIG_CONNECTORS,name);
  configuration.set(Constants.buildConnectorPropertyName(name,Constants.CONFIG_CLASSNAME),RestCollector.class.getCanonicalName());
  configuration.setInt(Constants.buildConnectorPropertyName(name,Constants.CONFIG_PORT),port);
  configuration.set(Constants.buildConnectorPropertyName(name,Constants.CONFIG_PATH_PREFIX),prefix);
  configuration.set(Constants.buildConnectorPropertyName(name,Constants.CONFIG_PATH_MIDDLE),path);
  RestCollector collector=new RestCollector();
  collector.setName(name);
  collector.setConsumer(new TestUtil.NoopConsumer());
  collector.setMetadataService(new DummyMDS());
  collector.configure(configuration);
  collector.start();
  String baseUrl=collector.getHttpConfig().getBaseUrl();
  Assert.assertEquals(200,TestUtil.sendGetRequest("String_Node_Str" + port + "String_Node_Str"));
  Assert.assertEquals(200,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest("String_Node_Str" + port + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest("String_Node_Str" + port + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl));
  Assert.assertEquals(200,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  ((DummyMDS)collector.getMetadataService()).allowAll();
  Assert.assertEquals(200,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(501,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  collector.stop();
}

Fixed version (ground truth):
/** 
 * This tests that the collector returns the correct HTTP codes for invalid requests
 */
@Test public void testBadRequests() throws Exception {
  final String name="String_Node_Str";
  final String prefix="String_Node_Str";
  final String path="String_Node_Str";
  final int port=PortDetector.findFreePort();
  CConfiguration configuration=new CConfiguration();
  configuration.set(Constants.CONFIG_CONNECTORS,name);
  configuration.set(Constants.buildConnectorPropertyName(name,Constants.CONFIG_CLASSNAME),RestCollector.class.getCanonicalName());
  configuration.setInt(Constants.buildConnectorPropertyName(name,Constants.CONFIG_PORT),port);
  configuration.set(Constants.buildConnectorPropertyName(name,Constants.CONFIG_PATH_PREFIX),prefix);
  configuration.set(Constants.buildConnectorPropertyName(name,Constants.CONFIG_PATH_MIDDLE),path);
  RestCollector collector=new RestCollector();
  collector.setName(name);
  collector.setConsumer(new TestUtil.NoopConsumer());
  collector.setMetadataService(new DummyMDS());
  collector.setAuthenticator(new NoAuthenticator());
  collector.configure(configuration);
  collector.start();
  String baseUrl=collector.getHttpConfig().getBaseUrl();
  Assert.assertEquals(200,TestUtil.sendGetRequest("String_Node_Str" + port + "String_Node_Str"));
  Assert.assertEquals(200,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest("String_Node_Str" + port + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest("String_Node_Str" + port + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl));
  Assert.assertEquals(200,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  ((DummyMDS)collector.getMetadataService()).allowAll();
  Assert.assertEquals(200,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(404,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  Assert.assertEquals(501,TestUtil.sendPostRequest(baseUrl + "String_Node_Str"));
  collector.stop();
}