AutoTesterMulti.javaAPI DocphoneME MR2 API (J2ME)11947Wed May 02 18:00:04 BST 2007com.sun.midp.installer


public class AutoTesterMulti extends AutoTesterBase implements AutoTesterInterface
Fetches a list of URLs pointing to test suites to install, then, for each specified test suite in parallel, installs/updates the suite, runs the first MIDlet in the suite in a loop specified number of iterations or until the new version of the suite is not found, then removes the suite.

The MIDlet uses these application properties as arguments:

  1. arg-0: URL for html page with links to test suites. This html page looks like this: Suite1 Suite2
  2. arg-1: Used to override the default domain used when installing an unsigned suite. The default is maximum to allow the runtime API tests be performed automatically without tester interaction. The domain name may be followed by a colon and a list of permissions that must be allowed even if they are not listed in the MIDlet-Permissions attribute in the application descriptor file. Instead of the list a keyword "all" can be specified indicating that all permissions must be allowed, for example: operator:all.
  3. arg-2: Integer number, specifying how many iterations to run the suite. If argument is not given or less then zero, then suite will be run until the new version of the suite is not found.

If arg-0 is not given then a form will be used to query the tester for the arguments.

Fields Summary
Info about suites to install
Constructors Summary
public AutoTesterMulti()
Create and initialize a new auto tester MIDlet.


        if (url != null) {
        } else if (restoreSession()) {
            // continuation of a previous session
        } else {
             * No URL has been provided, ask the user.
             * commandAction will subsequently call startBackgroundTester.
Methods Summary
private voidfetchInstallList(java.lang.String url)
Go to given URL, fetch and parse html page with links to tests suites. If there was error while fetching or parsing, display an alert.

url URL for html page with links to suites

        StreamConnection conn = null;
        InputStreamReader in = null;
        String errorMessage;

        try {
            conn = (StreamConnection), Connector.READ);
            in = new InputStreamReader(conn.openInputStream());
            try {
                installList = SuiteDownloadInfo.getDownloadInfoFromPage(in);
                if (installList.size() > 0) {
                errorMessage = Resource.getString(
            } catch (IllegalArgumentException ex) {
                errorMessage = Resource.getString(
            } catch (Exception ex) {
                errorMessage = ex.getMessage();
        } catch (Exception ex) {
            errorMessage = Resource.getString(
        } finally {
            try {
            } catch (Exception e) {
                if (Logging.REPORT_LEVEL <= Logging.WARNING) {
          , LogChannels.LC_AMS,
                            "close threw an Exception");

        Alert a = new Alert(Resource.getString(ResourceConstants.ERROR),
                errorMessage, null, AlertType.ERROR);
public voidinstallAndPerformTests(MIDletSuiteStorage inp_storage, Installer inp_installer, java.lang.String inp_url)
Get list of test suites, for each suite start a thread that performs testing, wait until all threads have finished.

inp_storage MIDletSuiteStorage object
inp_installer Installer object
inp_url URL for the html page with links to suites

        int totalSuites = installList.size();
        if (totalSuites > 0) {
            Thread[] threads = new Thread[totalSuites];

            // create threads
            for (int i = 0; i < totalSuites; i++) {
                SuiteDownloadInfo suite =
                threads[i] = new Thread(new AutoTesterRunner(
                    suite.url, inp_storage, inp_installer));

            // start threads
            for (int i = 0; i < totalSuites; i++) {

            // wait for threads to finish
            for (int i = 0; i < totalSuites; i++) {
                try {
                } catch (Exception ex) {
                    // just ignore

public booleanrestoreSession()
Restore the data from the last session, since this version of the autotester does not have sessions it just returns false.

true if there was data saved from the last session

        return false;
public voidrun()
Run the installer.

        installAndPerformTests(midletSuiteStorage, installer, url);