KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > types > TestDuration


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package test.types;
17
18 import junit.framework.TestCase;
19 import org.apache.axis.types.Duration;
20
21 public class TestDuration extends TestCase
22   {
23
24   public TestDuration( String JavaDoc name )
25     {
26     super( name );
27     }
28
29     
30   public void testDurations()
31     throws Exception JavaDoc
32     {
33     // invoke the web service as if it was a local java object
34
String JavaDoc[] durationStrings = new String JavaDoc[ 11 ];
35     durationStrings[ 0 ] = "P2Y3M8DT8H1M3.3S";
36     durationStrings[ 1 ] = "P2Y3M8DT8H1M3S";
37     durationStrings[ 2 ] = "PT8H1M3.3S";
38     durationStrings[ 3 ] = "P2Y3M8D";
39     durationStrings[ 4 ] = "P2YT8H";
40     durationStrings[ 5 ] = "P8DT3.3S";
41     durationStrings[ 6 ] = "P3MT1M";
42     durationStrings[ 7 ] = "PT0.3S";
43     durationStrings[ 8 ] = "P1M";
44     durationStrings[ 9 ] = "-P1M";
45     durationStrings[ 10 ] = "-P2Y3M8DT8H1M3.3S";
46
47     for( int i = 0; i < durationStrings.length; i++ )
48       {
49       String JavaDoc durationString = durationStrings[ i ];
50       Duration duration =
51               new Duration( durationString );
52
53       assertTrue( "Duration string \"" + durationString +
54                   "\" not equal to returned: " + duration.toString(),
55                   durationString.equals( duration.toString() ) );
56       }
57     }
58   }
59
Popular Tags