@@ -0,0 +1,1043 @@
+package de.guderlei.pubsub.producer;%0A%0Aimport java.io.File;%0Aimport java.io.PrintWriter;%0A%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0A%0Aimport org.junit.Test;%0A%0Aimport de.guderlei.pubsub.model.Message;%0Aimport de.guderlei.pubsub.model.Producer;%0Aimport static org.junit.Assert.fail;%0Aimport static org.mockito.Mockito.*;%0A%0Apublic class PublisherServletTest %7B%0A%0A%09@Test%0A%09public void create_and_handle_message()%7B%0A%09%09%0A%09%09Producer producer = mock(Producer.class);%0A%09%09%0A%09%09PublisherServlet servlet = new PublisherServlet(producer);%0A%09%09%0A%09%09%0A%09%09HttpServletRequest request = mock(HttpServletRequest.class);%0A%09%09HttpServletResponse response = mock(HttpServletResponse.class);%0A%09%09%0A%09%09try %7B%0A%09%09%09File tmp = File.createTempFile(%22msg%22, %22.txt%22);%0A%09%09%09tmp.deleteOnExit();%0A%09%09%09%0A%09%09%09when(response.getWriter()).thenReturn(new PrintWriter(tmp));%0A%09%09%09%0A%09%09%09servlet.doGet(request, response);%0A%09%09%09verify(producer, only()).send(any(Message.class));%0A%09%09%09%0A%09%09%09tmp.delete();%0A%09%09%09%0A%09%09%7D catch (Exception e) %7B%09%09%09%0A%09%09%09e.printStackTrace();%0A%09%09%09fail();%0A%09%09%7D %0A%09%7D%0A%0A%7D%0A

test for publisher servlet