remove utility classes (#1733)
* remove utility classes * remove httpclient, extend http * move code to core-java
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
package com.baeldung.http;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class HttpRequestBuilderTest {
|
||||
|
||||
private HttpRequestBuilder requestPerformer;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
requestPerformer = new HttpRequestBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetRequest_thenOk() throws IOException {
|
||||
HttpResponseWrapper response = requestPerformer.sendRequest("http://www.example.com", "GET", null, null);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
assertTrue("content incorrect", response.getContent()
|
||||
.contains("Example Domain"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPostRequest_thenOk() throws IOException {
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("param1", "val");
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
properties.put("Content-Type", "application/json");
|
||||
HttpResponseWrapper response = requestPerformer.sendRequest("http://www.example.com", "POST", parameters, properties);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.baeldung.httpclient;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.http.HttpResponseWrapper;
|
||||
|
||||
public class HttpClientRequestBuilderTest {
|
||||
private HttpClientRequestBuilder requestBuilder;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
requestBuilder = new HttpClientRequestBuilder();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenGetRequest_thenOk() {
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("param1", "val");
|
||||
HttpResponseWrapper response = requestBuilder.sendGetRequest("http://www.example.com",parameters);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
assertTrue("content incorrect", response.getContent()
|
||||
.contains("Example Domain"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPostRequestWithParameters_thenOk() {
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
parameters.put("param1", "val");
|
||||
HttpResponseWrapper response = requestBuilder.sendPostRequestWithParameters("http://www.example.com", parameters);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenPostRequestWithJson_thenOk() {
|
||||
String json = "{\"id\":\"1\"}";
|
||||
HttpResponseWrapper response = requestBuilder.sendPostRequestWithJson("http://www.example.com",json);
|
||||
assertEquals("status code incorrect", response.getStatus(), 200);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user