1 /*
2 * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package datatype;
25
26 import java.math.BigDecimal;
27 import java.math.BigInteger;
28 import java.util.Calendar;
29 import java.util.Date;
30 import java.util.GregorianCalendar;
31 import java.util.TimeZone;
32
33 import javax.xml.datatype.DatatypeConfigurationException;
34 import javax.xml.datatype.DatatypeConstants;
35 import javax.xml.datatype.DatatypeFactory;
36 import javax.xml.datatype.Duration;
37 import javax.xml.namespace.QName;
38
39 import org.testng.Assert;
40 import org.testng.AssertJUnit;
41 import org.testng.annotations.BeforeMethod;
42 import org.testng.annotations.Test;
43
44 /*
45 * @summary Test Duration.
46 */
47 public class DurationTest {
48
49 private final static boolean DEBUG = true;
50
51 protected Duration duration = null;
52
53 @BeforeMethod
54 protected void setUp() {
55 try {
56 duration = DatatypeFactory.newInstance().newDuration(100);
57 } catch (DatatypeConfigurationException dce) {
58 dce.printStackTrace();
59 Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage());
60 }
61 }
62
63 @Test
64 public void testDurationSubtract() {
65 try {
66 Duration bigDur = DatatypeFactory.newInstance().newDuration(20000);
|
1 /*
2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package datatype;
25
26 import java.math.BigDecimal;
27 import java.math.BigInteger;
28 import java.util.Calendar;
29 import java.util.Date;
30 import java.util.GregorianCalendar;
31 import java.util.TimeZone;
32
33 import javax.xml.datatype.DatatypeConfigurationException;
34 import javax.xml.datatype.DatatypeConstants;
35 import javax.xml.datatype.DatatypeFactory;
36 import javax.xml.datatype.Duration;
37 import javax.xml.namespace.QName;
38
39 import org.testng.Assert;
40 import org.testng.AssertJUnit;
41 import org.testng.annotations.BeforeMethod;
42 import org.testng.annotations.Listeners;
43 import org.testng.annotations.Test;
44
45 /*
46 * @summary Test Duration.
47 */
48 @Listeners({jaxp.library.BasePolicy.class})
49 public class DurationTest {
50
51 private final static boolean DEBUG = true;
52
53 protected Duration duration = null;
54
55 @BeforeMethod
56 protected void setUp() {
57 try {
58 duration = DatatypeFactory.newInstance().newDuration(100);
59 } catch (DatatypeConfigurationException dce) {
60 dce.printStackTrace();
61 Assert.fail("Failed to create instance of DatatypeFactory " + dce.getMessage());
62 }
63 }
64
65 @Test
66 public void testDurationSubtract() {
67 try {
68 Duration bigDur = DatatypeFactory.newInstance().newDuration(20000);
|