throw new RuntimeException("Admin should be able to invoke getUsers", ex);
}
}
public void sayHelloAsUser() throws Exception {
HelloWorld service = createServiceProxy("bob", "bobspassword");
System.out.println("Using HelloServiceRest with user priviliges");
System.out.println("Getting the list of existing users");
try {
Map<Integer, User> users = service.getUsers();
printUsers(users);
throw new RuntimeException("Only admin should be able to invoke getUsers");
} catch (WebApplicationException ex) {
Assert.assertEquals("403 response code is expected", 403, ex.getResponse().getStatus());
System.out.println("Access was denied for user bob");
}
System.out.println("Asking the service to add a new user Barry and also say hi");
try {
System.out.println(service.sayHi("Barry"));
System.out.println(service.sayHiToUser(new UserImpl("Barry")));
} catch (WebApplicationException ex) {
throw new RuntimeException("Should be able to sayHi");
}
}