KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > util > CounterTest


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.util;
6
7 import junit.framework.TestCase;
8
9
10 /**
11  * User: plightbo
12  * Date: Jan 7, 2004
13  * Time: 7:55:35 PM
14  */

15 public class CounterTest extends TestCase {
16     //~ Instance fields ////////////////////////////////////////////////////////
17

18     Counter c = new Counter();
19
20     //~ Methods ////////////////////////////////////////////////////////////////
21

22     public void testCurrentAfterNext() {
23         long next = c.getNext();
24         long current = c.getCurrent();
25         assertEquals(next + 1, current);
26     }
27
28     public void testCurrentBeforeNext() {
29         long current = c.getCurrent();
30         long next = c.getNext();
31         assertEquals(current, next);
32     }
33
34     public void testWrap() {
35         c.setWrap(true);
36         c.setLast(1);
37
38         long a = c.getNext();
39         long b = c.getNext();
40         assertEquals(1, a);
41         assertEquals(1, b);
42     }
43 }
44
Popular Tags