Methods Summary |
---|
public void | setUp()
mDummyListener = new DummyListener();
mIface = Decorator.newInstance(new DummyImpl(), mDummyListener);
|
public void | testDecorator()
// TODO rewrite this using mocks
assertTrue(mIface.addValues(1, 2, 3) == 6);
assertTrue(mDummyListener.beforeCalled);
assertTrue(mDummyListener.afterCalled);
int resultValue = (Integer)mDummyListener.resultValue;
assertTrue(resultValue == 6);
assertTrue(mDummyListener.finallyCalled);
assertFalse(mDummyListener.catchCalled);
|
public void | testDecoratorExceptions()
boolean gotExceptions = false;
try {
mIface.raiseException();
} catch (Exception e) {
gotExceptions = true;
assertTrue(e.getMessage() == "Test exception");
}
assertTrue(gotExceptions);
assertTrue(mDummyListener.beforeCalled);
assertFalse(mDummyListener.afterCalled);
assertTrue(mDummyListener.catchCalled);
assertTrue(mDummyListener.finallyCalled);
|
public void | testDecoratorRaisesException()
boolean gotExceptions = false;
try {
mDummyListener.raiseException = true;
mIface.addValues(1, 2, 3);
Assert.fail("unreachable");
} catch (UnsupportedOperationException e) {
gotExceptions = true;
assertTrue(e.getMessage() == "Test exception");
}
assertTrue(gotExceptions);
assertTrue(mDummyListener.beforeCalled);
assertTrue(mDummyListener.afterCalled);
assertFalse(mDummyListener.catchCalled);
assertTrue(mDummyListener.finallyCalled);
|
public void | testDecoratorUnsupportedOperationException()
boolean gotExceptions = false;
try {
mIface.raiseUnsupportedOperationException();
} catch (UnsupportedOperationException e) {
gotExceptions = true;
assertTrue(e.getMessage() == "Test exception");
}
assertTrue(gotExceptions);
assertTrue(mDummyListener.beforeCalled);
assertFalse(mDummyListener.afterCalled);
assertTrue(mDummyListener.catchCalled);
assertTrue(mDummyListener.finallyCalled);
|