TestAutoSuiteStoragepublic class TestAutoSuiteStorage extends TestCase i3test for AutoSuiteStorage |
Fields Summary |
---|
private static final String | NONEXISTENT_SUITE_URLURL of unexistent suite | private static final String | SUITE_URLURL of suite to install |
Methods Summary |
---|
public void | runTests()Run tests
testStorage();
testFailures();
| void | testFailures()Test failures
boolean exceptionThrown;
declare("Obtain AutoSuiteStorage instance");
AutoSuiteStorage storage = AutoSuiteStorage.getStorage();
assertNotNull("Failed to obtain AutoSuiteStorage instance", storage);
declare("Install nonexistent suite");
exceptionThrown = false;
try {
AutoSuiteDescriptor suite = null;
suite = storage.installSuite(NONEXISTENT_SUITE_URL);
} catch (Exception e) {
exceptionThrown = true;
}
assertTrue("Installed nonexistent suite", exceptionThrown);
declare("Install suite");
AutoSuiteDescriptor suite = null;
try {
suite = storage.installSuite(SUITE_URL);
} catch (Exception e) {
}
assertNotNull("Failed to install suite", suite);
declare("Uninstall suite");
exceptionThrown = false;
try {
storage.uninstallSuite(suite);
} catch (Exception e) {
exceptionThrown = true;
}
assertFalse("Failed to uninstall suite", exceptionThrown);
declare("Uninstall not installed suite");
exceptionThrown = false;
try {
storage.uninstallSuite(suite);
} catch (Exception e) {
exceptionThrown = true;
}
assertTrue("Uninstalled not installed suite", exceptionThrown);
| void | testStorage()Tests operations with storage
declare("Obtain AutoSuiteStorage instance");
AutoSuiteStorage storage = AutoSuiteStorage.getStorage();
assertNotNull("Failed to obtain AutoSuiteStorage instance", storage);
Vector suites = storage.getInstalledSuites();
assertNotNull("Failed to obtain list of installed suites", suites);
int totalSuitesBefore = suites.size();
declare("Install suite");
AutoSuiteDescriptor suite = null;
try {
suite = storage.installSuite(SUITE_URL);
} catch (Exception e) {
}
assertNotNull("Failed to install suite", suite);
suites = storage.getInstalledSuites();
int totalSuitesAfter = suites.size();
assertTrue("Invalid number of installed suites",
totalSuitesAfter == totalSuitesBefore + 1);
System.out.println("Suite name: " + suite.getSuiteName());
Vector midlets = suite.getSuiteMIDlets();
for (int i = 0; i < midlets.size(); ++i) {
AutoMIDletDescriptor midlet;
midlet = (AutoMIDletDescriptor)midlets.elementAt(i);
System.out.println("MIDlet #" + i);
System.out.println(" name : " + midlet.getMIDletName());
System.out.println(" class: " + midlet.getMIDletClassName());
System.out.println("");
}
declare("Uninstall suite");
boolean exceptionThrown = false;
try {
storage.uninstallSuite(suite);
} catch (Exception e) {
exceptionThrown = true;
}
assertFalse("Failed to uninstall suite", exceptionThrown);
suites = storage.getInstalledSuites();
totalSuitesAfter = suites.size();
assertTrue("Invalid number of installed suites",
totalSuitesAfter == totalSuitesBefore);
|
|