HttpSamplingManager implements SamplingManager { @Override public SamplingStrategyResponse getSamplingStrategy(String serviceName) throws SamplingStrategyErrorException { String jsonString; try { jsonString = makeGetRequest( "http: } catch (IOException e) { throw new SamplingStrategyErrorException( "http call to get sampling strategy from local agent failed.", e); } return parseJson(jsonString); } HttpSamplingManager();  HttpSamplingManager(String hostPort); @Override SamplingStrategyResponse getSamplingStrategy(String serviceName); static final String DEFAULT_HOST_PORT; }
@Test public void testGetSamplingStrategy() throws Exception { URI uri = target().getUri(); undertest = new HttpSamplingManager(uri.getHost() + ":" + uri.getPort()); SamplingStrategyResponse response = undertest.getSamplingStrategy("clairvoyant"); assertNotNull(response.getProbabilisticSampling()); }
@Test (expected = SamplingStrategyErrorException.class) public void testGetSamplingStrategyError() throws Exception { URI uri = target().getUri(); undertest = new HttpSamplingManager(uri.getHost() + ":" + uri.getPort()); undertest.getSamplingStrategy(""); }
@Test(expected = SamplingStrategyErrorException.class) public void testDefaultConstructor() { HttpSamplingManager httpSamplingManager = new HttpSamplingManager(); httpSamplingManager.getSamplingStrategy("name"); }