001: /*
002: *
003: *
004: * Copyright 1990-2007 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: */
026:
027: package com.sun.midp.installer;
028:
029: import java.io.*;
030:
031: import javax.microedition.rms.*;
032:
033: import com.sun.midp.i18n.Resource;
034:
035: import com.sun.midp.i18n.ResourceConstants;
036:
037: import com.sun.midp.main.MIDletSuiteLoader;
038:
039: import com.sun.midp.midlet.MIDletStateHandler;
040:
041: import com.sun.midp.midletsuite.MIDletInfo;
042: import com.sun.midp.midletsuite.MIDletSuiteStorage;
043:
044: import com.sun.midp.log.Logging;
045: import com.sun.midp.log.LogChannels;
046:
047: /**
048: * Installs/Updates a test suite for CHAPI, runs the first MIDlet
049: * in the suite in a loop
050: * specified number of iterations or until the new version of the suite is not
051: * found, then removes the suite.
052: * <p> The modifications for CHAPI enable the security checks during
053: * the installation by enabling the listener.
054: * The security prompts are handled by the installer.
055: * The listener responds without prompting to requests to install the jar and
056: * and to delete the RMS storage of the application (if ask).
057: * <p>
058: * The MIDlet uses these application properties as arguments: </p>
059: * <ol>
060: * <li>arg-0: URL for the test suite
061: * <li>arg-1: Used to override the default domain used when installing
062: * an unsigned suite. The default is maximum to allow the runtime API tests
063: * be performed automatically without tester interaction.
064: * <li>arg-2: Integer number, specifying how many iterations to run
065: * the suite. If argument is not given or less then zero, then suite
066: * will be run until the new version of the suite is not found.
067: * </ol>
068: * <p>
069: * If arg-0 is not given then a form will be used to query the tester for
070: * the arguments.</p>
071: */
072: public class CHAutoTester extends AutoTester implements InstallListener {
073:
074: /**
075: * Installs and performs the tests.
076: *
077: * @param midletSuiteStorage MIDletSuiteStorage object
078: * @param inp_installer Installer object
079: * @param inp_url URL of the test suite
080: */
081: public void installAndPerformTests(
082: MIDletSuiteStorage midletSuiteStorage,
083: Installer inp_installer, String inp_url) {
084:
085: installListener = this ;
086: super .installAndPerformTests(midletSuiteStorage, inp_installer,
087: url);
088: }
089:
090: /**
091: * Called with the current state of the install so the user can be
092: * asked to override the warning. To get the warning from the state
093: * call {@link InstallState#getLastException()}. If false is returned,
094: * the last exception in the state will be thrown and
095: * {@link Installer#wasStopped()} will return true if called.
096: *
097: * @param state current state of the install.
098: *
099: * @return true this installer does not stop.
100: */
101: public boolean warnUser(InstallState state) {
102: return true;
103: }
104:
105: /**
106: * Called with the current state of the install so the user can be
107: * asked to confirm the jar download.
108: * If false is returned, the an I/O exception thrown and
109: * {@link Installer#wasStopped()} will return true if called.
110: *
111: * @param state current state of the install.
112: *
113: * @return true; this installer always continues
114: */
115: public boolean confirmJarDownload(InstallState state) {
116: return true;
117: }
118:
119: /**
120: * Called with the current status of the install. See
121: * {@link Installer} for the status codes.
122: *
123: * @param status current status of the install.
124: * @param state current state of the install.
125: */
126: public void updateStatus(int status, InstallState state) {
127: // Ignore
128: }
129:
130: /**
131: * Called with the current state of the install so the user can be
132: * asked to confirm if the RMS data should be kept for new version of
133: * an updated suite.
134: *
135: * @param state current state of the install.
136: *
137: * @return false; never keep the RMS data if asked.
138: */
139: public boolean keepRMS(InstallState state) {
140: return false;
141: }
142:
143: /**
144: * Called with the current state of the install so the user can be
145: * asked to confirm the authentication path.
146: * If false is returned, the an I/O exception thrown and
147: * {@link Installer#wasStopped()} will return true if called.
148: *
149: * @param state current state of the install.
150: *
151: * @return true to continue the install
152: */
153: public boolean confirmAuthPath(InstallState state) {
154: return true;
155: }
156: }
|