Uploaded image for project: 'Arquillian'
  1. Arquillian
  2. ARQ-592

Bind CommandRunner to JNDI when GlassFish Embedded Container starts

    Details

      Description

      It would be really useful if the Glassfish CommandRunner could be bound to jndi when the embedded container is started.

      Looks like it would just be a case of adding

       
      CommandRunner commandRunner = glassfish.getCommandRunner();
      new InitialContext().bind("org.glassfish.embeddable.CommandRunner", commandRunner);
      

      to the start method on the GlassfishContainer and then unbinding it on the stop method.

      Then in the test class we could use

       
      @Resource(mappedName = "org.glassfish.embeddable.CommandRunner")
      CommandRunner commandRunner;
      

      This would open up all the glassfish admin commands from test classes.

      api http://embedded-glassfish.java.net/nonav/apidocs/org/glassfish/embeddable/CommandRunner.html
      asadmin http://download.oracle.com/docs/cd/E18930_01/html/821-2416/giobi.html#scrolltoc

        Gliffy Diagrams

          Activity

          Hide
          aslak Aslak Knutsen added a comment -

          You want to look at this Magnus?

          Show
          aslak Aslak Knutsen added a comment - You want to look at this Magnus?
          Hide
          magnus.smith Magnus Smith added a comment -

          yes happy to look at this one

          Show
          magnus.smith Magnus Smith added a comment - yes happy to look at this one
          Hide
          magnus.smith Magnus Smith added a comment -

          pull request https://github.com/arquillian/arquillian-container-glassfish/pull/5

          I also have an idea of using this to develop an arquillian extension for embedded glassfish that would allow easy testing of ejbs requiring security roles against a jdbc realm in the embedded derby that is shipped with embedded glassfish.

          The process would be

          #1 Provide an annotation with parameters for realm name, username, password and a list of roles.

          Process the annotation and set up the security realm before the test run :

          #2 Use the commandRunner to create a jdbc connection pool using the embedded derby database.

          #3 Use the commandRunner to create a datasource

          #4 Use that data source to create the user and group tables

          #5 Populate tables with user and roles from the annotation

          #6 Use the commandRunner to create create-auth-realm

          run the tests ....

          There was a bug http://java.net/jira/browse/GLASSFISH-16277 in embedded glassfish that prevented asadmin commands requiring a password file to work.

          This has been fixed now but is only available in glassfish 3.1.1 b07 onwards.
          The problem at the moment is that the command create-auth-realm requires a password file and this does not work with the version of embedded glassfish 3.1 currently used arquillian.

          Show
          magnus.smith Magnus Smith added a comment - pull request https://github.com/arquillian/arquillian-container-glassfish/pull/5 I also have an idea of using this to develop an arquillian extension for embedded glassfish that would allow easy testing of ejbs requiring security roles against a jdbc realm in the embedded derby that is shipped with embedded glassfish. The process would be #1 Provide an annotation with parameters for realm name, username, password and a list of roles. Process the annotation and set up the security realm before the test run : #2 Use the commandRunner to create a jdbc connection pool using the embedded derby database. #3 Use the commandRunner to create a datasource #4 Use that data source to create the user and group tables #5 Populate tables with user and roles from the annotation #6 Use the commandRunner to create create-auth-realm run the tests .... There was a bug http://java.net/jira/browse/GLASSFISH-16277 in embedded glassfish that prevented asadmin commands requiring a password file to work. This has been fixed now but is only available in glassfish 3.1.1 b07 onwards. The problem at the moment is that the command create-auth-realm requires a password file and this does not work with the version of embedded glassfish 3.1 currently used arquillian.
          Hide
          aslak Aslak Knutsen added a comment -

          pushed upstream

          Show
          aslak Aslak Knutsen added a comment - pushed upstream

            People

            • Assignee:
              magnus.smith Magnus Smith
              Reporter:
              magnus.smith Magnus Smith
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development