@@ -0,0 +1,2619 @@
+package org.analogweb.core.response;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.hamcrest.CoreMatchers.nullValue;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.verify;%0Aimport static org.mockito.Mockito.when;%0A%0Aimport java.util.Map;%0A%0Aimport org.analogweb.Headers;%0Aimport org.analogweb.RequestContext;%0Aimport org.analogweb.ResponseContext;%0Aimport org.analogweb.ResponseContext.ResponseEntity;%0Aimport org.analogweb.ResponseContext.ResponseWriter;%0Aimport org.analogweb.core.DefaultResponseEntity;%0Aimport org.hamcrest.BaseMatcher;%0Aimport org.hamcrest.Description;%0Aimport org.hamcrest.Matcher;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Apublic class DefaultResponseTest %7B%0A%0A%09private DefaultResponse response;%0A%09private RequestContext requestContext;%0A%09private ResponseContext responseContext;%0A%0A%09@Before%0A%09public void setUp() throws Exception %7B%0A%09%09requestContext = mock(RequestContext.class);%0A%09%09responseContext = mock(ResponseContext.class);%0A%09%7D%0A%0A%09@Test%0A%09public void testRenderDefault() throws Exception %7B%0A%09%09response = new DefaultResponse();%0A%0A%09%09response.render(requestContext, responseContext);%0A%0A%09%09assertThat(response.getHeaders(), is(emptyMap()));%0A%09%09assertThat(response.getResponseEntity(), is(nullValue()));%0A%09%09verify(responseContext)%0A%09%09%09%09.setStatus(HttpStatus.NO_CONTENT.getStatusCode());%0A%09%7D%0A%0A%09@Test%0A%09public void testRenderEntityAndHeaders() throws Exception %7B%0A%09%09response = new DefaultResponse();%0A%09%09ResponseEntity entity = new DefaultResponseEntity(%22This Is TEST!%22);%0A%09%09response.setResponseEntity(entity);%0A%09%09ResponseWriter writer = mock(ResponseWriter.class);%0A%09%09when(responseContext.getResponseWriter()).thenReturn(writer);%0A%0A%09%09response.addHeader(%22Content-Type%22, %22text/plain%22);%0A%0A%09%09Headers responseHeaders = mock(Headers.class);%0A%09%09when(responseContext.getResponseHeaders()).thenReturn(responseHeaders);%0A%0A%09%09response.render(requestContext, responseContext);%0A%0A%09%09assertThat(response.getHeaders().size(), is(1));%0A%09%09assertThat(response.getHeaders().get(%22Content-Type%22), is(%22text/plain%22));%0A%09%09assertThat(response.getResponseEntity(), is(entity));%0A%09%09verify(responseHeaders).putValue(%22Content-Type%22, %22text/plain%22);%0A%09%09verify(writer).writeEntity(entity);%0A%09%09verify(responseContext).setStatus(HttpStatus.OK.getStatusCode());%0A%09%7D%0A%0A%09private Matcher%3CObject%3E emptyMap() %7B%0A%09%09return new BaseMatcher%3CObject%3E() %7B%0A%09%09%09@Override%0A%09%09%09public boolean matches(Object item) %7B%0A%09%09%09%09if (item instanceof Map && ((Map%3C?, ?%3E) item).isEmpty()) %7B%0A%09%09%09%09%09return true;%0A%09%09%09%09%7D%0A%09%09%09%09return false;%0A%09%09%09%7D%0A%0A%09%09%09@Override%0A%09%09%09public void describeTo(Description description) %7B%0A%0A%09%09%09%7D%0A%09%09%7D;%0A%09%7D%0A%0A%7D%0A

Add Testcase