diff -r b8edf9de56c5 -r efecc4bc0321 samples/stateful/test/org/apidesign/stateful/api/ProgressTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/samples/stateful/test/org/apidesign/stateful/api/ProgressTest.java Sun May 02 14:56:33 2010 +0200 @@ -0,0 +1,34 @@ +package org.apidesign.stateful.api; + +import junit.framework.TestCase; +import org.apidesign.stateful.api.ProgressStateless.InProgress; + +public class ProgressTest extends TestCase { + + public ProgressTest(String testName) { + super(testName); + } + + public void testProgressStatefulWithoutStart() { + try { + // BEGIN: progress.wrong.order + ProgressStateful p = ProgressStateful.create("WrongOrder"); + p.progress(10); + p.finish(); + // END: progress.wrong.order + + fail("Calling progress without start yields an exception!?"); + } catch (IllegalStateException ex) { + // OK + } + } + + public void testProgressStatelessNeedsStart() { + ProgressStateless p = ProgressStateless.create("GoodOrder"); + InProgress progress = p.start(10); + // without calling start(), there is no way to call progress() method + progress.progress(10); + progress.finish(); + } + +}