author | joehw |
Fri, 30 Jan 2015 17:07:53 -0800 | |
changeset 28792 | ce053a3f1d92 |
child 40223 | 64662417aa2d |
permissions | -rw-r--r-- |
28792
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
1 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
2 |
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
4 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
8 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
13 |
* accompanied this code). |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
14 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
18 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
21 |
* questions. |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
22 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
23 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
24 |
package javax.xml.datatype.ptests; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
25 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
26 |
import static java.util.Calendar.HOUR; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
27 |
import static java.util.Calendar.MINUTE; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
28 |
import static java.util.Calendar.YEAR; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
29 |
import static org.testng.Assert.assertEquals; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
30 |
import static org.testng.Assert.assertTrue; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
31 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
32 |
import java.util.GregorianCalendar; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
33 |
import java.util.Locale; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
34 |
import java.util.TimeZone; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
35 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
36 |
import javax.xml.datatype.DatatypeConfigurationException; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
37 |
import javax.xml.datatype.DatatypeConstants; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
38 |
import javax.xml.datatype.DatatypeFactory; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
39 |
import javax.xml.datatype.Duration; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
40 |
import javax.xml.datatype.XMLGregorianCalendar; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
41 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
42 |
import jaxp.library.JAXPBaseTest; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
43 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
44 |
import org.testng.Assert; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
45 |
import org.testng.annotations.BeforeClass; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
46 |
import org.testng.annotations.DataProvider; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
47 |
import org.testng.annotations.Test; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
48 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
49 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
50 |
* @bug 5049592 5041845 5048932 5064587 5040542 5049531 5049528 |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
51 |
* @summary Class containing the test cases for XMLGregorianCalendar |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
52 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
53 |
public class XMLGregorianCalendarTest extends JAXPBaseTest { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
54 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
55 |
private DatatypeFactory datatypeFactory; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
56 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
57 |
@BeforeClass |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
58 |
public void setup() throws DatatypeConfigurationException { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
59 |
datatypeFactory = DatatypeFactory.newInstance(); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
60 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
61 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
62 |
@DataProvider(name = "valid-milliseconds") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
63 |
public Object[][] getValidMilliSeconds() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
64 |
return new Object[][] { { 0 }, { 1 }, { 2 }, { 16 }, { 1000 } }; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
65 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
66 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
67 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
68 |
* Test DatatypeFactory.newXMLGregorianCalendar(..) with milliseconds > 1. |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
69 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
70 |
* Bug # 5049592 |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
71 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
72 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
73 |
@Test(dataProvider = "valid-milliseconds") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
74 |
public void checkNewCalendar(int ms) { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
75 |
// valid milliseconds |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
76 |
XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(2004, // year |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
77 |
6, // month |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
78 |
2, // day |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
79 |
19, // hour |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
80 |
20, // minute |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
81 |
59, // second |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
82 |
ms, // milliseconds |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
83 |
840 // timezone |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
84 |
); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
85 |
// expected success |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
86 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
87 |
assertEquals(calendar.getMillisecond(), ms); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
88 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
89 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
90 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
91 |
* Test DatatypeFactory.newXMLGregorianCalendarTime(..). |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
92 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
93 |
* Bug # 5049592 |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
94 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
95 |
@Test(dataProvider = "valid-milliseconds") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
96 |
public void checkNewTime(int ms) { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
97 |
// valid milliseconds |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
98 |
XMLGregorianCalendar calendar2 = datatypeFactory.newXMLGregorianCalendarTime(19, // hour |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
99 |
20, // minute |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
100 |
59, // second |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
101 |
ms, // milliseconds |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
102 |
840 // timezone |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
103 |
); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
104 |
// expected success |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
105 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
106 |
assertEquals(calendar2.getMillisecond(), ms); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
107 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
108 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
109 |
@DataProvider(name = "invalid-milliseconds") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
110 |
public Object[][] getInvalidMilliSeconds() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
111 |
return new Object[][] { { -1 }, { 1001 } }; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
112 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
113 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
114 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
115 |
* Test DatatypeFactory.newXMLGregorianCalendar(..). |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
116 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
117 |
* Bug # 5049592 IllegalArgumentException is thrown if milliseconds < 0 or > |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
118 |
* 1001. |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
119 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
120 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
121 |
@Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "invalid-milliseconds") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
122 |
public void checkNewCalendarNeg(int milliseconds) { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
123 |
// invalid milliseconds |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
124 |
datatypeFactory.newXMLGregorianCalendar(2004, // year |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
125 |
6, // month |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
126 |
2, // day |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
127 |
19, // hour |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
128 |
20, // minute |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
129 |
59, // second |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
130 |
milliseconds, // milliseconds |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
131 |
840 // timezone |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
132 |
); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
133 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
134 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
135 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
136 |
* Test DatatypeFactory.newXMLGregorianCalendarTime(..). |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
137 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
138 |
* Bug # 5049592 IllegalArgumentException is thrown if milliseconds < 0 or > |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
139 |
* 1001. |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
140 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
141 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
142 |
@Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "invalid-milliseconds") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
143 |
public void checkNewTimeNeg(int milliseconds) { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
144 |
// invalid milliseconds |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
145 |
datatypeFactory.newXMLGregorianCalendarTime(19, // hour |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
146 |
20, // minute |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
147 |
59, // second |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
148 |
milliseconds, // milliseconds |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
149 |
840 // timezone |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
150 |
); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
151 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
152 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
153 |
@DataProvider(name = "data-for-add") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
154 |
public Object[][] getDataForAdd() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
155 |
return new Object[][] { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
156 |
//calendar1, calendar2, duration |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
157 |
{ "1999-12-31T00:00:00Z", "2000-01-01T00:00:00Z", "P1D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
158 |
{ "2000-12-31T00:00:00Z", "2001-01-01T00:00:00Z", "P1D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
159 |
{ "1998-12-31T00:00:00Z", "1999-01-01T00:00:00Z", "P1D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
160 |
{ "2001-12-31T00:00:00Z", "2002-01-01T00:00:00Z", "P1D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
161 |
{ "2003-04-11T00:00:00Z", "2003-04-12T00:00:00Z", "P1D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
162 |
{ "2003-04-11T00:00:00Z", "2003-04-14T00:00:00Z", "P3D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
163 |
{ "2003-04-30T00:00:00Z", "2003-05-01T00:00:00Z", "P1D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
164 |
{ "2003-02-28T00:00:00Z", "2003-03-01T00:00:00Z", "P1D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
165 |
{ "2000-02-29T00:00:00Z", "2000-03-01T00:00:00Z", "P1D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
166 |
{ "2000-02-28T00:00:00Z", "2000-02-29T00:00:00Z", "P1D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
167 |
{ "1998-01-11T00:00:00Z", "1998-04-11T00:00:00Z", "P90D" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
168 |
{ "1999-05-11T00:00:00Z", "2002-05-11T00:00:00Z", "P1096D" }}; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
169 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
170 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
171 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
172 |
* Test XMLGregorianCalendar.add(Duration). |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
173 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
174 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
175 |
@Test(dataProvider = "data-for-add") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
176 |
public void checkAddDays(String cal1, String cal2, String dur) { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
177 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
178 |
XMLGregorianCalendar calendar1 = datatypeFactory.newXMLGregorianCalendar(cal1); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
179 |
XMLGregorianCalendar calendar2 = datatypeFactory.newXMLGregorianCalendar(cal2); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
180 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
181 |
Duration duration = datatypeFactory.newDuration(dur); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
182 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
183 |
XMLGregorianCalendar calendar1Clone = (XMLGregorianCalendar)calendar1.clone(); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
184 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
185 |
calendar1Clone.add(duration); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
186 |
assertEquals(calendar1Clone, calendar2); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
187 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
188 |
calendar2.add(duration.negate()); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
189 |
assertEquals(calendar2, calendar1); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
190 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
191 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
192 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
193 |
@DataProvider(name = "gMonth") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
194 |
public Object[][] getGMonth() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
195 |
return new Object[][] { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
196 |
{ "2000-02" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
197 |
{ "2000-03" }, |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
198 |
{ "2018-02" }}; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
199 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
200 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
201 |
* Test XMLGregorianCalendar#isValid(). for gMonth |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
202 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
203 |
* Bug # 5041845 |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
204 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
205 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
206 |
@Test(dataProvider = "gMonth") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
207 |
public void checkIsValid(String month) { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
208 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
209 |
XMLGregorianCalendar gMonth = datatypeFactory.newXMLGregorianCalendar(month); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
210 |
gMonth.setYear(null); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
211 |
Assert.assertTrue(gMonth.isValid(), gMonth.toString() + " should isValid"); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
212 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
213 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
214 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
215 |
@DataProvider(name = "lexical01") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
216 |
public Object[][] getLexicalRepresentForNormalize01() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
217 |
return new Object[][] { { "2000-01-16T12:00:00Z" }, { "2000-01-16T12:00:00" } }; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
218 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
219 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
220 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
221 |
* Test XMLGregorianCalendar#normalize(...). |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
222 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
223 |
* Bug # 5048932 XMLGregorianCalendar.normalize works |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
224 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
225 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
226 |
@Test(dataProvider = "lexical01") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
227 |
public void checkNormalize01(String lexical) { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
228 |
XMLGregorianCalendar lhs = datatypeFactory.newXMLGregorianCalendar(lexical); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
229 |
lhs.normalize(); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
230 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
231 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
232 |
@DataProvider(name = "lexical02") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
233 |
public Object[][] getLexicalRepresentForNormalize02() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
234 |
return new Object[][] { { "2000-01-16T00:00:00.01Z" }, { "2000-01-16T00:00:00.01" }, { "13:20:00" } }; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
235 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
236 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
237 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
238 |
* Test XMLGregorianCalendar#normalize(...). |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
239 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
240 |
* Bug # 5064587 XMLGregorianCalendar.normalize shall not change timezone |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
241 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
242 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
243 |
@Test(dataProvider = "lexical02") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
244 |
public void checkNormalize02(String lexical) { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
245 |
XMLGregorianCalendar orig = datatypeFactory.newXMLGregorianCalendar(lexical); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
246 |
XMLGregorianCalendar normalized = datatypeFactory.newXMLGregorianCalendar(lexical).normalize(); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
247 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
248 |
assertEquals(normalized.getTimezone(), orig.getTimezone()); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
249 |
assertEquals(normalized.getMillisecond(), orig.getMillisecond()); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
250 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
251 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
252 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
253 |
* Test XMLGregorianCalendar#toGregorianCalendar( TimeZone timezone, Locale |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
254 |
* aLocale, XMLGregorianCalendar defaults) |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
255 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
256 |
* Bug # 5040542 the defaults XMLGregorianCalendar parameter shall take |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
257 |
* effect |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
258 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
259 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
260 |
@Test |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
261 |
public void checkToGregorianCalendar01() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
262 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
263 |
XMLGregorianCalendar time_16_17_18 = datatypeFactory.newXMLGregorianCalendar("16:17:18"); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
264 |
XMLGregorianCalendar date_2001_02_03 = datatypeFactory.newXMLGregorianCalendar("2001-02-03"); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
265 |
GregorianCalendar calendar = date_2001_02_03.toGregorianCalendar(null, null, time_16_17_18); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
266 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
267 |
int year = calendar.get(YEAR); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
268 |
int minute = calendar.get(MINUTE); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
269 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
270 |
assertTrue((year == 2001 && minute == 17), " expecting year == 2001, minute == 17" + ", result is year == " + year + ", minute == " + minute); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
271 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
272 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
273 |
calendar = time_16_17_18.toGregorianCalendar(null, null, date_2001_02_03); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
274 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
275 |
year = calendar.get(YEAR); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
276 |
minute = calendar.get(MINUTE); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
277 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
278 |
assertTrue((year == 2001 && minute == 17), " expecting year == 2001, minute == 17" + ", result is year == " + year + ", minute == " + minute); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
279 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
280 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
281 |
date_2001_02_03.setMinute(3); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
282 |
date_2001_02_03.setYear(null); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
283 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
284 |
XMLGregorianCalendar date_time = datatypeFactory.newXMLGregorianCalendar("2003-04-11T02:13:01Z"); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
285 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
286 |
calendar = date_2001_02_03.toGregorianCalendar(null, null, date_time); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
287 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
288 |
year = calendar.get(YEAR); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
289 |
minute = calendar.get(MINUTE); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
290 |
int hour = calendar.get(HOUR); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
291 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
292 |
assertTrue((year == 2003 && hour == 2 && minute == 3), " expecting year == 2003, hour == 2, minute == 3" + ", result is year == " + year + ", hour == " + hour + ", minute == " + minute); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
293 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
294 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
295 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
296 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
297 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
298 |
* Test XMLGregorianCalendar#toGregorianCalendar( TimeZone timezone, Locale |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
299 |
* aLocale, XMLGregorianCalendar defaults) with the 'defaults' parameter |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
300 |
* being null. |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
301 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
302 |
* Bug # 5049531 XMLGregorianCalendar.toGregorianCalendar(..) can accept |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
303 |
* 'defaults' is null |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
304 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
305 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
306 |
@Test |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
307 |
public void checkToGregorianCalendar02() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
308 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
309 |
XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar("2004-05-19T12:00:00+06:00"); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
310 |
calendar.toGregorianCalendar(TimeZone.getDefault(), Locale.getDefault(), null); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
311 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
312 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
313 |
@DataProvider(name = "calendar") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
314 |
public Object[][] getXMLGregorianCalendarData() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
315 |
return new Object[][] { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
316 |
// year, month, day, hour, minute, second |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
317 |
{ 1970, 1, 1, 0, 0, 0 }, // DATETIME |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
318 |
{ 1970, 1, 1, undef, undef, undef }, // DATE |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
319 |
{ undef, undef, undef, 1, 0, 0 }, // TIME |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
320 |
{ 1970, 1, undef, undef, undef, undef }, // GYEARMONTH |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
321 |
{ undef, 1, 1, undef, undef, undef }, // GMONTHDAY |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
322 |
{ 1970, undef, undef, undef, undef, undef }, // GYEAR |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
323 |
{ undef, 1, undef, undef, undef, undef }, // GMONTH |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
324 |
{ undef, undef, 1, undef, undef, undef } // GDAY |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
325 |
}; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
326 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
327 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
328 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
329 |
* Test XMLGregorianCalendar#toString() |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
330 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
331 |
* Bug # 5049528 |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
332 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
333 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
334 |
@Test(dataProvider = "calendar") |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
335 |
public void checkToStringPos(final int year, final int month, final int day, final int hour, final int minute, final int second) { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
336 |
XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(year, month, day, hour, minute, second, undef, undef); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
337 |
calendar.toString(); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
338 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
339 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
340 |
/* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
341 |
* Negative Test XMLGregorianCalendar#toString() |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
342 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
343 |
* Bug # 5049528 XMLGregorianCalendar.toString throws IllegalStateException |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
344 |
* if all parameters are undef |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
345 |
* |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
346 |
*/ |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
347 |
@Test(expectedExceptions = IllegalStateException.class) |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
348 |
public void checkToStringNeg() { |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
349 |
XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(undef, undef, undef, undef, undef, undef, undef, undef); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
350 |
// expected to fail |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
351 |
calendar.toString(); |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
352 |
} |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
353 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
354 |
private final int undef = DatatypeConstants.FIELD_UNDEFINED; |
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
355 |
|
ce053a3f1d92
8051709: Convert JAXP function tests: javax.xml.datatype to jtreg (testng) tests
joehw
parents:
diff
changeset
|
356 |
} |