ProxyTrustIterator pti = null;
Object obj = new Object();
RemoteException re = new RemoteException();
try {
pti = new SingletonProxyTrustIterator(null);
// FAIL
throw new TestException(
"Constructor invocation of SingletonProxyTrustIterator "
+ "with null parameter did not throw any exception "
+ "while NullPointerException was expected.");
} catch (NullPointerException npe) {
// PASS
logger.fine("Constructor invocation of "
+ "SingletonProxyTrustIterator with null parameter "
+ "threw NullPointerException as expected.");
}
pti = new SingletonProxyTrustIterator(obj);
logger.fine("Constructed SingletonProxyTrustIterator(" + obj + ").");
try {
pti.setException(re);
// FAIL
throw new TestException(
"'setExcepion' method invocation of constructed "
+ "SingletonProxyTrustIterator just after it's "
+ "construction did not throw any exception "
+ "while IllegalStateException was expected.");
} catch (IllegalStateException ise) {
// PASS
logger.fine("'setExcepion' method invocation of constructed "
+ "SingletonProxyTrustIterator just after it's "
+ "construction threw IllegalStateException "
+ "as expected.");
}
if (!pti.hasNext()) {
// FAIL
throw new TestException(
"First 'hasNext' method invocation of constructed "
+ "SingletonProxyTrustIterator just after it's "
+ "construction returned false while true was "
+ "expected");
}
// PASS
logger.fine("First 'hasNext' method invocation of constructed "
+ "SingletonProxyTrustIterator just after it's "
+ "construction returned true as expected");
try {
pti.setException(re);
// FAIL
throw new TestException(
"'setExcepion' method invocation of constructed "
+ "SingletonProxyTrustIterator after it's 'hasNext' "
+ "method invocation did not throw any exception "
+ "while IllegalStateException was expected.");
} catch (IllegalStateException ise) {
// PASS
logger.fine("'setExcepion' method invocation of constructed "
+ "SingletonProxyTrustIterator after it's 'hasNext' "
+ "method invocation threw IllegalStateException "
+ "as expected.");
}
Object res = pti.next();
if (res != obj) {
// FAIL
throw new TestException(
"First 'next' method invocation of constructed "
+ "SingletonProxyTrustIterator returned " + res
+ " while " + obj + " was expected.");
}
// PASS
logger.fine("First 'next' method invocation of constructed "
+ "SingletonProxyTrustIterator returned " + obj
+ " as expected.");
pti.setException(re);
// PASS
logger.fine("'setExcepion' method invocation of constructed "
+ "SingletonProxyTrustIterator after it's 'next' "
+ "method invocation did not throw any exception "
+ "as expected.");
try {
pti.setException(re);
// FAIL
throw new TestException(
"2-nd 'setExcepion' method invocation of constructed "
+ "SingletonProxyTrustIterator after it's 'next' "
+ "method invocation did not throw any exception "
+ "while IllegalStateException was expected.");
} catch (IllegalStateException ise) {
// PASS
logger.fine("2-nd 'setExcepion' method invocation of "
+ "constructed SingletonProxyTrustIterator after it's "
+ "'next' method invocation threw "
+ "IllegalStateException as expected.");
}
if (pti.hasNext()) {
// FAIL
throw new TestException(
"2-nd 'hasNext' method invocation of constructed "
+ "SingletonProxyTrustIterator returned true while "
+ "false was expected");
}
// PASS
logger.fine("2-nd 'hasNext' method invocation of constructed "
+ "SingletonProxyTrustIterator returned false as expected");
try {
res = pti.next();
// FAIL
throw new TestException(
"2-nd 'next' method invocation of constructed "
+ "SingletonProxyTrustIterator did not throw any "
+ "exception while NoSuchElementException was "
+ "expected.");
} catch (NoSuchElementException nsee) {
// PASS
logger.fine("2-nd 'next' method invocation of constructed "
+ "SingletonProxyTrustIterator threw "
+ "NoSuchElementException as expected.");
}
pti = new SingletonProxyTrustIterator(obj);
logger.fine("Constructed SingletonProxyTrustIterator(" + obj
+ ") again.");
pti.next();
pti.hasNext();