= BLL Integration Tests =

The itests package contain integration tests for the backend.

We run the tests in an embedded JBoss container. We:

  - Start the embedded app server
  - Set up our quartz based scheduler
  - Register a fake VDS broker with JNDI
  - Initialize a full instance of the Backend class
  - Set up a user session

In order to run these tests, you need:

  - A database instance
  - Nothing running on the ports the embedded JBoss binds to

Each of these tests executes an action or query through using the
Backend instance and checks the result e.g.

   VdcReturnValueBase runAction = backend.runInternalAction(VdcActionType.AddVmTemplate, parameters)

Conflicts are avoided with the existing state of the DB with tricks
like creating new VMs with a unique suffix:

  public static final String testSequence = "-JUnit-" + System.currentTimeMillis();

  vm.setvm_name("vm" + testSequence);

== Running The Tests ==

The tests require an uptodate MS-SQL database called 'engine' on the
'engine-test-db' host using the username 'sa' and password
'ENGINEadmin2009'.

The enable-bll-itests profile runs the tests:

  $> mvn -P enable-bll-itests test

or enable them using your ~/.m2/settings.xml:

   <activeProfiles>
     <activeProfile>enable-bll-itests</activeProfile>
   </activeProfiles>

You can also choose to run individual tests:

  $> mv -D test=QueriesTest test

== Changing The Ports Used ==

The ${engine.ejb3.connector.port} and ${engine.bisocket.connector.port}
properties define the port numbers used by the embedded JBoss instance.

In order to change these using ~/.m2/settings.xml you can do:

  <profile>
    <id>my-engine-profile</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <properties>
      <engine.ejb3.connector.port>3883</engine.ejb3.connector.port>
      <engine.bisocket.connector.port>4467</engine.bisocket.connector.port>
    </properties>
  </profile>

or, indeed, on the command line:

  $> mvn -Dengine.ejb3.connector.port=3883 -Dengine.bisocket.connector.port=4467 test

