Last updated January 18, 2011 11:20, by Jørgen Austvik
Feedicon  

How to start a test

There are several ways to start a test in JET, so that it is convenient for you to run the tests from your environment.

If you just want to run a single test with the client on the same machine that you are starting the test, then you can use JET to run the test. JETBatch adde the possibility to run several tests on several machines, and adds reporting.

JET

Usage:

  java com.sun.jet.framework.engine.JET <xmlfile> [options]

Options:

-b <property_file>
Default bindings
-v
Verbose
-runner <JETTestRunner class name>
Test runner
-c
Don't run the test, only check the XML-file.

In the classpath for JET, you need:

  • jet.jar
  • jag-ops.jar
  • testsuite.jar, where your TestSetup, TestCase, Client and test.xml files are
  • testsuite-dependencies.jars, one or several JAR files with classes used in your test suite. Example: derby.jar
  • jet-load.jar, if you are using load testing

Example:

  java -Xmx512m -cp jet.jar:testsuite.jar:testsuite-dependencies.jars:jag-ops.jar com.sun.jet.framework.engine.JET path/to/test/file.xml -v

An example shell script to run a JET test is in jet~framework/jet-examples/run.sh

JETBatch

Usage:

 java com.sun.jet.batch.JETBatch [options]
-testxmlfile <file>
Full or relative path to package and name to testxmlfile for the test to run, if you only want to run a single test
-propfile <file>
Full path and name to property file for test settings and test suites
-reportdir <dir>
Full path to report directory
-message <message>
Message to include in email to identify this test run
-loglevel <level>
Log level for jetbatch

Example:

  java -Xmx512m -cp jet-batch.jar:jag-ops.jar com.sun.jet.batch.JETBatch -reportdir /tmp/jetbatch -propfile settings.props -propfile testsuite.props

An example shell script to run a JET test is in jet~framework/jet-examples/run-batch.sh

Ant

Starting JET and JETBatch from Ant is similar to the shell scripts. This only gives an outline.

  <property name="jagopsjar"    value="${extlib}/jag-ops.jar"/>
  <property name="jagapijar"    value="${extlib}/jag-api.jar"/>
  <property name="jetbatchjar"  value="${extlib}/jet-batch.jar"/>
  <property name="testsuitejar"  value="${extlib}/something.jar"/>
  ...

 <target name="run" depends="init" description="Runs a test">

    <tstamp>
     <format property="timestamp.isoformat" pattern="yyyy-MM-dd'T'HHmmss" locale="en"/>
    </tstamp>

    <property file="${propfile}"/>
    <basename file="${propfile}" property="batchname" suffix="properties" />
    <condition property="jet.testlogpath" value="default_testlogpath" >
       <not>
          <isset property="jet.testlogpath" />
       </not>
    </condition>
    <property name="reportdir" value="${jet.testlogpath}/${batchname}${timestamp.isoformat}"/>
    <property name="jetbatch_classpath" value="${jetbatchjar}:${jagjar}:${jagopsjar}:${testsuitejar}" />
    <java classname="com.sun.jet.batch.JETBatch" classpath="${jetbatch_classpath}" fork="yes" newenvironment="yes" maxmemory="1024m">
      <sysproperty key="java.util.logging.config.file" value="config/logging.properties"/>
      <sysproperty key="jet.installpath.testsuite" file="dist"/>
      <arg line=" -propfile ${propfile} -reportdir ${reportdir}"/>
    </java>
 </target>

Or with JET:

    <java classname="com.sun.jet.framework.engine.JET" classpath="${jet_classpath}" fork="yes" newenvironment="yes" maxmemory="1024m">
      <sysproperty key="java.util.logging.config.file" value="config/logging.properties"/>
      <sysproperty key="jet.installpath.testsuite" file="dist"/>
      <arg line="${xmlfile} -b ${propfile} "/>
    </java>

Maven Plugin

JET has a Maven 2.2.1 plugin, that makes it easy to run JET tests of your code from Maven integration testing.

JET uses this maven plugin to test itself, you can take a look in jet~framework/integration-test/pom.xml for a live example on how to use this plugin. To run it, simply run mvn install in jet~framework.

The source code for the java plugin is in the jet~framework/maven-jet-plugin directory, and the settings in JetMojo.java and JetBatchMojo.java is documented in JavaDoc there.

Runtime settings

jet.java.home
Home directory for the Java to start JET with on platforms where this can not be detected
jetbatch.java.home
Home directory for the Java to start JET with on platforms where this can not be detected
jet.jvmargs
Arguments to the JVM that starts JET
jetbatch.jvmargs
Arguments to the JVM that starts JET
maven.test.skip
Set to true to skip these tests

Settings:

plugin.configuration.classpaths
List of classpath elements that should be used when JET or JETBatch is started
plugin.executions.execution.goal
jet or batch, depending on what you want to start
plugin.executions.execution.configuration.expectSuccess
true or false - set to false if you expect the test to fail
plugin.executions.execution.configuration.testName
The name of the test xml file to run
plugin.executions.execution.configuration.testNames
If you run a batch, you can specify several test xml files to run
plugin.executions.execution.configuration.installfiles
Files that you want to install in your install diractory before you run the test
plugin.executions.execution.configuration.startJagEmbedded
true or false, set to false if you want to start JAG before you run the test or batch
plugin.executions.execution.configuration.jagJar
If you are not running JAG embedded, then you can specify which jar to use when you start JAG with this setting
plugin.executions.execution.configuration.installDirectory
Where to install files and run test from
plugin.executions.execution.configuration.reportDirectory
Where to place reports after the run
plugin.executions.execution.configuration.portBase
Port base to use

Examples

Needed dependencies:

        <dependency>
            <groupId>com.sun.jet</groupId>
            <artifactId>jet</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jet</groupId>
            <artifactId>jet-batch</artifactId>
            <version>1.0-SNAPSHOT</version>
        </dependency>

Adding the plugin (example with JET):

    <build>
        <plugins>
            <plugin>
                <groupId>com.sun.jet</groupId>
                <artifactId>maven-jet-plugin</artifactId>
                <version>1.0-SNAPSHOT</version>
                <inherited>false</inherited>
                <configuration>
                    <classpaths>
                        <classpath>jet.jar</classpath>
                        <classpath>jag-ops.jar</classpath>
                        <classpath>testsuite.jar</classpath>
                        <classpath>jet-batch.jar</classpath>
                    </classpaths>
                </configuration>
                <executions>
                    <execution>
                        <id>jet with failing test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>jet</goal>
                        </goals>
                        <configuration>
                            <expectSuccess>false</expectSuccess>
                            <testName>/test/jet/some_file.xml</testName>
                            <installfiles>
                                <installFile>
                                    <fromPath>/path/jag-ops-1.0.jar</fromPath>
                                    <newName>jag-ops.jar</newName>
                                </installFile>
                            </installfiles>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Example with JETBatch:

                    <execution>
                        <id>batch with external jag</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>batch</goal>
                        </goals>
                        <configuration>
                            <startJagEmbedded>false</startJagEmbedded>
                            <jagJar>tools/jag.jar</jagJar>
                            <installfiles>
                                <installFile>
                                    <fromPath>${basedir}/jag-ops-1.0.jar</fromPath>
                                    <newName>jag-ops.jar</newName>
                                </installFile>
                                <installFile>
                                    <fromPath>${basedir}/jtestsuite-1.0.jar</fromPath>
                                    <newName>testsuite.jar</newName>
                                </installFile>
                            </installfiles>
                            <testNames>
                                <testName>${basedir}/test/jet/example.xml</testName>
                            </testNames>
                        </configuration>
                    </execution>

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close