HTML Files

The test programs created by TestKit, when called from an Applet, firstly attempt to execute and collect data as a CGI program on the host server.  If the environment is found to be unsuitable to execute the program, the test programs automatically fallback to running the program via the Java plug-in on the client machine. 

 

In this case a message such as that shown above may appear.  Changes may need to be made to the plug-in policy file and any data collected will be written to the client machine.

 

 

Applets

The TestKit™ program creates the basic Hypertext Markup Language (HTML/HTM) script required to run a test through a Web Browser.  These commands will run provided you are accessing the script via a Java enabled Net Browser utilizing Java version 1.4.2.

 

However, in order to run the scripts via non-Java enabled browsers or Java enabled browsers which access other versions of Java, additional embedded commands must also be included.  HTMLConverter plug-in programs which translate HTML APPLET commands to OBJECT commands are publicly available.  Following conversion by these programs, non-Java enabled browsers will run the HTML file via a locally installed Java™ Plug-in and prompt the user to download one when there is not one available on the local machine.  The following example shows sample code before and after conversion using the Java™ Plug-in HTML Converter available from Sun Microsystems at http://www.java.sun.com/.

 

Prior to conversion:

 

<HTML>

<HEAD>

<TITLE>TestKit HTML Page</TITLE>

</HEAD>

<BODY>

<H3><HR WIDTH="100%">Test demo<HR WIDTH="100%"></H3>

<P>

<APPLET CODE = "TestKit.StartTester" ARCHIVE = "demo.jar" width="0%" height="0%">

<PARAM NAME = "type" VALUE = "application/x-java-archive;jpi-version=1.4.2_04" />

<PARAM NAME = CODEBASE VALUE = "file:/C:/My Programs/Hexworx/TestKit /TestKitProjects/" >

<PARAM NAME = "defaultPath" VALUE = "C:/My Programs/Hexworx /TestKit/TestKitProjects" />

<PARAM NAME = "defaultTestName" VALUE = "demo" />

<PARAM NAME = "Entry" VALUE = "T" />

</APPLET>

</P>

<FONT SIZE=-1><I>TestKit Generation</I></FONT>

</BODY>

</HTML>

 

 

Following conversion:

 

<HTML>

<HEAD>

<TITLE>TestKit HTML Page</TITLE>

</HEAD>

<BODY>

<H3><HR WIDTH="100%">Test demo<HR WIDTH="100%"></H3>

<P>

 

<!--"CONVERTED_APPLET"-->

<!-- HTML CONVERTER -->

<OBJECT

    classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"

    codebase = "http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"

    WIDTH = "0%" HEIGHT = "0%" >

    <PARAM NAME = CODE VALUE = "TestKit.StartTester" >

    <PARAM NAME = ARCHIVE VALUE = "demo.jar" >

    <PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.4">

    <PARAM NAME = "scriptable" VALUE = "false">

    <PARAM NAME = "type" VALUE = "application/x-java-archive;jpi-version=1.4.2_04" />

 

    <PARAM NAME = CODEBASE VALUE = "file:/C:/My Programs/Hexworx/TestKit /TestKitProjects/" >

    <PARAM NAME = "defaultPath" VALUE = "C:/My Programs/Hexworx/TestKit /TestKitProjects" />

    <PARAM NAME = "defaultTestName" VALUE = "demo" />

    <PARAM NAME = "Entry" VALUE="T" />

    <COMMENT>

      <EMBED

            type = "application/x-java-applet;version=1.4" \

            CODE = "TestKit.StartTester" \

            ARCHIVE = "demo.jar" \

            WIDTH = "0%" \

            HEIGHT = "0%" \

            type = "application/x-java-archive;jpi-version=1.4.2_04" / \

            CODEBASE = "file:/C:/My Programs/Hexworx/TestKit /TestKitProjects/" \

            defaultPath = "C:/My Programs/Hexworx/TestKit /TestKitProjects" / \

            defaultTestName = "demo" / \

            Entry ="T" / \

          scriptable = false \

          pluginspage = "http://java.sun.com/products/plugin/index.html#download">

          <NOEMBED>

           

            </NOEMBED>

      </EMBED>

    </COMMENT>

</OBJECT>

 

<!--

<APPLET CODE = "TestKit.StartTester" ARCHIVE = "demo.jar" WIDTH = "0%" HEIGHT = "0%">

<PARAM NAME = "type" VALUE = "application/x-java-archive;jpi-version=1.4.2_04" />

<PARAM NAME = CODEBASE VALUE = "file:/C:/My Programs/Hexworx/TestKit /TestKitProjects/" >

<PARAM NAME = "defaultPath" VALUE = "C:/My Programs/Hexworx/TestKit /TestKitProjects" />

<PARAM NAME = "defaultTestName" VALUE = "demo" />

<PARAM NAME = "Entry" VALUE="T" />

 

</APPLET>

-->

<!--"END_CONVERTED_APPLET"-->

 

</P>

<FONT SIZE=-1><I>TestKit Generation</I></FONT>

</BODY>

</HTML>

 

The above shows the results of applying the Java Version 1.4.2 HTMLConverter to the TestKit applet.  File formats differ between Java versions and TestKit programs require version 1.4.2 to run correctly.  If the incorrect version is used, a message such as the following will appear[1]:

 

 

java.io.InvalidClassException: javax.swing.JComponent; local class incompatible: stream classdesc serialVersionUID = 6954663636822719621, local class serialVersionUID = -7908749299918704233

 

 

The converted Applet will automatically download the required Java plug-in if it is not available on the target client machine.  However, if an HTMLConverter program other than the 1.4.2 version is used to convert the Applet, then the converted Applet will default to downloading the plug-in for that version.  In these cases the converted Applet file should be edited to replace references to the version number with 1.4.2.  For example, the following has been converted using 1.4.1.

 

<HTML>

<HEAD>

<TITLE>TestKit HTML Page</TITLE>

</HEAD>

<BODY>

<H3><HR WIDTH="100%">Test demo<HR WIDTH="100%"></H3>

<P>

<!--"CONVERTED_APPLET"-->

<!-- HTML CONVERTER -->

<OBJECT

    classid = "clsid:CAFEEFAC-0014-0001-0000-ABCDEFFEDCBA"

    codebase = "http://java.sun.com/products/plugin/autodl/jinstall-1_4_1-windows-i586.cab#Version=1,4,1,0"

    WIDTH = "100%" HEIGHT = "100%" >

    <PARAM NAME = CODE VALUE = "TestKit.StartTester" >

    <PARAM NAME = CODEBASE VALUE = "file:/C:/My Programs/Hexworx/TestKit/TestKitProjects/" >

    <PARAM NAME = ARCHIVE VALUE = "demo.jar" >

    <PARAM NAME = "type" VALUE = "application/x-java-applet;jpi-version=1.4.1">

    <PARAM NAME = "scriptable" VALUE = "false">

    <PARAM NAME = "defaultPath" VALUE="C:/My Programs/Hexworx/TestKit/TestKitProjects" />

    <PARAM NAME = "defaultTestName" VALUE="demo" />

    <PARAM NAME = "Entry" VALUE="T" />

 

    <COMMENT>

  <EMBED

            type = "application/x-java-applet;jpi-version=1.4.1"

            CODE = "TestKit.StartTester"

            JAVA_CODEBASE = "file:/C:/My Programs/Hexworx/TestKit/TestKitProjects/"

            ARCHIVE = "demo.jar"

            WIDTH = "100%"

            HEIGHT = "100%"

            defaultPath ="C:/My Programs/Hexworx/TestKit/TestKitProjects" /

            defaultTestName ="demo" /

            Entry ="T" /

      scriptable = false

      pluginspage = "http://java.sun.com/products/plugin/index.html#download">

      <NOEMBED>

           

          </NOEMBED>

  </EMBED>

    </COMMENT>

</OBJECT>

 

<!--

<APPLET CODE = "TestKit.StartTester" JAVA_CODEBASE = "file:/C:/My Programs/Hexworx/TestKit/TestKitProjects/" ARCHIVE = "demo.jar" WIDTH = "100%" HEIGHT = "100%">

<PARAM NAME = "defaultPath" VALUE="C:/My Programs/Hexworx/TestKit/TestKitProjects" />

<PARAM NAME = "defaultTestName" VALUE="demo" />

<PARAM NAME = "Entry" VALUE="T" />

 

</APPLET>

-->

 

<!--"END_CONVERTED_APPLET"-->

 

</P>

<FONT SIZE=-1><I>TestKit Generation</I></FONT>

</BODY>

</HTML>

 

The bolded entries should be changed as follows:

 

 

classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"

codebase = "http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0"

 

 

<PARAM NAME = "type" VALUE = "application/x-java-applet;version=1.4">

 

 

type = "application/x-java-archive;jpi-version=1.4.2_04"

 

 

Note that although conversion may be performed by manual editing of the APPLET file, use of the HTMLConverter utility will make it more likely that the web locations of the Java Plug-in will be current.  The classid and codebase parameters instruct the program to download the correct Java Plug-in version and shoukd be omitted if this behaviour is not required.

 

Alternative code may be placed between the <NOEMBED> tags for browsers which fail to recognize any of the tags inserted by the HTMLConverter.  The following will insert an anchor tag which may be used to download and execute the test program on the client machine:

 

<NOEMBED>

<b><span style='color:red'>Your browser does not support this function.</span></b>

<p text="#556B2F">

<i><b>The demo program may also be downloaded and run by clicking on the following link.</b></i>

<i><b><a href ="/Tester/TesterDemo/demo.jar?defaultPath=%5CTester%5CTesterDemo&defaultTestName=demo&Entry=T">Download demo</a></b></i>

</NOEMBED>

 

If your server environment is suitable for running the test program as a CGI program then the references required for downloading the Java plug-in may be omitted.

 


 

Security Restrictions

 

Applets are subject to security restrictions which prevent access to local file systems.  If your server environment will not run the test program in CGI mode and falls back to attempting to use the Java plug-in, a message such as the following may be received:

 

 

Contact your system administer to request creation or updating of your local Java plug-in Policy File to grant file system writing privileges for your HTML file.  Further information on performing this task is available in the Quick Tour of Controlling Applets lesson of the Java™ Tutorial which is publicly available at the Sun Microsystems hyperlink address at http://www.java.sun.com/.  A copy of the policytool program for updating the policy file is also available from this site.

 

Having located the policy file in use for the Java 1.4.2 plug-in, add a policy entry for the programs you wish to run via a Net Browser.

 

 

 

The CodeBase will be the directory in which the HTML file is to be run from, expressed as a URL.  For example:

 

file:/C:/My Programs/ Hexworx/TestKit/TestKitProjects

 

or, more generically, on a multi-user system, something such as the following might be used:

 

file:${user.home}/ Hexworx/TestKit/TestKitProjects

 

Enter the codebase in the CodeBase field of the policy tool.

 

 

The specific permissions which must be added are those granting write access to the local file system.  This is required in order to save the data files created.  Add these entries as follows:

 

Access to the file system

 

 

Security problems may also be overcome by converting the test program you have created from untrusted to trusted form.  This is achieved by signing the jar file using information provided by a Certification Authority.

 

 

Common Gateway Interface

The HTML files created assume use of a Net Browser which can read the content of ARCHIVE files.  This will only be true for more recently released versions of  browsers.  Test programs created by TestKit are executable Java archive files.  As such, they may be run in the same manner as CGI (Common Gateway Interface server-side) programs.  That is, the program name and arguments may be entered as a URL address.  For example:

 

http://Server:port/directory/demo.jar?defaultPath=${user.home}/ Hexworx/TestKit/TestKitProjects&defaultTestName=demo&Entry=T

 

where:

defaultPath=${user.home}/Hexworx/TestKit/TestKitProjects;

defaultTestName=demo;

and Entry=T

 

The syntax should be the same as that for other addresses.  That is, the beginning of the parameter is indicated by a question mark, the “+” is used instead of space characters and special characters such as file separators are replaced accordingly.  For example, to execute the demo program from location

 

/My Programs/Hexworx/TestKit/TestKitProjects

 

the following link would be used:

 

http://localhost/Hexworx/TestKit/TestKitProjects/demo.jar?defaultPath=%5CMy+Programs%5CHexworx%5CTestKit%5CTestKitProjects &defaultTestName=demo&Entry=T

 

Note that when a test program is invoked directly as an executable program it is not necessary to specify the Java version.

 

 

Anchor Reference

The test programs may also be run by embedding the program name and parameters within an HTML anchor reference.  For example:

 

<a href=”/directory/demo.jar?defaultPath=${user.home}/ Hexworx/TestKit/TestKitProjects&defaultTestName=demo&Entry=T”>Run Demo</a>.

 

 

where:

Test executable name ==/directory/demo.jar

defaultPath=${user.home}/Hexworx/TestKit/TestKitProjects;

defaultTestName=demo;

and Entry=T

 

 

Java Server Pages

TestKit test programs may be included in Java Server Pages (JSP) as form actions or directly using the JSP plug-in command.  Running tests via this method assumes that your web server is running an appropriate Java Virtual Machine (JVM) and JSP server.  If the web server does not include a graphics environment then the JVM should be started with the “headless” parameter set to “true”.

 

Example 1 Form Version

<form action=”demo.jar?defaultPath=${user.home}/ Hexworx/TestKit/TestKitProjects&defaultTestName=demo&Entry=T” method=”post”>

</form>

 

where:

Test executable name ==demo.jar

defaultPath=${user.home}/Hexworx/TestKit/TestKitProjects;

defaultTestName=demo;

and Entry=T

 

 

This version runs the program as a CGI program (from the server) and hence the client Applet plug-in information is not required.  The example assumes that the demo.jar program is in the web page root directory.

 

 

Example 2 JSP Plug-in Version

The <jsp:plugin> command generates HTML for downloading the Java

Plug-in, if it is not installed, and executing an applet.  When the JSP is executed, the <jsp:plugin> action element is replaced by either an <OBJECT> or <EMBED>

HTML tag, depending on the browser (OBJECT for Internet Explorer or  EMBED for Netscape Navigator).

 

For example, the applet may be specified as follows in JSP:

 

<jsp:plugin type=applet code="TestKit.StartTester" codebase="file:/C:/My Programs/Hexworx/TestKit/TestKitProjects/" >

<jsp:params>

<jsp:param name="defaultPath" value="C:/My Programs/Hexworx/TestKit/TestKitProjects"/>

<jsp:param name="defaultTestName" value="demo"/>

<jsp:param name="Entry" value="T"/>

</jsp:params>

<jsp:fallback>

<p> Unable to start Plug-in. </p>

</jsp:fallback>

</jsp:plugin>

 

The <jsp:param> elements specify the parameters to the applet. The <jsp:fallback> element specifies the content for the browser if the Java Plug-in fails to start.

 

Example 3 JSP Plug-in Version

Test programs may also be run by running the TesterFrame program directly with the required parameters inside a JSP Program.  For example:

 

<%!

public TesterFrame getTester(String defaultPath, String defaultTestName, String Entry) {

 

     TesterFrame tf = new TesterFrame(defaultPath, defaultTestName, Entry) ;

     tf.show() ;

     return tf ;

 

}

%>

 

Use the Print Test – Test JSP option to create a template JSP for your test and modify the test parameters according to your requirements.

 


 

Entry Parameter Values

The Entry Parameter is used to specify the way in which the test will be executed and the parameter for running the test via HTML needs to be different from the parameter used if the test is to be run directly via the operating system due to HTML security restrictions which prevent exit to the operating system.  The relevant values for this parameter are as follows:

 

 

Value

Meaning

Description

 

 

 

A

Preview (HTML form)

Run the test without recording answers or decrementing the run count.  Previews are always untimed.  This version should be used when the test is run via a Net Browser.

T

Test (HTML form)

Run the test recording the answers and decrementing the run count.  This version should be used when the test is run via a Net Browser.

M

Mastery (HTML form)

Run the test in Preview mode and allow the user access to the Feedback button in order that they may immediately view whether their answer is correct or incorrect.  This version should be used when the test is run via a Net Browser. 

P

Preview

Run the test without recording answers or decrementing the run count.  Previews are always untimed.  Only used when the test should exit to the operating system, for example, when the test is run via an operating system shortcut or Desktop Icon.

K

Test

Run the test recording the answers and decrementing the run count.  Only used when the test should exit to the operating system, for example, when the test is run via an operating system shortcut or Desktop Icon.

F

Feedback

Run the test in Preview mode and allow the user access to the Feedback button in order that they may immediately view whether their answer is correct or incorrect.  Only used when the test should exit to the operating system, for example, when the test is run via an operating system shortcut or Desktop Icon.

 



[1] This message may also appear when a test has been created using a different Java JVM to that currently in use by the TestKit program.