maven cleanup work

This commit is contained in:
eugenp
2016-12-27 13:00:01 +02:00
parent ed89b85f18
commit bfaff06813
4 changed files with 11 additions and 8 deletions
@@ -0,0 +1,34 @@
package com.baeldung.servlets;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.junit.Test;
public class FormServletLiveTest {
@Test
public void whenPostRequestUsingHttpClient_thenCorrect() throws Exception {
HttpClient client = new DefaultHttpClient();
HttpPost method = new HttpPost("http://localhost:8080/calculateServlet");
List<BasicNameValuePair> nvps = new ArrayList<>();
nvps.add(new BasicNameValuePair("height", String.valueOf(2)));
nvps.add(new BasicNameValuePair("weight", String.valueOf(80)));
method.setEntity(new UrlEncodedFormEntity(nvps));
HttpResponse httpResponse = client.execute(method);
assertEquals("Success", httpResponse.getHeaders("Test")[0].getValue());
assertEquals("20.0", httpResponse.getHeaders("BMI")[0].getValue());
}
}