1 /*
2 * Copyright (c) 1999, 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 */
27 import static javax.xml.datatype.DatatypeConstants.HOURS;
28 import static javax.xml.datatype.DatatypeConstants.MINUTES;
29 import static javax.xml.datatype.DatatypeConstants.MONTHS;
30 import static javax.xml.datatype.DatatypeConstants.SECONDS;
31 import static javax.xml.datatype.DatatypeConstants.YEARS;
32 import static org.testng.Assert.assertEquals;
33 import static org.testng.Assert.assertFalse;
34 import static org.testng.Assert.assertTrue;
35
36 import java.math.BigDecimal;
37 import java.math.BigInteger;
38 import java.util.Calendar;
39 import java.util.function.Function;
40
41 import javax.xml.datatype.DatatypeConfigurationException;
42 import javax.xml.datatype.DatatypeConstants;
43 import javax.xml.datatype.DatatypeFactory;
44 import javax.xml.datatype.Duration;
45 import javax.xml.namespace.QName;
46
47 import jaxp.library.JAXPBaseTest;
48
49 import org.testng.Assert;
50 import org.testng.annotations.BeforeClass;
51 import org.testng.annotations.DataProvider;
52 import org.testng.annotations.Test;
53
54 /*
55 * @summary Class containing the test cases for Duration.
56 */
57 public class DurationTest extends JAXPBaseTest {
58
59 private DatatypeFactory datatypeFactory;
60
61 /*
62 * Setup.
63 */
64 @BeforeClass
65 public void setup() throws DatatypeConfigurationException {
66 datatypeFactory = DatatypeFactory.newInstance();
67 }
68
69 @DataProvider(name = "legal-number-duration")
70 public Object[][] getLegalNumberDuration() {
71 return new Object[][] {
72 // is positive, year, month, day, hour, minute, second
73 { true, 1, 1, 1, 1, 1, 1 },
74 { false, 1, 1, 1, 1, 1, 1 },
75 { true, 1, 0, 0, 0, 0, 0 },
76 { false, 1, 0, 0, 0, 0, 0 }
77 };
|
1 /*
2 * Copyright (c) 1999, 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 */
27 import static javax.xml.datatype.DatatypeConstants.HOURS;
28 import static javax.xml.datatype.DatatypeConstants.MINUTES;
29 import static javax.xml.datatype.DatatypeConstants.MONTHS;
30 import static javax.xml.datatype.DatatypeConstants.SECONDS;
31 import static javax.xml.datatype.DatatypeConstants.YEARS;
32 import static org.testng.Assert.assertEquals;
33 import static org.testng.Assert.assertFalse;
34 import static org.testng.Assert.assertTrue;
35
36 import java.math.BigDecimal;
37 import java.math.BigInteger;
38 import java.util.Calendar;
39 import java.util.function.Function;
40
41 import javax.xml.datatype.DatatypeConfigurationException;
42 import javax.xml.datatype.DatatypeConstants;
43 import javax.xml.datatype.DatatypeFactory;
44 import javax.xml.datatype.Duration;
45 import javax.xml.namespace.QName;
46
47 import org.testng.Assert;
48 import org.testng.annotations.BeforeClass;
49 import org.testng.annotations.DataProvider;
50 import org.testng.annotations.Listeners;
51 import org.testng.annotations.Test;
52
53 /*
54 * @summary Class containing the test cases for Duration.
55 */
56 @Listeners({jaxp.library.BasePolicy.class})
57 public class DurationTest {
58
59 private DatatypeFactory datatypeFactory;
60
61 /*
62 * Setup.
63 */
64 @BeforeClass
65 public void setup() throws DatatypeConfigurationException {
66 datatypeFactory = DatatypeFactory.newInstance();
67 }
68
69 @DataProvider(name = "legal-number-duration")
70 public Object[][] getLegalNumberDuration() {
71 return new Object[][] {
72 // is positive, year, month, day, hour, minute, second
73 { true, 1, 1, 1, 1, 1, 1 },
74 { false, 1, 1, 1, 1, 1, 1 },
75 { true, 1, 0, 0, 0, 0, 0 },
76 { false, 1, 0, 0, 0, 0, 0 }
77 };
|