author | Jaroslav Tulach <jtulach@netbeans.org> |
Sun, 02 May 2010 14:56:33 +0200 | |
changeset 351 | efecc4bc0321 |
parent 350 | samples/stateful/test/org/apidesign/stateful/api/ProgressStatefulTest.java@b8edf9de56c5 |
permissions | -rw-r--r-- |
jtulach@348 | 1 |
package org.apidesign.stateful.api; |
jtulach@348 | 2 |
|
jtulach@348 | 3 |
import junit.framework.TestCase; |
jtulach@351 | 4 |
import org.apidesign.stateful.api.ProgressStateless.InProgress; |
jtulach@348 | 5 |
|
jtulach@351 | 6 |
public class ProgressTest extends TestCase { |
jtulach@348 | 7 |
|
jtulach@351 | 8 |
public ProgressTest(String testName) { |
jtulach@348 | 9 |
super(testName); |
jtulach@348 | 10 |
} |
jtulach@348 | 11 |
|
jtulach@351 | 12 |
public void testProgressStatefulWithoutStart() { |
jtulach@348 | 13 |
try { |
jtulach@348 | 14 |
// BEGIN: progress.wrong.order |
jtulach@350 | 15 |
ProgressStateful p = ProgressStateful.create("WrongOrder"); |
jtulach@348 | 16 |
p.progress(10); |
jtulach@348 | 17 |
p.finish(); |
jtulach@348 | 18 |
// END: progress.wrong.order |
jtulach@348 | 19 |
|
jtulach@348 | 20 |
fail("Calling progress without start yields an exception!?"); |
jtulach@348 | 21 |
} catch (IllegalStateException ex) { |
jtulach@348 | 22 |
// OK |
jtulach@348 | 23 |
} |
jtulach@348 | 24 |
} |
jtulach@348 | 25 |
|
jtulach@351 | 26 |
public void testProgressStatelessNeedsStart() { |
jtulach@351 | 27 |
ProgressStateless p = ProgressStateless.create("GoodOrder"); |
jtulach@351 | 28 |
InProgress progress = p.start(10); |
jtulach@351 | 29 |
// without calling start(), there is no way to call progress() method |
jtulach@351 | 30 |
progress.progress(10); |
jtulach@351 | 31 |
progress.finish(); |
jtulach@351 | 32 |
} |
jtulach@351 | 33 |
|
jtulach@348 | 34 |
} |