.getParameter("service"), this.serviceName);
this.requestMockControl.expectAndReturn(this.mockRequest.getReader(),this.reader);
this.requestMockControl.replay();
AbstractFeedHandler handler = new InsertFeedHandler();
try{
ServerBaseFeed feed = handler.createFeedFromRequest(this.mockRequest);
assertNotNull(feed.getId());
}catch (Exception e) {
e.printStackTrace();
fail("unexpected exception -- "+e.getMessage());
}
this.requestMockControl.verify();
this.requestMockControl.reset();
/*
* Test for not registered service
*/
this.requestMockControl.expectAndDefaultReturn(this.mockRequest
.getParameter("service"), "some other service");
this.requestMockControl.replay();
handler = new InsertFeedHandler();
try{
ServerBaseFeed feed = handler.createFeedFromRequest(this.mockRequest);
fail(" exception expected");
}catch (FeedHandlerException e) {
e.printStackTrace();
assertEquals(HttpServletResponse.SC_NOT_FOUND,handler.getErrorCode());
}
this.requestMockControl.verify();
this.requestMockControl.reset();
/*
* Test for IOException
*/
this.requestMockControl.expectAndDefaultReturn(this.mockRequest
.getParameter("service"), this.serviceName);
this.reader.close();
this.requestMockControl.expectAndReturn(this.mockRequest.getReader(),this.reader);
this.requestMockControl.replay();
handler = new InsertFeedHandler();
try{
ServerBaseFeed feed = handler.createFeedFromRequest(this.mockRequest);
fail(" exception expected");
}catch (IOException e) {
e.printStackTrace();
assertEquals(HttpServletResponse.SC_BAD_REQUEST,handler.getErrorCode());