### Question:
PrometheusReporter implements MetricReporter { @VisibleForTesting int getPort() { Preconditions.checkState(httpServer != null, "Server has not been initialized."); return port; }  @Override void open(MetricConfig config); @Override void close(); @Override void notifyOfAddedMetric(final Metric metric, final String metricName, final MetricGroup group); @Override void notifyOfRemovedMetric(final Metric metric, final String metricName, final MetricGroup group);  }### Answer:
@Test public void cannotStartTwoReportersOnSamePort() throws Exception { final MetricRegistryImpl fixedPort1 = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test1", portRangeProvider.next()))); assertThat(fixedPort1.getReporters(), hasSize(1)); PrometheusReporter firstReporter = (PrometheusReporter) fixedPort1.getReporters().get(0); final MetricRegistryImpl fixedPort2 = new MetricRegistryImpl(MetricRegistryConfiguration.fromConfiguration(createConfigWithOneReporter("test2", String.valueOf(firstReporter.getPort())))); assertThat(fixedPort2.getReporters(), hasSize(0)); fixedPort1.shutdown().get(); fixedPort2.shutdown().get(); }