Overview

This project provides Arquillian container adapters for running tests on Eclipse GlassFish server in different modes:

  • Managed – Starts and stops a local GlassFish server instance.

  • Remote – Connects to a running GlassFish server instance.

  • Embedded – Runs Embedded GlassFish in-process in the test JVM.

Installation

Add one of the following dependencies to your Maven pom.xml, depending on your target container mode.

Managed GlassFish

<dependency>
  <groupId>ee.omnifish.arquillian</groupId>
  <artifactId>arquillian-glassfish-server-managed</artifactId>
  <version>YOUR_VERSION</version>
  <scope>test</scope>
</dependency>

Remote GlassFish

<dependency>
  <groupId>ee.omnifish.arquillian</groupId>
  <artifactId>arquillian-glassfish-server-remote</artifactId>
  <version>YOUR_VERSION</version>
  <scope>test</scope>
</dependency>

Embedded GlassFish

<dependency>
  <groupId>ee.omnifish.arquillian</groupId>
  <artifactId>arquillian-glassfish-server-embedded</artifactId>
  <version>YOUR_VERSION</version>
  <scope>test</scope>
</dependency>

Configuration Options

The following configuration options are available for all GlassFish Arquillian containers (managed, remote, embedded). Each option may be set via a system property (-Dglassfish.X) or inside arquillian.xml as a container <property>.

Configuration Table

Property (arquillian.xml) System Property Type Default Modes Description

glassFishHome

glassfish.home

String

none

Managed

The local GlassFish installation directory (required)

adminHost

glassfish.adminHost

String

localhost

Managed, Remote

Admin server host address

adminPort

glassfish.adminPort

int

4848

Managed, Remote

Admin console port

adminHttps

glassfish.adminHttps

boolean

false

Managed, Remote

Use HTTPS for admin URL

httpPort

glassfish.httpPort

int

8080

Managed, Remote

HTTP port

httpsPort

glassfish.httpsPort

int

8181

Managed, Remote

HTTPS port

authorisation

glassfish.authorisation

boolean

false

Managed, Remote

Enable login with admin credentials

ignoreCertificates

glassfish.ignoreCertificates

boolean

false

All

If SSL certificates are ignored

adminUser

glassfish.adminUser

String

none

Managed, Remote

Admin username (required if authorisation=true)

adminPassword

glassfish.adminPassword

String

none

Managed, Remote

Admin password (required if authorisation=true)

target

glassfish.target

String

server

All

Deployment target (e.g., server, cluster, instance_name)

libraries

glassfish.libraries

String

none

Managed

Comma-separated library JAR paths for deployed applications

properties

glassfish.properties

String

none

All

Additional deployment properties for the deployment - keyword-value pairs.

type

glassfish.type

String

none

All

Deployment archive type (e.g., osgi)

domain

glassfish.domain

String

none

Managed

GlassFish domain name. The default will be used if not specified

postBootCommands

glassfish.postBootCommands

String

none

Managed, Embedded

Multiline asadmin commands executed after boot

systemProperties

glassfish.systemProperties

String

none

Managed

Multiline JVM system properties

httpsPortAsDefault

glassfish.httpsPortAsDefault

boolean

false

All

Use HTTPS port as default connector

debug

glassfish.debug

boolean

false

Managed

Start server in debug mode

suspend

glassfish.suspend

boolean

false

Managed

Suspend until debugger connects

addDeployName

glassfish.addDeployName

boolean

false

All

Add deploy name to archive

outputToConsole

glassfish.outputToConsole

boolean

true

Managed

Show the output of the admin commands on the console

allowConnectingToRunningServer

glassfish.allowConnectingToRunningServer

boolean

false

Managed

Allow Arquillian to use an already running GlassFish instance

keepServerRunning

glassfish.keepServerRunning

boolean

false

Managed

Starts the server if needed, but keeps it running after tests

keepDeployment

glassfish.keepDeployment

boolean

false

Managed

Keep deployment after tests

enableDerby

glassfish.enableDerby

boolean

false

Managed

Flag to start/stop the registered Derby server using standard Derby port

derbyDatabaseName

glassfish.derbyDatabaseName

String

none

Managed

Derby database name

derbySQLFile

glassfish.derbySQLFile

String

none

Managed

Derby SQL file to execute

derbyUser

glassfish.derbyUser

String

none

Managed

Derby user

derbyPasswordFile

glassfish.derbyPasswordFile

String

none

Managed

Derby password file

maxHeapSize

glassfish.maxHeapSize

String

none

Managed

JVM max heap size (e.g., 2048m)

enableAssertions

glassfish.enableAssertions

String

none

Managed

Enable JVM assertions for specific packages (e.g., :org.jboss.cdi.tck…​)

bindHttpPort

none

int

8181

Embedded

The port number of the http-listener for the embedded GlassFish server

bindHttpsPort

none

int

8182

Embedded

The port number of the https-listener for the embedded GlassFish server

instanceRoot

none

String

none

Embedded

The instance root directory (parent of server instance directory)

installRoot

none

String

none

Embedded

The location of the GlassFish installation root directory

configurationReadOnly

none

boolean

true

Embedded

Specifies whether GlassFish should writeback changes to configuration file

configurationXml

none

String

none

Embedded

Location of configuration file (domain.xml) for the GlassFish server

resourcesXml

none

String

none

Embedded

Comma-separated list of GlassFish resources.xml files to add using add-resources command

cleanup

none

boolean

true

Embedded

Specifies whether Arquillian should cleanup on shutdown (deletes instanceRoot files)

Usage Notes

  • System properties must be passed to the JVM, e.g. -Dglassfish.adminPort=4848.

  • arquillian.xml should define properties under the container configuration:

<container qualifier="glassfish-managed" default="true">
  <configuration>
    <property name="adminUser">admin</property>
    <property name="adminPassword">admin123</property>
  </configuration>
</container>
  • Properties like postBootCommands and systemProperties support multiline values.

  • When authorisation is enabled, both adminUser and adminPassword must be provided.

Usage Examples

Example: arquillian.xml for Managed GlassFish

<arquillian>
  <container qualifier="glassfish-managed" default="true">
    <configuration>
      <property name="adminUser">admin</property>
      <property name="adminPassword">admin123</property>
      <property name="glassfishHome">${env.GLASSFISH_HOME}</property>
      <property name="postBootCommands">
        create-jdbc-connection-pool --datasourceclassname=com.mysql.cj.jdbc.MysqlDataSource ...
        create-jdbc-resource --connectionpoolid=MyPool jdbc/MyDS
      </property>
    </configuration>
  </container>
</arquillian>

Example: Passing System Properties

Run tests with:

-Dglassfish.adminUser=admin -Dglassfish.adminPassword=admin123