Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class GlassFishTestHelper {
- public static void createFileUser(String userName, String userPassword, String userGroups) throws Exception {
- // Get the running arquillian embedded glassfish
- Server server = Server.getServer(Server.getServerNames().get(0));
- String command = "create-file-user";
- ParameterMap params = new ParameterMap();
- params.add("userpassword", userPassword);
- params.add("groups", userGroups);
- params.add("username", userName);
- CommandRunner runner = server.getHabitat().getComponent(CommandRunner.class);
- ActionReport report = server.getHabitat().getComponent(ActionReport.class);
- runner.getCommandInvocation(command, report).parameters(params).execute();
- if (report.getMessage() != null) {
- throw new Exception(String.format("Failed to create user : %s - message %s",
- userName, report.getMessage()), report.getFailureCause());
- }
- }
- public static boolean loginFileUser(String userName, String userPassword) throws Exception {
- ProgrammaticLogin pgLogin = new ProgrammaticLogin();
- return pgLogin.login(userName, userPassword.toCharArray(), "fileRealm", true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement