samples/stateful/test/org/apidesign/stateful/api/ProgressTest.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 30 Oct 2014 21:30:10 +0100
changeset 409 40cabcdcd2be
parent 350 b8edf9de56c5
permissions -rw-r--r--
Updating to NBMs from NetBeans 8.0.1 as some of them are required to run on JDK8
     1 package org.apidesign.stateful.api;
     2 
     3 import junit.framework.TestCase;
     4 import org.apidesign.stateful.api.ProgressStateless.InProgress;
     5 
     6 public class ProgressTest extends TestCase {
     7     
     8     public ProgressTest(String testName) {
     9         super(testName);
    10     }
    11 
    12     public void testProgressStatefulWithoutStart() {
    13         try {
    14             // BEGIN: progress.wrong.order
    15             ProgressStateful p = ProgressStateful.create("WrongOrder");
    16             p.progress(10);
    17             p.finish();
    18             // END: progress.wrong.order
    19             
    20             fail("Calling progress without start yields an exception!?");
    21         } catch (IllegalStateException ex) {
    22             // OK
    23         }
    24     }
    25 
    26     public void testProgressStatelessNeedsStart() {
    27         ProgressStateless p = ProgressStateless.create("GoodOrder");
    28         InProgress progress = p.start(10);
    29         // without calling start(), there is no way to call progress() method
    30         progress.progress(10);
    31         progress.finish();
    32     }
    33 
    34 }