01: /*
02: * Copyright (C) 2007 XStream Committers.
03: * All rights reserved.
04: *
05: * The software in this package is published under the terms of the BSD
06: * style license a copy of which has been included with this distribution in
07: * the LICENSE.txt file.
08: *
09: * Created on 21. September 2007 by Joerg Schaible
10: */
11: package com.thoughtworks.xstream.converters.extended;
12:
13: import com.thoughtworks.xstream.converters.SingleValueConverter;
14:
15: import junit.framework.TestCase;
16:
17: import javax.xml.datatype.DatatypeFactory;
18: import javax.xml.datatype.Duration;
19:
20: /**
21: * @author John Kristian
22: */
23: public class DurationConverterTest extends TestCase {
24: private static final String[] STRINGS = { "-P1Y2M3DT4H5M6.7S",
25: "P1Y", "PT1H2M" };
26:
27: public void testConversion() throws Exception {
28: final SingleValueConverter converter = new DurationConverter();
29: DatatypeFactory factory = DatatypeFactory.newInstance();
30: for (int i = 0; i < STRINGS.length; i++) {
31: final String s = STRINGS[i];
32: Duration o = factory.newDuration(s);
33: assertEquals(s, converter.toString(o));
34: assertEquals(o, converter.fromString(s));
35: }
36: }
37:
38: }
|