@Test public void doHttpCallTest() throws IOException { HttpClientMock mockHttpClient = new HttpClientMock(200, "test"); JamService jamService = new JamService("http: jamService.setClient(mockHttpClient); String result = jamService.doHttpCall(new GetMethod(jamService.getJamServerBaseUrl() + "webservice/removeServiceQueue/" + URLEncoder.encode("mydata"))); assertTrue(result.equals("test")); }
protected String doHttpCall(HttpMethod method) throws IOException, HttpException { int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HttpException("Method failed: " + method.getStatusLine() + " Response:" + method.getResponseBodyAsString()); } return method.getResponseBodyAsString(); }
JamService { protected String doHttpCall(HttpMethod method) throws IOException, HttpException { int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HttpException("Method failed: " + method.getStatusLine() + " Response:" + method.getResponseBodyAsString()); } return method.getResponseBodyAsString(); } }
JamService { protected String doHttpCall(HttpMethod method) throws IOException, HttpException { int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HttpException("Method failed: " + method.getStatusLine() + " Response:" + method.getResponseBodyAsString()); } return method.getResponseBodyAsString(); } JamService(String jamServerBaseUrl); }
JamService { protected String doHttpCall(HttpMethod method) throws IOException, HttpException { int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HttpException("Method failed: " + method.getStatusLine() + " Response:" + method.getResponseBodyAsString()); } return method.getResponseBodyAsString(); } JamService(String jamServerBaseUrl); HttpClient getClient(); void setClient(HttpClient client); String getJamServerBaseUrl(); void setJamServerBaseUrl(String jamServerBaseUrl); void addServerToServiceQueue(final String queueName, final String brokerUrl,
                                        final String host, final int port); void disableServiceQueue(final String queueName); boolean doesServiceQueueExist(final String queueName, final String brokerUrl); void enableServiceQueue(final String queueName); void registerServiceQueue(final String queueName, final String brokerUrl,
                                     final int queryIntervalInSeconds, final boolean resetStatisticsAfterQuery,
                                     final boolean profileEnabled); void removeServerFromServiceQueue(final String queueName, final String brokerUrl,
                                             final String host, final int port); void removeServiceQueue(final String queueName); void runGather(final String queueName, final String brokerUrl); int loadJMXAgent(int port); }
JamService { protected String doHttpCall(HttpMethod method) throws IOException, HttpException { int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { throw new HttpException("Method failed: " + method.getStatusLine() + " Response:" + method.getResponseBodyAsString()); } return method.getResponseBodyAsString(); } JamService(String jamServerBaseUrl); HttpClient getClient(); void setClient(HttpClient client); String getJamServerBaseUrl(); void setJamServerBaseUrl(String jamServerBaseUrl); void addServerToServiceQueue(final String queueName, final String brokerUrl,
                                        final String host, final int port); void disableServiceQueue(final String queueName); boolean doesServiceQueueExist(final String queueName, final String brokerUrl); void enableServiceQueue(final String queueName); void registerServiceQueue(final String queueName, final String brokerUrl,
                                     final int queryIntervalInSeconds, final boolean resetStatisticsAfterQuery,
                                     final boolean profileEnabled); void removeServerFromServiceQueue(final String queueName, final String brokerUrl,
                                             final String host, final int port); void removeServiceQueue(final String queueName); void runGather(final String queueName, final String brokerUrl); int loadJMXAgent(int port); static final Logger LOGGER; }