BAEL-3200 Error handling with Spring AMQP

This commit is contained in:
Alexander Molochko
2019-10-17 03:01:56 +03:00
parent db85c8f275
commit 70d5e7c57d
20386 changed files with 1639315 additions and 0 deletions
@@ -0,0 +1,37 @@
package com.baeldung.nanohttpd;
import static org.junit.Assert.*;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
public class ItemGetControllerUnitTest {
private static final String URL = "http://localhost:8071";
private static final HttpClient CLIENT = HttpClientBuilder.create().build();
@BeforeClass
public static void setUp() throws IOException {
new ItemGetController();
}
@Test
public void givenServer_whenDoingGet_thenParamIsReadCorrectly() throws IOException {
HttpResponse response = CLIENT.execute(new HttpGet(URL + "?itemId=1234"));
assertEquals("Requested itemId = 1234", IOUtils.toString(response.getEntity().getContent()));
}
@Test
public void givenServer_whenDoingPost_then404IsReturned() throws IOException {
HttpResponse response = CLIENT.execute(new HttpPost(URL));
assertEquals(404, response.getStatusLine().getStatusCode());
}
}