samples/stateful/test/org/apidesign/stateful/api/ProgressTest.java
changeset 409 40cabcdcd2be
parent 350 b8edf9de56c5
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/samples/stateful/test/org/apidesign/stateful/api/ProgressTest.java	Thu Oct 30 21:30:10 2014 +0100
     1.3 @@ -0,0 +1,34 @@
     1.4 +package org.apidesign.stateful.api;
     1.5 +
     1.6 +import junit.framework.TestCase;
     1.7 +import org.apidesign.stateful.api.ProgressStateless.InProgress;
     1.8 +
     1.9 +public class ProgressTest extends TestCase {
    1.10 +    
    1.11 +    public ProgressTest(String testName) {
    1.12 +        super(testName);
    1.13 +    }
    1.14 +
    1.15 +    public void testProgressStatefulWithoutStart() {
    1.16 +        try {
    1.17 +            // BEGIN: progress.wrong.order
    1.18 +            ProgressStateful p = ProgressStateful.create("WrongOrder");
    1.19 +            p.progress(10);
    1.20 +            p.finish();
    1.21 +            // END: progress.wrong.order
    1.22 +            
    1.23 +            fail("Calling progress without start yields an exception!?");
    1.24 +        } catch (IllegalStateException ex) {
    1.25 +            // OK
    1.26 +        }
    1.27 +    }
    1.28 +
    1.29 +    public void testProgressStatelessNeedsStart() {
    1.30 +        ProgressStateless p = ProgressStateless.create("GoodOrder");
    1.31 +        InProgress progress = p.start(10);
    1.32 +        // without calling start(), there is no way to call progress() method
    1.33 +        progress.progress(10);
    1.34 +        progress.finish();
    1.35 +    }
    1.36 +
    1.37 +}