KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jbpm > bpel > xml > util > DurationTest


1 package org.jbpm.bpel.xml.util;
2
3 import org.jbpm.bpel.xml.util.Duration;
4
5 import junit.framework.TestCase;
6
7 /**
8  * @author Alejandro Guízar
9  * @version $Revision: 1.1 $ $Date: 2005/06/23 02:17:27 $
10  */

11 public class DurationTest extends TestCase {
12   
13   private Duration fullDuration = new Duration(8, 12, 20, 15, 45, 30, 50);
14   private Duration dateDuration = new Duration(12, 75, 60, 0, 0, 0, 0);
15   private Duration timeDuration = new Duration(0, 0, 0, 28, 35, 140, 700);
16
17   public DurationTest(String JavaDoc name) {
18     super(name);
19   }
20
21   public void testParseFull() {
22     String JavaDoc literal = "P8Y12M20DT15H45M30.05S";
23     assertEquals(fullDuration, Duration.parseDuration(literal));
24   }
25   
26   public void testParseDate() {
27     String JavaDoc literal = "P12Y75M60D";
28     assertEquals(dateDuration, Duration.parseDuration(literal));
29   }
30   
31   public void testParseTime() {
32     String JavaDoc literal = "PT28H35M140.7S";
33     assertEquals(timeDuration, Duration.parseDuration(literal));
34   }
35   
36   public void testFormatFull() {
37     assertEquals("P8Y12M20DT15H45M30.05S", fullDuration.toString());
38   }
39   
40   public void testFormatDate() {
41     assertEquals("P12Y75M60D", dateDuration.toString());
42   }
43   
44   public void testFormatTime() {
45     assertEquals("PT28H35M140.7S", timeDuration.toString());
46   }
47 }
48
Popular Tags