HttpWebService extends ServletBase { protected Document getUsers() throws ServletException, IOException { IUserRoleListService service = PentahoSystem.get( IUserRoleListService.class ); Element rootElement = new DefaultElement( "users" ); Document doc = DocumentHelper.createDocument( rootElement ); if ( service != null ) { List users = service.getAllUsers(); for ( Iterator usersIterator = users.iterator(); usersIterator.hasNext(); ) { String username = usersIterator.next().toString(); if ( ( null != username ) && ( username.length() > 0 ) ) { rootElement.addElement( "user" ).addCDATA( username ); } } } return doc; } HttpWebService(); @Override Log getLogger(); String getPayloadAsString( final HttpServletRequest request ); void doGetFixMe( final HttpServletRequest request, final HttpServletResponse response ); @Override void doGet( final HttpServletRequest request, final HttpServletResponse response );  }
@Test public void testGetUsers() throws Exception { PentahoSystem.registerObject( userRoleListService ); List<String> users = Arrays.asList( new String[] { "admin", "suzy" } ); when( userRoleListService.getAllUsers() ).thenReturn( users ); Document doc = httpWebService.getUsers(); assertNotNull( doc ); assertEquals( users.size(), doc.getRootElement().elements().size() ); }