use of org.apache.servicecomb.http.client.common.HttpTransport in project incubator-servicecomb-java-chassis by apache.
the class ServiceCenterRawClientTest method TestDefaultParameter.
@Test
public void TestDefaultParameter() throws IOException {
HttpTransport httpTransport = Mockito.mock(HttpTransport.class);
AddressManager addressManager = new AddressManager(PROJECT_NAME, Arrays.asList("http://127.0.0.1:30100"), new EventBus());
ServiceCenterRawClient client = new ServiceCenterRawClient.Builder().setHttpTransport(httpTransport).setAddressManager(addressManager).setTenantName(TENANT_NAME).build();
HttpResponse httpResponse = new HttpResponse();
httpResponse.setStatusCode(200);
httpResponse.setContent("ok");
Mockito.when(httpTransport.doRequest(Mockito.any())).thenReturn(httpResponse);
HttpResponse actualGetResponse = client.getHttpRequest(null, null, null);
HttpResponse actualPostResponse = client.postHttpRequest(null, null, null);
HttpResponse actualPutResponse = client.putHttpRequest(null, null, null);
HttpResponse actualDeleteResponse = client.putHttpRequest(null, null, null);
Assert.assertNotNull(actualGetResponse);
Assert.assertEquals("ok", actualGetResponse.getContent());
Assert.assertNotNull(actualPostResponse);
Assert.assertEquals("ok", actualPostResponse.getContent());
Assert.assertNotNull(actualPutResponse);
Assert.assertEquals("ok", actualPutResponse.getContent());
Assert.assertNotNull(actualDeleteResponse);
Assert.assertEquals("ok", actualDeleteResponse.getContent());
}
Aggregations