* Test method for 'org.apache.lucene.gdata.servlet.handler.AbstractFeedHandler.createRequestedAccount(HttpServletRequest)'
*/
public void testCreateRequestedAccount() throws IOException, ParseException, ServiceException {
this.requestMockControl.expectAndDefaultReturn(this.mockRequest
.getParameter(AbstractFeedHandler.PARAMETER_ACCOUNT), this.accountName);
GDataAccount a = new GDataAccount();
a.setName("helloworld");
this.adminServiceMockControl.expectAndReturn(this.adminService.getAccount(this.accountName),a );
this.requestMockControl.replay();
this.adminServiceMockControl.replay();
AbstractFeedHandler handler = new InsertFeedHandler();
try{
GDataAccount account = handler.createRequestedAccount(this.mockRequest);
assertEquals(a,account);
}catch (Exception e) {
e.printStackTrace();
fail("unexpected exception -- "+e.getMessage());
}
this.requestMockControl.verify();
this.requestMockControl.reset();
this.adminServiceMockControl.verify();
this.adminServiceMockControl.reset();
/*
*Test for service exception
*/
this.requestMockControl.expectAndDefaultReturn(this.mockRequest
.getParameter(AbstractFeedHandler.PARAMETER_ACCOUNT), this.accountName);
a.setName("helloworld");
this.adminServiceMockControl.expectAndDefaultThrow(this.adminService.getAccount(this.accountName),new ServiceException(GDataResponse.BAD_REQUEST) );
this.requestMockControl.replay();
this.adminServiceMockControl.replay();
handler = new InsertFeedHandler();
try{
GDataAccount account = handler.createRequestedAccount(this.mockRequest);
fail(" exception expected ");
}catch (Exception e) {
e.printStackTrace();