You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ki...@apache.org on 2019/01/18 23:08:48 UTC
svn commit: r1851656 [27/28] - in /xmlbeans/trunk: ./ external/ lib/
resources/ resources/typeimpl/ resources/typeimpl/org/
resources/typeimpl/org/apache/ resources/typeimpl/org/apache/xmlbeans/
resources/typeimpl/org/apache/xmlbeans/impl/ resources/ty...
Modified: xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/GDateTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/GDateTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/GDateTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/GDateTests.java Fri Jan 18 23:08:44 2019
@@ -15,306 +15,292 @@
package xmlobject.schematypes.checkin;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.Assert;
-import org.apache.xmlbeans.GDate;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.GDateBuilder;
-import org.apache.xmlbeans.GDuration;
-import org.apache.xmlbeans.GDurationBuilder;
-import org.apache.xmlbeans.XmlCalendar;
+import org.apache.xmlbeans.*;
+import org.junit.Assert;
+import org.junit.Test;
-import java.util.GregorianCalendar;
-import java.util.Date;
-import java.util.Calendar;
import java.math.BigDecimal;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+import static org.junit.Assert.*;
+
+public class GDateTests {
-public class GDateTests extends TestCase
-{
- public GDateTests(String name) { super(name); }
- public static Test suite() { return new TestSuite(GDateTests.class); }
-
- static String[] validDurations =
- {
- "PT0S",
- "P1Y",
- "P1M",
- "P1D",
- "P2Y",
- "P2M",
- "P2D",
- "PT1H",
- "PT1M",
- "PT1S",
- "PT3600S",
- "P1Y1M1DT1H1M1S",
- "P1Y1M1DT1H1M1.1S",
- "P1Y365D",
- "P1Y366D",
- "PT0.1S",
- "P1M29D",
-
- "PT0.1415926S",
- "PT5233132S",
- "PT142332M",
- "PT98023H",
-
- "-PT0S",
- "-P1Y",
- "-P1M",
- "-P1D",
- "-PT1H",
- "-PT1M",
- "-PT1S",
- "-P1Y1M1DT1H1M1S",
- "-P1Y1M1DT1H1M1.1S",
- "-P27D",
- "-P28D",
- "-P29D",
- "-P30D",
- "-P31D",
- "-P364D",
- "-P365D",
- "-P366D",
- "-PT0.1S",
- "-PT0.1415926S",
- "-PT5233132S",
- "-PT142332M",
- "-PT98023H",
-
- };
-
- static String[] invalidDurations =
- {
- "P1Y-364D",
- "P1Y-365D",
- "P1Y-366D",
- "P1Y-367D",
- "P1Y-12M",
- "P1M-27D",
- "P1M-28D",
- "P1M-29D",
- "P1M-31D",
- "P1M-32D",
- "P1MT-660H",
- "P1MT-670H",
- "P1MT-680H",
- "P1MT-690H",
- "P1MT-700H",
- "P1MT-710H",
- "P1MT-720H",
- "P1MT-730H",
- "P1MT-740H",
-
- "-PT-0S",
- "-P-1Y",
- "-P-1M",
- "-P-1D",
- "-PT-1H",
- "-PT-1M",
- "-PT-1S",
- "-P1Y1M-1DT1H1M1S",
- "-P1Y1M1DT1H-1M1.1S",
- "-PT-0.1S",
- "-PT-0.1415926S",
- };
-
- static String[] invalidDates =
- {
- "+14:01", // tz
- "-14:01", // tz
- "+15:00", // tz
- "-15:00", // tz
- "X",
- ",",
- "T",
- "+",
- "-",
- ":",
- "0",
- "March 2",
- "T00:00:00Z", // T not allowed
- "-00:00:00Z", // - not allowed
- "96-02-28T00:00:00Z", // year width
- "100-02-28T00:00:00Z", // year width
- "1900-2-28T00:00:00Z", // month width
- "1900-02-8T00:00:00Z", // day width
- "1900-02-08T0:00:00Z", // hour width
- "1900-02-08T00:0:00Z", // hour width
- "1900-02-08T00:00:0Z", // hour width
- "1900-02-08T00:00Z", // time incomplete
- "1900-02-08 T00:00:00Z", // space
- "1900-02-08T 00:00:00Z", // space
- "1900-02-08T00:00:00 Z", // space
- "1900-02-29T00Z", // time incomplete
- "00:00", // time incomplete
- "00", // incomplete
- "2100-02-29", // not leap
- "-999999999-02-28T00:00:00Z", // too long ago
- "999999999-02-28T00:00:00Z", // too long from now
- "9999999999999999999999999999999-02-28T00:00:00Z", // overflow?
- "0000-01-01", // year zero
- "0000-12-31T04:35:22.456", // year zero
- "1996-00-28T00:00:00Z", // month
- "1996-13-28T00:00:00Z", // month
- "1996-02-00T00:00:00Z", // day
- "2000-02-30T00:00:00Z", // day
- "1996-02-29T25:00:00Z", // hr
- "1996-02-29T24:00:01Z", // hr
- "1996-02-29T00:60:00Z", // min
- "1996-02-29T00:00:60Z", // sec
- "1996-02-29T00:00:00+14:01", // tz
- "1996-02-29T00:00:00-14:01", // tz
- "1996-02-29T00:00:00+15:00", // tz
- "1996-02-29T00:00:00-15:00", // tz
- "1996-00-29", // month
- "1996-13-29", // month
- "1996-02-00", // day
- "2000-02-30", // day
- "--00", // month
- "--13", // month
- "--00-01", // month
- "--13-01", // month
- "--02-00", // day
- "--02-30", // day
- "--01-32", // day
- "--11-31", // day
- "---00", // day
- "---32", // day
- "25:00:00Z", // hr
- "24:01:00Z", // hr
- "00:60:00Z", // min
- "00:00:60Z", // sec
- "00:00:00+14:01", // tz
- "00:00:00-14:01", // tz
- "00:00:00+15:00", // tz
- "00:00:00-15:00", // tz
- };
-
- static String[] validDates =
- {
- "",
- "Z", // timezone only
- "-14:00", // timezone only
- "999999-12-31T23:59:59.999Z",
- "1970-12-31T23:59:59.990+14:00",
- "1996-02-29T00:00:00Z", // leap
- "2000-02-29T00:00:00Z", // leap
- "2004-02-29T00:00:00Z", // leap
- "2008-02-29T00:00:00Z", // leap
- "2012-02-29T00:00:00Z", // leap
- "1900-02-28T00:00:00Z", // not leap
- "2100-02-28T00:00:00Z", // not leap
- "1900-03-28T00:00:00Z", // not leap
- "-4712-01-01T00:00:00Z",
- "1999-01-01T00:00:00+01:00",
- "2001-12-31T23:59:59.010",
- "2001-12-31T23:59:59.999901000",
- "1999-12-31T23:59:59.1234567890-14:00",
- "1992-12-31T23:59:59.01-14:00",
- "1965-12-31T23:59:59.000Z",
- //"0000-12-31T04:35:22.456",
- "1696-09-01T00:00:00Z",
- "1697-02-01T00:00:00Z",
- "1903-03-01T00:00:00Z",
- "1903-07-01T00:00:00Z",
- "1696-09-01T00:00:00+00:00",
- "1697-02-01T00:00:00-00:00",
- "2002",
- "-0001",
- "--12",
- "-0001-11",
- "2002-01",
- "---31",
- "1554--31",
- "-0004--31",
- "--02-29",
- "--12-31",
- "2002-04-18",
- "-0423-12-31",
- "23:59:59",
- "00:00:00",
- "2010T23:59:59",
- "-0001T00:00:00",
- "--12T23:59:59",
- "-0001-11T00:00:00",
- "2011-01T23:59:59",
- "---31T00:00:00",
- "2002--31T23:59:59",
- "-0004--31T00:00:00",
- "2002-02-18T23:59:59",
- "-0423-12-31T00:00:00",
- "2002Z",
- "-0001+01:30",
- "--12-14:00",
- "-0001-11Z",
- "1970-12-01:00",
- "---31+01:30",
- "2002--31Z",
- "--03-31-03:00",
- "--04-30+05:00",
- "-0004--31-01:00",
- "2002-04-18-14:00",
- "-0423-12-31Z",
- "23:59:59-01:00",
- "00:00:00Z",
- "00:00:00+01:30",
- "1776T23:59:59-14:00",
- "-0001T00:00:00Z",
- "--12T23:59:59+01:30",
- "-0001-11T00:00:00-01:00",
- "2002-02T23:59:59Z",
- "---31T00:00:00-14:00",
- "2002--31T23:59:59-01:00",
- "-0004--31T00:00:00+01:30",
- "2002-04-18T23:59:59Z",
- "-0423-12-31T00:00:00-05:00",
- "1996-02-29T24:00:00Z", // 24:00:00 is valid
- "24:00:00Z", // 24:00:00 is valid
+ private static String[] validDurations = {
+ "PT0S",
+ "P1Y",
+ "P1M",
+ "P1D",
+ "P2Y",
+ "P2M",
+ "P2D",
+ "PT1H",
+ "PT1M",
+ "PT1S",
+ "PT3600S",
+ "P1Y1M1DT1H1M1S",
+ "P1Y1M1DT1H1M1.1S",
+ "P1Y365D",
+ "P1Y366D",
+ "PT0.1S",
+ "P1M29D",
+
+ "PT0.1415926S",
+ "PT5233132S",
+ "PT142332M",
+ "PT98023H",
+
+ "-PT0S",
+ "-P1Y",
+ "-P1M",
+ "-P1D",
+ "-PT1H",
+ "-PT1M",
+ "-PT1S",
+ "-P1Y1M1DT1H1M1S",
+ "-P1Y1M1DT1H1M1.1S",
+ "-P27D",
+ "-P28D",
+ "-P29D",
+ "-P30D",
+ "-P31D",
+ "-P364D",
+ "-P365D",
+ "-P366D",
+ "-PT0.1S",
+ "-PT0.1415926S",
+ "-PT5233132S",
+ "-PT142332M",
+ "-PT98023H",
+
+ };
+
+ private static String[] invalidDurations = {
+ "P1Y-364D",
+ "P1Y-365D",
+ "P1Y-366D",
+ "P1Y-367D",
+ "P1Y-12M",
+ "P1M-27D",
+ "P1M-28D",
+ "P1M-29D",
+ "P1M-31D",
+ "P1M-32D",
+ "P1MT-660H",
+ "P1MT-670H",
+ "P1MT-680H",
+ "P1MT-690H",
+ "P1MT-700H",
+ "P1MT-710H",
+ "P1MT-720H",
+ "P1MT-730H",
+ "P1MT-740H",
+
+ "-PT-0S",
+ "-P-1Y",
+ "-P-1M",
+ "-P-1D",
+ "-PT-1H",
+ "-PT-1M",
+ "-PT-1S",
+ "-P1Y1M-1DT1H1M1S",
+ "-P1Y1M1DT1H-1M1.1S",
+ "-PT-0.1S",
+ "-PT-0.1415926S",
+ };
+
+ private static String[] invalidDates = {
+ "+14:01", // tz
+ "-14:01", // tz
+ "+15:00", // tz
+ "-15:00", // tz
+ "X",
+ ",",
+ "T",
+ "+",
+ "-",
+ ":",
+ "0",
+ "March 2",
+ "T00:00:00Z", // T not allowed
+ "-00:00:00Z", // - not allowed
+ "96-02-28T00:00:00Z", // year width
+ "100-02-28T00:00:00Z", // year width
+ "1900-2-28T00:00:00Z", // month width
+ "1900-02-8T00:00:00Z", // day width
+ "1900-02-08T0:00:00Z", // hour width
+ "1900-02-08T00:0:00Z", // hour width
+ "1900-02-08T00:00:0Z", // hour width
+ "1900-02-08T00:00Z", // time incomplete
+ "1900-02-08 T00:00:00Z", // space
+ "1900-02-08T 00:00:00Z", // space
+ "1900-02-08T00:00:00 Z", // space
+ "1900-02-29T00Z", // time incomplete
+ "00:00", // time incomplete
+ "00", // incomplete
+ "2100-02-29", // not leap
+ "-999999999-02-28T00:00:00Z", // too long ago
+ "999999999-02-28T00:00:00Z", // too long from now
+ "9999999999999999999999999999999-02-28T00:00:00Z", // overflow?
+ "0000-01-01", // year zero
+ "0000-12-31T04:35:22.456", // year zero
+ "1996-00-28T00:00:00Z", // month
+ "1996-13-28T00:00:00Z", // month
+ "1996-02-00T00:00:00Z", // day
+ "2000-02-30T00:00:00Z", // day
+ "1996-02-29T25:00:00Z", // hr
+ "1996-02-29T24:00:01Z", // hr
+ "1996-02-29T00:60:00Z", // min
+ "1996-02-29T00:00:60Z", // sec
+ "1996-02-29T00:00:00+14:01", // tz
+ "1996-02-29T00:00:00-14:01", // tz
+ "1996-02-29T00:00:00+15:00", // tz
+ "1996-02-29T00:00:00-15:00", // tz
+ "1996-00-29", // month
+ "1996-13-29", // month
+ "1996-02-00", // day
+ "2000-02-30", // day
+ "--00", // month
+ "--13", // month
+ "--00-01", // month
+ "--13-01", // month
+ "--02-00", // day
+ "--02-30", // day
+ "--01-32", // day
+ "--11-31", // day
+ "---00", // day
+ "---32", // day
+ "25:00:00Z", // hr
+ "24:01:00Z", // hr
+ "00:60:00Z", // min
+ "00:00:60Z", // sec
+ "00:00:00+14:01", // tz
+ "00:00:00-14:01", // tz
+ "00:00:00+15:00", // tz
+ "00:00:00-15:00", // tz
+ };
+
+ private static String[] validDates = {
+ "",
+ "Z", // timezone only
+ "-14:00", // timezone only
+ "999999-12-31T23:59:59.999Z",
+ "1970-12-31T23:59:59.990+14:00",
+ "1996-02-29T00:00:00Z", // leap
+ "2000-02-29T00:00:00Z", // leap
+ "2004-02-29T00:00:00Z", // leap
+ "2008-02-29T00:00:00Z", // leap
+ "2012-02-29T00:00:00Z", // leap
+ "1900-02-28T00:00:00Z", // not leap
+ "2100-02-28T00:00:00Z", // not leap
+ "1900-03-28T00:00:00Z", // not leap
+ "-4712-01-01T00:00:00Z",
+ "1999-01-01T00:00:00+01:00",
+ "2001-12-31T23:59:59.010",
+ "2001-12-31T23:59:59.999901000",
+ "1999-12-31T23:59:59.1234567890-14:00",
+ "1992-12-31T23:59:59.01-14:00",
+ "1965-12-31T23:59:59.000Z",
+ //"0000-12-31T04:35:22.456",
+ "1696-09-01T00:00:00Z",
+ "1697-02-01T00:00:00Z",
+ "1903-03-01T00:00:00Z",
+ "1903-07-01T00:00:00Z",
+ "1696-09-01T00:00:00+00:00",
+ "1697-02-01T00:00:00-00:00",
+ "2002",
+ "-0001",
+ "--12",
+ "-0001-11",
+ "2002-01",
+ "---31",
+ "1554--31",
+ "-0004--31",
+ "--02-29",
+ "--12-31",
+ "2002-04-18",
+ "-0423-12-31",
+ "23:59:59",
+ "00:00:00",
+ "2010T23:59:59",
+ "-0001T00:00:00",
+ "--12T23:59:59",
+ "-0001-11T00:00:00",
+ "2011-01T23:59:59",
+ "---31T00:00:00",
+ "2002--31T23:59:59",
+ "-0004--31T00:00:00",
+ "2002-02-18T23:59:59",
+ "-0423-12-31T00:00:00",
+ "2002Z",
+ "-0001+01:30",
+ "--12-14:00",
+ "-0001-11Z",
+ "1970-12-01:00",
+ "---31+01:30",
+ "2002--31Z",
+ "--03-31-03:00",
+ "--04-30+05:00",
+ "-0004--31-01:00",
+ "2002-04-18-14:00",
+ "-0423-12-31Z",
+ "23:59:59-01:00",
+ "00:00:00Z",
+ "00:00:00+01:30",
+ "1776T23:59:59-14:00",
+ "-0001T00:00:00Z",
+ "--12T23:59:59+01:30",
+ "-0001-11T00:00:00-01:00",
+ "2002-02T23:59:59Z",
+ "---31T00:00:00-14:00",
+ "2002--31T23:59:59-01:00",
+ "-0004--31T00:00:00+01:30",
+ "2002-04-18T23:59:59Z",
+ "-0423-12-31T00:00:00-05:00",
+ "1996-02-29T24:00:00Z", // 24:00:00 is valid
+ "24:00:00Z", // 24:00:00 is valid
- };
+ };
- private boolean hasTime(GDuration gd)
- {
+ private boolean hasTime(GDuration gd) {
return gd.getHour() != 0 || gd.getMinute() != 0 || gd.getSecond() != 0 || gd.getFraction().signum() != 0;
}
- public void testGregorianCalendar()
- {
+ @Test
+ public void testGregorianCalendar() {
// this is a check of DST offsets
Date date = new GDate("2002-04-18T23:59:59Z").getDate();
GregorianCalendar gcal = new XmlCalendar(date);
- Assert.assertEquals(date, gcal.getTime());
+ assertEquals(date, gcal.getTime());
// now check out some things
GDate gd = new GDate("2001-12-31T07:00:59.010");
GregorianCalendar gc = gd.getCalendar();
Date gdd = gd.getDate();
Date gcd = gc.getTime();
- Assert.assertEquals(gdd, gcd);
+ assertEquals(gdd, gcd);
// set up 2/29, and read out Feb 29 in the year 1 BC.
Calendar gregcal = new GDate("--02-29").getCalendar();
- Assert.assertEquals(29, gregcal.get(Calendar.DAY_OF_MONTH));
- Assert.assertEquals(2 - 1, gregcal.get(Calendar.MONTH));
- Assert.assertEquals(1, gregcal.get(Calendar.YEAR));
- Assert.assertEquals(0, gregcal.get(Calendar.ERA));
+ assertEquals(29, gregcal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(2 - 1, gregcal.get(Calendar.MONTH));
+ assertEquals(1, gregcal.get(Calendar.YEAR));
+ assertEquals(0, gregcal.get(Calendar.ERA));
// repeat some tests to make sure it's stable.
- Assert.assertEquals(29, gregcal.get(Calendar.DAY_OF_MONTH));
- Assert.assertEquals(2 - 1, gregcal.get(Calendar.MONTH));
+ assertEquals(29, gregcal.get(Calendar.DAY_OF_MONTH));
+ assertEquals(2 - 1, gregcal.get(Calendar.MONTH));
// now try some setters
gregcal = new GDate("--02-29").getCalendar();
gregcal.set(Calendar.MONTH, 10);
- Assert.assertEquals("--11-29", gregcal.toString());
+ assertEquals("--11-29", gregcal.toString());
// repeat to ensure it's stable.
- Assert.assertEquals("--11-29", gregcal.toString());
+ assertEquals("--11-29", gregcal.toString());
}
- private void _testEmptyDuration(GDuration gd)
- {
+ private void _testEmptyDuration(GDuration gd) {
assertTrue(gd.isValid());
assertEquals("PT0S", gd.toString());
assertEquals(0, gd.getYear());
@@ -326,41 +312,33 @@ public class GDateTests extends TestCase
assertEquals(new java.math.BigDecimal(0.0), gd.getFraction());
}
- public void testEmptyDuration()
- {
+ @Test
+ public void testEmptyDuration() {
GDuration gd = new GDuration();
_testEmptyDuration(gd);
GDuration gdCopy = new GDuration(gd);
_testEmptyDuration(gdCopy);
}
- public void testValidDuration()
- {
- for (int i = 0; i < validDurations.length; i++)
- {
+ @Test
+ public void testValidDuration() {
+ for (int i = 0; i < validDurations.length; i++) {
GDuration gd = null;
String str = validDurations[i];
- try
- {
+ try {
gd = new GDuration(str);
- }
- catch (IllegalArgumentException e)
- {
+ } catch (IllegalArgumentException e) {
Assert.fail("Problem with " + str + ": " + e.getMessage());
}
- Assert.assertEquals(str, gd.toString());
+ assertEquals(str, gd.toString());
- for (int j = 0; j < validDurations.length; j++)
- {
+ for (int j = 0; j < validDurations.length; j++) {
GDuration gd2 = null;
String str2 = validDurations[j];
- try
- {
+ try {
gd2 = new GDuration(str2);
- }
- catch (IllegalArgumentException e)
- {
+ } catch (IllegalArgumentException e) {
Assert.fail("Problem with " + str2 + ": " + e.getMessage());
}
@@ -370,25 +348,24 @@ public class GDateTests extends TestCase
gdb.setSign(-gdb.getSign());
gdb.addGDuration(gd);
GDuration sum2 = gdb.toGDuration();
- Assert.assertEquals(0, diff.compareToGDuration(sum2));
+ assertEquals(0, diff.compareToGDuration(sum2));
gdb.normalize();
GDurationBuilder gdb1 = new GDurationBuilder(diff);
gdb1.normalize();
- Assert.assertEquals("Problem: " + gd + " and " + gd2, gdb.toString(), gdb1.toString());
+ assertEquals("Problem: " + gd + " and " + gd2, gdb.toString(), gdb1.toString());
// comparing is reversible
int comp1 = gd.compareToGDuration(gd2);
int comp2 = gd2.compareToGDuration(gd);
if (comp1 == 2)
- Assert.assertEquals(2, comp2);
+ assertEquals(2, comp2);
else
- Assert.assertEquals(-comp1, comp2);
+ assertEquals(-comp1, comp2);
// comparing translates to addition to dates
boolean[] seen = new boolean[3];
- for (int k = 0; k < validDates.length; k++)
- {
+ for (int k = 0; k < validDates.length; k++) {
GDate date = new GDate(validDates[k]);
if (!date.hasDate() || date.getYear() > 99999 || date.getYear() < -4000)
continue;
@@ -399,39 +376,33 @@ public class GDateTests extends TestCase
GDate date2 = date.add(gd2);
comp2 = date1.compareToGDate(date2);
- if (comp1 != 2)
- {
- Assert.assertEquals("Adding " + date + " + " + gd + " -> " + date1 + ", " + gd2 + " -> " + date2 + ", expecting " + comp1, comp1, comp2);
- }
- else
- {
- Assert.assertTrue(comp2 != 2);
+ if (comp1 != 2) {
+ assertEquals("Adding " + date + " + " + gd + " -> " + date1 + ", " + gd2 + " -> " + date2 + ", expecting " + comp1, comp1, comp2);
+ } else {
+ assertTrue(comp2 != 2);
seen[comp2 + 1] = true;
}
// subtraction should yield the same result
- if (comp1 != 2)
- {
+ if (comp1 != 2) {
GDate date3 = date.add(diff);
- Assert.assertEquals(comp1, date3.compareToGDate(date));
+ assertEquals(comp1, date3.compareToGDate(date));
}
}
- if (comp1 == 2)
- {
+ if (comp1 == 2) {
int seencount = 0;
for (int k = 0; k < seen.length; k++)
if (seen[k])
seencount += 1;
- Assert.assertTrue("Not ambiguous as advertised" /* + gd + ", " + gd2 + " d: " + diff */, seencount > 1);
+ assertTrue("Not ambiguous as advertised" /* + gd + ", " + gd2 + " d: " + diff */, seencount > 1);
}
}
}
}
private void _testAddAndSubtract(String date1, String date2,
- String duration)
- {
+ String duration) {
GDate gd1 = new GDate(date1);
GDate gd2 = new GDate(date2);
GDuration gdur = new GDuration(duration);
@@ -443,8 +414,7 @@ public class GDateTests extends TestCase
assertEquals(gd1, gd);
}
- private void _testAdd(String date1, String date2, String duration)
- {
+ private void _testAdd(String date1, String date2, String duration) {
GDate gd1 = new GDate(date1);
GDate gd2 = new GDate(date2);
GDuration gdur = new GDuration(duration);
@@ -453,8 +423,7 @@ public class GDateTests extends TestCase
assertEquals(gd2, gd);
}
- private void _testSubtract(String date1, String date2, String duration)
- {
+ private void _testSubtract(String date1, String date2, String duration) {
GDate gd1 = new GDate(date1);
GDate gd2 = new GDate(date2);
GDuration gdur = new GDuration(duration);
@@ -463,8 +432,8 @@ public class GDateTests extends TestCase
assertEquals(gd1, gd);
}
- public void testAddAndSubtractDuration()
- {
+ @Test
+ public void testAddAndSubtractDuration() {
_testAddAndSubtract("1970-01-01", "1973-01-01", "P3Y");
_testAddAndSubtract("0001-01-01", "0004-01-01", "P3Y");
// there is no year 0, so 1 BCE + 3Y = 3 CE
@@ -491,265 +460,240 @@ public class GDateTests extends TestCase
_testSubtract("0001-01-01T00:00:00", "-0002-11-29T22:58:58.9", "-P1Y1M2DT1H1M1.1S");
}
- public void testOrder()
- {
- Assert.assertEquals(-1, new GDate("1998-08-26").compareToGDate(new GDate("2001-08-06")));
- Assert.assertEquals(-1, new GDate("1970-12-20T04:14:22Z").compareToGDate(new GDate("1971-04-18T12:51:41Z")));
- Assert.assertEquals(2, new GDate("2001-08-06").compareToGDate(new GDate("2001-08-06Z")));
- Assert.assertEquals(2, new GDate("2001-08-06").compareToGDate(new GDate("2001-08-07+10:00")));
- Assert.assertEquals(2, new GDate("2001-08-06").compareToGDate(new GDate("2001-08-05-10:00")));
- Assert.assertEquals(2, new GDate("2001-02-28").compareToGDate(new GDate("2001-03-01+10:00")));
- Assert.assertEquals(2, new GDate("2001-03-01").compareToGDate(new GDate("2001-02-28-10:00")));
- Assert.assertEquals(-1, new GDate("2000-02-28").compareToGDate(new GDate("2000-03-01+10:00")));
- Assert.assertEquals(1, new GDate("2000-03-01").compareToGDate(new GDate("2000-02-28-10:00")));
- Assert.assertEquals(-1, new GDate("2001-08-06Z").compareToGDate(new GDate("2001-08-06-00:01")));
- Assert.assertEquals(0, new GDate("00:00:00Z").compareToGDate(new GDate("00:01:00+00:01")));
- Assert.assertEquals(0, new GDate("12:00:00-05:00").compareToGDate(new GDate("09:00:00-08:00")));
- Assert.assertEquals(-1, new GDate("09:00:00-05:00").compareToGDate(new GDate("09:00:00-08:00"))); // the east coast rises before the west
- Assert.assertEquals(-1, new GDate("2003-05-05T09:00:00-05:00").compareToGDate(new GDate("2003-05-05T09:00:00-08:00"))); // the east coast rises before the west
- Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---31")));
- Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---31+14:00")));
- Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---31-14:00")));
- Assert.assertEquals(1, new GDate("---31").compareToGDate(new GDate("---01")));
- Assert.assertEquals(1, new GDate("---31").compareToGDate(new GDate("---01+14:00")));
- Assert.assertEquals(1, new GDate("---31").compareToGDate(new GDate("---01-14:00")));
- Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---02")));
- Assert.assertEquals(1, new GDate("---02").compareToGDate(new GDate("---01")));
- Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---02Z")));
- Assert.assertEquals(1, new GDate("---02").compareToGDate(new GDate("---01Z")));
- Assert.assertEquals(2, new GDate("---02").compareToGDate(new GDate("---01-10:00")));
- Assert.assertEquals(2, new GDate("---01").compareToGDate(new GDate("---02+10:00")));
- Assert.assertEquals(1, new GDate("---02").compareToGDate(new GDate("---01-09:00")));
- Assert.assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---02+09:00")));
- Assert.assertEquals(0, new GDate("---01").compareToGDate(new GDate("---01")));
- Assert.assertEquals(-1, new GDate("2003").compareToGDate(new GDate("2004")));
- Assert.assertEquals(-1, new GDate("--11").compareToGDate(new GDate("--12")));
- Assert.assertEquals(-1, new GDate("2003-12").compareToGDate(new GDate("2004-01")));
- Assert.assertEquals(-1, new GDate("--11-30").compareToGDate(new GDate("--12-01")));
- Assert.assertEquals(-1, new GDate("--02-28").compareToGDate(new GDate("--02-29")));
- Assert.assertEquals(-1, new GDate("--02-29").compareToGDate(new GDate("--03-01")));
- Assert.assertEquals(2, new GDate("--02-29").compareToGDate(new GDate("--03-01+10:00")));
- Assert.assertEquals(2, new GDate("--02-28").compareToGDate(new GDate("--03-01+10:00")));
- Assert.assertEquals(2, new GDate("--03-01").compareToGDate(new GDate("--02-28-10:00")));
- Assert.assertEquals(2, new GDate("--03-01").compareToGDate(new GDate("--02-29-10:00")));
- Assert.assertEquals(-1, new GDate("--02-29").compareToGDate(new GDate("--03-01+09:00")));
- Assert.assertEquals(-1, new GDate("--02-28").compareToGDate(new GDate("--03-01+09:00")));
- Assert.assertEquals(1, new GDate("--03-01").compareToGDate(new GDate("--02-28-09:00")));
- Assert.assertEquals(1, new GDate("--03-01").compareToGDate(new GDate("--02-29-09:00")));
- Assert.assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:59")));
- Assert.assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:59+09:59")));
- Assert.assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:01+09:59")));
- Assert.assertEquals(2, new GDate("00:00:00").compareToGDate(new GDate("23:59:00+09:59")));
- Assert.assertEquals(2, new GDate("00:00:00").compareToGDate(new GDate("23:59:59+10:00")));
- Assert.assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:59-14:00")));
- Assert.assertEquals(1, new GDate("23:59:59").compareToGDate(new GDate("00:00:00-09:59")));
- Assert.assertEquals(1, new GDate("23:59:59").compareToGDate(new GDate("00:00:58-09:59")));
- Assert.assertEquals(2, new GDate("23:59:59").compareToGDate(new GDate("00:00:59-09:59")));
- Assert.assertEquals(2, new GDate("23:59:59").compareToGDate(new GDate("00:00:00-10:00")));
- Assert.assertEquals(1, new GDate("23:59:59").compareToGDate(new GDate("00:00:00+14:00")));
+ @Test
+ public void testOrder() {
+ assertEquals(-1, new GDate("1998-08-26").compareToGDate(new GDate("2001-08-06")));
+ assertEquals(-1, new GDate("1970-12-20T04:14:22Z").compareToGDate(new GDate("1971-04-18T12:51:41Z")));
+ assertEquals(2, new GDate("2001-08-06").compareToGDate(new GDate("2001-08-06Z")));
+ assertEquals(2, new GDate("2001-08-06").compareToGDate(new GDate("2001-08-07+10:00")));
+ assertEquals(2, new GDate("2001-08-06").compareToGDate(new GDate("2001-08-05-10:00")));
+ assertEquals(2, new GDate("2001-02-28").compareToGDate(new GDate("2001-03-01+10:00")));
+ assertEquals(2, new GDate("2001-03-01").compareToGDate(new GDate("2001-02-28-10:00")));
+ assertEquals(-1, new GDate("2000-02-28").compareToGDate(new GDate("2000-03-01+10:00")));
+ assertEquals(1, new GDate("2000-03-01").compareToGDate(new GDate("2000-02-28-10:00")));
+ assertEquals(-1, new GDate("2001-08-06Z").compareToGDate(new GDate("2001-08-06-00:01")));
+ assertEquals(0, new GDate("00:00:00Z").compareToGDate(new GDate("00:01:00+00:01")));
+ assertEquals(0, new GDate("12:00:00-05:00").compareToGDate(new GDate("09:00:00-08:00")));
+ assertEquals(-1, new GDate("09:00:00-05:00").compareToGDate(new GDate("09:00:00-08:00"))); // the east coast rises before the west
+ assertEquals(-1, new GDate("2003-05-05T09:00:00-05:00").compareToGDate(new GDate("2003-05-05T09:00:00-08:00"))); // the east coast rises before the west
+ assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---31")));
+ assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---31+14:00")));
+ assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---31-14:00")));
+ assertEquals(1, new GDate("---31").compareToGDate(new GDate("---01")));
+ assertEquals(1, new GDate("---31").compareToGDate(new GDate("---01+14:00")));
+ assertEquals(1, new GDate("---31").compareToGDate(new GDate("---01-14:00")));
+ assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---02")));
+ assertEquals(1, new GDate("---02").compareToGDate(new GDate("---01")));
+ assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---02Z")));
+ assertEquals(1, new GDate("---02").compareToGDate(new GDate("---01Z")));
+ assertEquals(2, new GDate("---02").compareToGDate(new GDate("---01-10:00")));
+ assertEquals(2, new GDate("---01").compareToGDate(new GDate("---02+10:00")));
+ assertEquals(1, new GDate("---02").compareToGDate(new GDate("---01-09:00")));
+ assertEquals(-1, new GDate("---01").compareToGDate(new GDate("---02+09:00")));
+ assertEquals(0, new GDate("---01").compareToGDate(new GDate("---01")));
+ assertEquals(-1, new GDate("2003").compareToGDate(new GDate("2004")));
+ assertEquals(-1, new GDate("--11").compareToGDate(new GDate("--12")));
+ assertEquals(-1, new GDate("2003-12").compareToGDate(new GDate("2004-01")));
+ assertEquals(-1, new GDate("--11-30").compareToGDate(new GDate("--12-01")));
+ assertEquals(-1, new GDate("--02-28").compareToGDate(new GDate("--02-29")));
+ assertEquals(-1, new GDate("--02-29").compareToGDate(new GDate("--03-01")));
+ assertEquals(2, new GDate("--02-29").compareToGDate(new GDate("--03-01+10:00")));
+ assertEquals(2, new GDate("--02-28").compareToGDate(new GDate("--03-01+10:00")));
+ assertEquals(2, new GDate("--03-01").compareToGDate(new GDate("--02-28-10:00")));
+ assertEquals(2, new GDate("--03-01").compareToGDate(new GDate("--02-29-10:00")));
+ assertEquals(-1, new GDate("--02-29").compareToGDate(new GDate("--03-01+09:00")));
+ assertEquals(-1, new GDate("--02-28").compareToGDate(new GDate("--03-01+09:00")));
+ assertEquals(1, new GDate("--03-01").compareToGDate(new GDate("--02-28-09:00")));
+ assertEquals(1, new GDate("--03-01").compareToGDate(new GDate("--02-29-09:00")));
+ assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:59")));
+ assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:59+09:59")));
+ assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:01+09:59")));
+ assertEquals(2, new GDate("00:00:00").compareToGDate(new GDate("23:59:00+09:59")));
+ assertEquals(2, new GDate("00:00:00").compareToGDate(new GDate("23:59:59+10:00")));
+ assertEquals(-1, new GDate("00:00:00").compareToGDate(new GDate("23:59:59-14:00")));
+ assertEquals(1, new GDate("23:59:59").compareToGDate(new GDate("00:00:00-09:59")));
+ assertEquals(1, new GDate("23:59:59").compareToGDate(new GDate("00:00:58-09:59")));
+ assertEquals(2, new GDate("23:59:59").compareToGDate(new GDate("00:00:59-09:59")));
+ assertEquals(2, new GDate("23:59:59").compareToGDate(new GDate("00:00:00-10:00")));
+ assertEquals(1, new GDate("23:59:59").compareToGDate(new GDate("00:00:00+14:00")));
}
- public void testAPI() throws Exception
- {
+ @Test
+ public void testAPI() throws Exception {
GDateBuilder builder = new GDateBuilder("1970-12-20T04:14:22Z");
builder.normalizeToTimeZone(1, 0, 0);
- Assert.assertEquals("1970-12-20T04:14:22+00:00", builder.toString());
+ assertEquals("1970-12-20T04:14:22+00:00", builder.toString());
builder.setTimeZone(615);
- Assert.assertEquals("1970-12-20T04:14:22+10:15", builder.toString());
+ assertEquals("1970-12-20T04:14:22+10:15", builder.toString());
builder.setTimeZone(-345);
- Assert.assertEquals("1970-12-20T04:14:22-05:45", builder.toString());
+ assertEquals("1970-12-20T04:14:22-05:45", builder.toString());
builder.normalizeToTimeZone(-300);
- Assert.assertEquals("1970-12-20T04:59:22-05:00", builder.toString());
+ assertEquals("1970-12-20T04:59:22-05:00", builder.toString());
}
- public void testFailure() throws Exception
- {
- for (int i = 0; i < invalidDurations.length; i++)
- {
+ @Test
+ public void testFailure() throws Exception {
+ for (int i = 0; i < invalidDurations.length; i++) {
String str = invalidDurations[i];
- try
- {
+ try {
new GDuration(str);
- }
- catch (IllegalArgumentException e)
- {
+ } catch (IllegalArgumentException e) {
continue;
}
Assert.fail("Missing exception for GDuration: " + str);
}
- for (int i = 0; i < invalidDates.length; i++)
- {
+ for (int i = 0; i < invalidDates.length; i++) {
String str = invalidDates[i];
- try
- {
+ try {
new GDate(str);
- }
- catch (IllegalArgumentException e)
- {
+ } catch (IllegalArgumentException e) {
continue;
}
Assert.fail("Missing exception for GDate " + str);
}
}
- public void testSuccess() throws Exception
- {
- for (int i = 0; i < validDates.length; i++)
- {
+ @Test
+ public void testSuccess() throws Exception {
+ for (int i = 0; i < validDates.length; i++) {
String str = validDates[i];
GDate gdate = null;
- try
- {
+ try {
gdate = new GDate(str);
- }
- catch (IllegalArgumentException e)
- {
+ } catch (IllegalArgumentException e) {
Assert.fail("Problem with " + str + ": " + e.getMessage());
}
- if ( str.indexOf("24:00:00") >= 0 && gdate.hasDay() ) // for 24h if hasDay must be normalized, else has the same representation
- {
- Assert.assertTrue(str + " " + gdate.toString(), gdate.hasDay() && gdate.toString().indexOf("00:00:00") >= 0);
- }
- else
+ // for 24h if hasDay must be normalized, else has the same representation
+ if (str.contains("24:00:00") && gdate.hasDay()) {
+ assertTrue(str + " " + gdate.toString(), gdate.hasDay() && gdate.toString().contains("00:00:00"));
+ } else
// must round-trip to string
- Assert.assertEquals(str, gdate.toString());
+ assertEquals(str, gdate.toString());
// must round-trip to GregorianCalendar if fractions-of-seconds <=3 digits
if (gdate.getFraction() == null || gdate.getFraction().scale() <= 3)
if (!gdate.toString().equals("--02-29")) // bug in gcal -> 03-01
- {
- GregorianCalendar gcal = gdate.getCalendar();
- GDate gdate2 = new GDate(gcal);
- Assert.assertEquals(gdate, gdate2);
-
- // and if fractions-of-seconds is 3 digits, stringrep must round-trip
- if (gdate.getFraction() == null || gdate.getFraction().scale() == 3 || gdate.getFraction().scale() == 0)
- Assert.assertEquals(gdate.toString(), gdate2.toString());
- }
+ {
+ GregorianCalendar gcal = gdate.getCalendar();
+ GDate gdate2 = new GDate(gcal);
+ assertEquals(gdate, gdate2);
+
+ // and if fractions-of-seconds is 3 digits, stringrep must round-trip
+ if (gdate.getFraction() == null || gdate.getFraction().scale() == 3 || gdate.getFraction().scale() == 0)
+ assertEquals(gdate.toString(), gdate2.toString());
+ }
// must round-trip to Date if absolute time+timezone + fractions-of-seconds <= 3
- if (gdate.hasTimeZone() && gdate.getYear() > -4000 && gdate.getYear() < 99999 && gdate.getBuiltinTypeCode() == SchemaType.BTC_DATE_TIME && gdate.getFraction().scale() <= 3)
- {
+ if (gdate.hasTimeZone() && gdate.getYear() > -4000 && gdate.getYear() < 99999 && gdate.getBuiltinTypeCode() == SchemaType.BTC_DATE_TIME && gdate.getFraction().scale() <= 3) {
Date date = gdate.getDate();
GDate gdate2 = new GDate(date);
- Assert.assertEquals(gdate, gdate2);
+ assertEquals(gdate, gdate2);
// normalize to UTC fractions-of-seconds is 0 or 3 digits [not 000], stringrep must round-trip
- if (gdate.getTimeZoneSign() == 0 && ((gdate.getFraction().scale() == 3 && gdate.getFraction().signum() != 0) || gdate.getFraction().scale() == 0))
- {
+ if (gdate.getTimeZoneSign() == 0 && ((gdate.getFraction().scale() == 3 && gdate.getFraction().signum() != 0) || gdate.getFraction().scale() == 0)) {
GDateBuilder gdb = new GDateBuilder(gdate2);
gdb.normalizeToTimeZone(0, 0, 0);
- Assert.assertEquals(gdate.toString(), gdb.toString());
+ assertEquals(gdate.toString(), gdb.toString());
}
// verify that going through gcal gives us the same thing
GregorianCalendar gcal = gdate.getCalendar();
- Assert.assertEquals(date, gcal.getTime());
+ assertEquals(date, gcal.getTime());
// double-check XmlCalendar constructor
gcal = new XmlCalendar(date);
- Assert.assertEquals("Doing " + gdate, date, gcal.getTime());
- }
- else if (gdate.hasDate() && (gdate.getFraction() == null || gdate.getFraction().scale() <= 3))
- {
+ assertEquals("Doing " + gdate, date, gcal.getTime());
+ } else if (gdate.hasDate() && (gdate.getFraction() == null || gdate.getFraction().scale() <= 3)) {
// must be able to get a date if time+timezone is unset (midnight, ltz are assumed)
Date date = gdate.getDate();
GDateBuilder gdate1 = new GDateBuilder(gdate);
if (!gdate1.hasTime())
gdate1.setTime(0, 0, 0, null);
- Assert.assertEquals(gdate1.getDate(), date);
+ assertEquals(gdate1.getDate(), date);
// verify that going through gcal gives us the same thing
GregorianCalendar gcal = gdate.getCalendar();
- Assert.assertEquals("Comparing " + gdate + " and " + gcal, date, gcal.getTime());
+ assertEquals("Comparing " + gdate + " and " + gcal, date, gcal.getTime());
}
}
}
- public void test24hDates()
- {
+ @Test
+ public void test24hDates() {
GDate d1 = new GDate("2004-03-31T24:00:00");
- Assert.assertEquals("2004-04-01T00:00:00", d1.toString());
+ assertEquals("2004-04-01T00:00:00", d1.toString());
GDateBuilder b = new GDateBuilder();
b.setTime(24, 0, 0, new BigDecimal("0.00"));
System.out.println("hour 24: " + b.getCalendar());
- Assert.assertEquals("24:00:00.000", b.getCalendar().toString());
+ assertEquals("24:00:00.000", b.getCalendar().toString());
b.setDay(10);
b.setMonth(1);
System.out.println("hour 24: " + b.getCalendar());
- Assert.assertEquals("--01-10T24:00:00.000", b.getCalendar().toString());
+ assertEquals("--01-10T24:00:00.000", b.getCalendar().toString());
b.setYear(2010);
System.out.println("hour 24: " + b.getCalendar());
- Assert.assertEquals("2010-01-10T24:00:00.000", b.getCalendar().toString());
+ assertEquals("2010-01-10T24:00:00.000", b.getCalendar().toString());
b.setDay(31);
b.setMonth(03);
b.setYear(2004);
System.out.println("hour 24: canonical str: " + b.canonicalString());
- Assert.assertEquals("2004-04-01T00:00:00", b.canonicalString());
+ assertEquals("2004-04-01T00:00:00", b.canonicalString());
System.out.println("hour 24: toString: " + b.toString());
- Assert.assertEquals("2004-03-31T24:00:00.00", b.toString());
+ assertEquals("2004-03-31T24:00:00.00", b.toString());
System.out.println("hour 24: toGDate: " + b.toGDate());
- Assert.assertEquals("2004-03-31T24:00:00.00", b.toGDate().toString());
+ assertEquals("2004-03-31T24:00:00.00", b.toGDate().toString());
System.out.println("hour 24: toGDate().canonicalStr: " + b.toGDate().canonicalString());
- Assert.assertEquals("2004-04-01T00:00:00", b.toGDate().canonicalString());
+ assertEquals("2004-04-01T00:00:00", b.toGDate().canonicalString());
System.out.println("hour 24: toGDate().getCal: " + b.toGDate().getCalendar());
- Assert.assertEquals("2004-03-31T24:00:00.000", b.toGDate().getCalendar().toString());
+ assertEquals("2004-03-31T24:00:00.000", b.toGDate().getCalendar().toString());
GDateBuilder gdb = new GDateBuilder("24:00:00+01:00");
System.out.println("gdb: " + gdb);
- Assert.assertEquals("24:00:00+01:00", gdb.toString());
+ assertEquals("24:00:00+01:00", gdb.toString());
gdb.normalize();
System.out.println("gdb.normalize(): " + gdb);
- Assert.assertEquals("23:00:00Z", gdb.toString());
+ assertEquals("23:00:00Z", gdb.toString());
}
- public void testYearStartingWith0()
- {
+ @Test
+ public void testYearStartingWith0() {
GDate gdate = new GDate("0004-08-01"); // 00004-08-01 must fail
System.out.println("year starting with 0: " + gdate.getCalendar());
- Assert.assertEquals("0004-08-01", gdate.toString());
+ assertEquals("0004-08-01", gdate.toString());
String txt = "-9999-06";
GDate d = new GDate(txt);
System.out.println(" gdate(" + txt + ") = " + d);
- Assert.assertEquals("-9999-06", d.toString());
+ assertEquals("-9999-06", d.toString());
txt = "-12345-06";
d = new GDate(txt);
System.out.println(" gdate(" + txt + ") = " + d);
- Assert.assertEquals(txt, d.toString());
+ assertEquals(txt, d.toString());
- try
- {
+ try {
txt = "00004-08-01";
d = new GDate(txt); // 00004-08-01 must fail
- Assert.assertTrue("Year starting with 0 of five digits: " + txt, false);
- }
- catch(IllegalArgumentException e)
- {
- Assert.assertTrue("Year starting with 0 of five digits: " + txt, true);
+ fail("Year starting with 0 of five digits: " + txt);
+ } catch (IllegalArgumentException e) {
}
- try
- {
+ try {
txt = "-012340-08-01";
d = new GDate(txt);
- Assert.assertTrue("Year starting with 0 of six digits: " + txt, false);
- }
- catch(IllegalArgumentException e)
- {
- Assert.assertTrue("Year starting with 0 of six digits: " + txt, true);
+ fail("Year starting with 0 of six digits: " + txt);
+ } catch (IllegalArgumentException e) {
}
}
}
Modified: xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/IntTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/IntTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/IntTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/IntTests.java Fri Jan 18 23:08:44 2019
@@ -16,28 +16,23 @@
package xmlobject.schematypes.checkin;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.TestCase;
-import junit.framework.Assert;
-
+import org.apache.xmlbeans.XmlException;
+import org.junit.Test;
import xint.test.PositionDocument;
-public class IntTests extends TestCase
-{
- public IntTests(String name) { super(name); }
- public static Test suite() { return new TestSuite(IntTests.class); }
+import static org.junit.Assert.assertEquals;
- public static void testLatLong() throws Exception
- {
+public class IntTests {
+ @Test
+ public void testLatLong() throws XmlException {
PositionDocument doc = PositionDocument.Factory.parse(
- "<p:position xmlns:p='java:int.test'><p:lat>43</p:lat><p:lon>020</p:lon></p:position>");
- Assert.assertEquals(43, doc.getPosition().getLat());
- Assert.assertEquals(20, doc.getPosition().getLon());
+ "<p:position xmlns:p='java:int.test'><p:lat>43</p:lat><p:lon>020</p:lon></p:position>");
+ assertEquals(43, doc.getPosition().getLat());
+ assertEquals(20, doc.getPosition().getLon());
doc.getPosition().xgetLat().setStringValue("07");
doc.getPosition().xgetLon().setStringValue("040");
- Assert.assertEquals(7, doc.getPosition().getLat());
- Assert.assertEquals(40, doc.getPosition().getLon());
- doc.getPosition().setLat((short)22);
+ assertEquals(7, doc.getPosition().getLat());
+ assertEquals(40, doc.getPosition().getLon());
+ doc.getPosition().setLat((short) 22);
}
}
Modified: xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/NumeralsTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/NumeralsTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/NumeralsTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/NumeralsTests.java Fri Jan 18 23:08:44 2019
@@ -17,29 +17,22 @@
package xmlobject.schematypes.checkin;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.Assert;
-import org.openuri.testNumerals.DocDocument;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.impl.values.XmlValueOutOfRangeException;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openuri.testNumerals.DocDocument;
import java.math.BigDecimal;
import java.math.BigInteger;
-/**
- * Author: Cezar Andrei (cezar.andrei at bea.com)
- * Date: Nov 23, 2003
- */
-public class NumeralsTests extends TestCase
-{
- public NumeralsTests(String name) { super(name); }
- public static Test suite() { return new TestSuite(NumeralsTests.class); }
+import static org.junit.Assert.*;
+public class NumeralsTests {
private static DocDocument.Doc doc;
- static
- {
+
+ @BeforeClass
+ public static void initDoc() throws XmlException {
String inst =
"<doc xmlns='http://openuri.org/testNumerals'>\n" +
" <string> this is a long string \n" +
@@ -117,158 +110,138 @@ public class NumeralsTests extends TestC
" </integer>\n" +
"</doc>";
- try
- {
- doc = DocDocument.Factory.parse(inst).getDoc();
- }
- catch (XmlException e)
- {
- throw new IllegalStateException(e.getMessage());
- }
+ doc = DocDocument.Factory.parse(inst).getDoc();
}
- public void test1() throws XmlException
- {
+ @Test
+ public void test1() {
String s = " this is a long string \n" + " ... ";
- Assert.assertTrue("String expected:\n'" + s + "' actual:\n'" +
- doc.getStringArray()[0] + "'", s.equals(doc.getStringArray()[0]));
+ assertEquals("String expected:\n'" + s + "' actual:\n'" +
+ doc.getStringArray()[0] + "'", s, doc.getStringArray()[0]);
}
- public void test2() throws XmlException
- {
- Assert.assertTrue("int expected:" + 5 + " actual:" + doc.getIntArray()[0], doc.getIntArray()[0]==5);
+ @Test
+ public void test2() {
+ assertEquals("int expected:" + 5 + " actual:" + doc.getIntArray()[0], 5, doc.getIntArray()[0]);
}
- public void test3() throws XmlException
- {
- Assert.assertTrue("int expected:" + (-6) + " actual:" + doc.getIntArray()[1], doc.getIntArray()[1]==-6);
+ @Test
+ public void test3() {
+ assertEquals("int expected:" + (-6) + " actual:" + doc.getIntArray()[1], doc.getIntArray()[1], -6);
}
- public void test4() throws XmlException
- {
- Assert.assertTrue("int expected:" + 15 + " actual:" + doc.getIntArray()[2], doc.getIntArray()[2]==15);
+ @Test
+ public void test4() {
+ assertEquals("int expected:" + 15 + " actual:" + doc.getIntArray()[2], 15, doc.getIntArray()[2]);
}
- public void test5() throws XmlException
- {
- Assert.assertTrue("int expected:" + 77 + " actual:" + doc.getIntArray()[3], doc.getIntArray()[3]==77);
+ @Test
+ public void test5() {
+ assertEquals("int expected:" + 77 + " actual:" + doc.getIntArray()[3], 77, doc.getIntArray()[3]);
}
- public void test6() throws XmlException
- {
- Assert.assertTrue(doc.getBooleanArray(0)==true);
+ @Test
+ public void test6() {
+ assertTrue(doc.getBooleanArray(0));
}
- public void test7() throws XmlException
- {
- Assert.assertTrue(doc.getBooleanArray(1)==false);
+ @Test
+ public void test7() {
+ assertFalse(doc.getBooleanArray(1));
}
- public void test8() throws XmlException
- {
- Assert.assertTrue(doc.getBooleanArray(2)==false);
+ @Test
+ public void test8() {
+ assertFalse(doc.getBooleanArray(2));
}
- public void test9() throws XmlException
- {
- Assert.assertTrue(doc.getBooleanArray(3)==true);
+ @Test
+ public void test9() {
+ assertTrue(doc.getBooleanArray(3));
}
- public void test10() throws XmlException
- {
- try { boolean b = doc.getBooleanArray()[4]; Assert.assertTrue(false); }
- catch(XmlValueOutOfRangeException e)
- { Assert.assertTrue(true); }
+ @Test(expected = XmlValueOutOfRangeException.class)
+ public void test10() {
+ boolean b = doc.getBooleanArray()[4];
}
- public void test11() throws XmlException
- {
- Assert.assertTrue(doc.getShortArray()[0]==3);
+ @Test
+ public void test11() {
+ assertEquals(3, doc.getShortArray()[0]);
}
- public void test12() throws XmlException
- {
- Assert.assertTrue(doc.getByteArray()[0]==1);
+ @Test
+ public void test12() {
+ assertEquals(1, doc.getByteArray()[0]);
}
- public void test13() throws XmlException
- {
- Assert.assertTrue("long expected:" + (-50000) + " actual:" + doc.getLongArray()[0],
- doc.getLongArray()[0]==-500000);
+ @Test
+ public void test13() {
+ assertEquals("long expected:" + (-50000) + " actual:" + doc.getLongArray()[0], doc.getLongArray()[0], -500000);
}
- public void test14() throws XmlException
- {
- Assert.assertTrue("long expected:" + 1 + " actual:" + doc.getLongArray()[1],
- doc.getLongArray()[1]==1);
+ @Test
+ public void test14() {
+ assertEquals("long expected:" + 1 + " actual:" + doc.getLongArray()[1], 1, doc.getLongArray()[1]);
}
- public void test15() throws XmlException
- {
- Assert.assertTrue("long expected:" + 2 + " actual:" + doc.getLongArray()[2],
- doc.getLongArray()[2]==2);
+ @Test
+ public void test15() {
+ assertEquals("long expected:" + 2 + " actual:" + doc.getLongArray()[2], 2, doc.getLongArray()[2]);
}
- public void test16() throws XmlException
- {
- Assert.assertTrue(doc.getDoubleArray()[0]==1);
+ @Test
+ public void test16() {
+ assertEquals(1, doc.getDoubleArray()[0], 0.0);
}
- public void test17() throws XmlException
- {
- Assert.assertTrue("double expected:" + -2.007d + " actual:" + doc.getDoubleArray()[1],
- doc.getDoubleArray()[1]==-2.007d);
+ @Test
+ public void test17() {
+ assertEquals("double expected:" + -2.007d + " actual:" + doc.getDoubleArray()[1], doc.getDoubleArray()[1], -2.007d, 0.0);
}
- public void test18() throws XmlException
- {
- Assert.assertTrue(new Double(Double.POSITIVE_INFINITY).
- equals(new Double(doc.getDoubleArray()[2])));
+ @Test
+ public void test18() {
+ assertEquals(Double.POSITIVE_INFINITY, doc.getDoubleArray()[2], 0);
}
- public void test19() throws XmlException
- {
- Assert.assertTrue(new Double(Double.NEGATIVE_INFINITY).
- equals(new Double(doc.getDoubleArray()[3])));
+ @Test
+ public void test19() {
+ assertEquals(Double.NEGATIVE_INFINITY, doc.getDoubleArray()[3], 0);
}
- public void test20() throws XmlException
- {
- Assert.assertTrue(new Double(Double.NaN).
- equals(new Double(doc.getDoubleArray()[4])));
+ @Test
+ public void test20() {
+ assertEquals(Double.NaN, doc.getDoubleArray()[4], 0);
}
- public void test21() throws XmlException
- {
- Assert.assertTrue("fload expected:" + 12.325f + " actual:" + doc.getFloatArray()[0],
- doc.getFloatArray()[0]==12.325f);
+ @Test
+ public void test21() {
+ assertEquals("fload expected:" + 12.325f + " actual:" + doc.getFloatArray()[0], 12.325f, doc.getFloatArray()[0], 0.0);
}
- public void test22() throws XmlException
- {
- Assert.assertTrue(new Float(Float.NaN).
- equals(new Float(doc.getFloatArray()[1])));
+ @Test
+ public void test22() {
+ assertEquals(Float.NaN, doc.getFloatArray()[1], 0);
}
- public void test23() throws XmlException
- {
- Assert.assertTrue("fload expected:" + Float.POSITIVE_INFINITY + " actual:" + doc.getFloatArray()[2],
- new Float(Float.POSITIVE_INFINITY).equals(new Float(doc.getFloatArray()[2])));
+ @Test
+ public void test23() {
+ assertEquals("fload expected:" + Float.POSITIVE_INFINITY + " actual:" + doc.getFloatArray()[2], Float.POSITIVE_INFINITY, doc.getFloatArray()[2], 0);
}
- public void test24() throws XmlException
- {
- Assert.assertTrue(new Float(Float.NEGATIVE_INFINITY).
- equals(new Float(doc.getFloatArray()[3])));
+ @Test
+ public void test24() {
+ assertEquals(Float.NEGATIVE_INFINITY, doc.getFloatArray()[3], 0);
}
- public void test25() throws XmlException
- {
- Assert.assertTrue(new BigDecimal("1.001").equals(doc.getDecimalArray()[0]));
+ @Test
+ public void test25() {
+ assertEquals(new BigDecimal("1.001"), doc.getDecimalArray()[0]);
}
- public void test26() throws XmlException
- {
- Assert.assertTrue(new BigInteger("1000000000").equals(doc.getIntegerArray(0)));
+ @Test
+ public void test26() {
+ assertEquals(new BigInteger("1000000000"), doc.getIntegerArray(0));
}
}
Modified: xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/QNameTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/QNameTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/QNameTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/QNameTests.java Fri Jan 18 23:08:44 2019
@@ -15,29 +15,18 @@
package xmlobject.schematypes.checkin;
-import org.apache.xmlbeans.XmlQName;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.SchemaTypeLoader;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlAnySimpleType;
-import junit.framework.Assert;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class QNameTests extends TestCase
-{
- public QNameTests(String name) { super(name); }
- public static Test suite() { return new TestSuite(QNameTests.class); }
+import org.apache.xmlbeans.*;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+public class QNameTests {
static String[] _args;
static String _test;
- public void testQName ( )
- throws Exception
- {
+ @Test
+ public void testQName() throws Exception {
String schema =
"<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>\n" +
"" +
@@ -48,10 +37,9 @@ public class QNameTests extends TestCase
"";
SchemaTypeLoader stl =
- XmlBeans.loadXsd( new XmlObject[] {
- XmlObject.Factory.parse(schema) } );
+ XmlBeans.loadXsd(new XmlObject[]{
+ XmlObject.Factory.parse(schema)});
-
//
// Test the set_XMLName function on XmlQNameImpl
//
@@ -59,11 +47,11 @@ public class QNameTests extends TestCase
String ns =
"xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " +
"xmlns:xs='http://www.w3.org/2001/XMLSchema'";
-
+
XmlObject sourceDocument =
stl.parse(
"<any " + ns + " xsi:type='xs:QName' xmlns:xxx='xxx.com'>" +
- "xxx:abc</any>", null, null );
+ "xxx:abc</any>", null, null);
XmlCursor sourceCursor = sourceDocument.newCursor();
@@ -74,7 +62,7 @@ public class QNameTests extends TestCase
XmlObject targetDocument =
stl.parse(
"<any " + ns + " xsi:type='xs:QName'>" +
- "</any>", null, null );
+ "</any>", null, null);
XmlCursor targetCursor = targetDocument.newCursor();
@@ -82,19 +70,18 @@ public class QNameTests extends TestCase
XmlQName targetQName = (XmlQName) targetCursor.getObject();
- targetQName.set( sourceQName );
+ targetQName.set(sourceQName);
- Assert.assertTrue(
- targetQName.getQNameValue().getNamespaceURI().equals( "xxx.com" ) );
+ assertEquals("xxx.com", targetQName.getQNameValue().getNamespaceURI());
//
// Test the set_text function on XmlQNameImpl
//
-
+
targetDocument =
stl.parse(
"<any " + ns + " xsi:type='xs:QName' xmlns:xxx='xxx.com'>" +
- "</any>", null, null );
+ "</any>", null, null);
targetCursor = targetDocument.newCursor();
@@ -102,19 +89,14 @@ public class QNameTests extends TestCase
targetQName = (XmlQName) targetCursor.getObject();
- try
- {
- targetQName.setStringValue( "zzz:abc" );
-
- Assert.assertTrue( false ); // Must fail
+ try {
+ targetQName.setStringValue("zzz:abc");
+ fail("Must fail");
+ } catch (Throwable t) {
}
- catch ( Throwable t )
- {
- }
-
- targetQName.setStringValue( "xxx:abc" );
-
- Assert.assertTrue(
- targetQName.getQNameValue().getNamespaceURI().equals( "xxx.com" ) );
+
+ targetQName.setStringValue("xxx:abc");
+
+ assertEquals("xxx.com", targetQName.getQNameValue().getNamespaceURI());
}
}
Modified: xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/SchemaTypesTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/SchemaTypesTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/SchemaTypesTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/schematypes/checkin/SchemaTypesTests.java Fri Jan 18 23:08:44 2019
@@ -16,158 +16,144 @@
package xmlobject.schematypes.checkin;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.XmlOptions;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlBeans;
-import org.apache.xmlbeans.XmlCalendar;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import java.util.Date;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.io.InputStream;
-
-import org.openuri.xstypes.test.*;
-import org.openuri.def.DefaultsDocument;
+import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.xb.xsdschema.SchemaDocument;
+import org.junit.Test;
+import org.openuri.def.DefaultsDocument;
+import org.openuri.xstypes.test.CustomerDocument;
+import org.openuri.xstypes.test.Person;
+import tools.util.JarUtil;
import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.io.InputStream;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
-import tools.util.*;
-
-public class SchemaTypesTests extends TestCase
-{
- public SchemaTypesTests(String name) { super(name); }
- public static Test suite() { return new TestSuite(SchemaTypesTests.class); }
+public class SchemaTypesTests {
private CustomerDocument doc;
private void ensureDoc()
- throws Exception
- {
- if( doc==null )
- {
+ throws Exception {
+ if (doc == null) {
doc = (CustomerDocument)
- XmlObject.Factory.parse(
- JarUtil.getResourceFromJarasFile("xbean/xmlobject/person.xml"));
+ XmlObject.Factory.parse(
+ JarUtil.getResourceFromJarasFile("xbean/xmlobject/person.xml"));
}
}
- public void testDefaults() throws Throwable
- {
+ @Test
+ public void testDefaults() {
DefaultsDocument doc = DefaultsDocument.Factory.newInstance();
DefaultsDocument.Defaults defs = doc.addNewDefaults();
- Assert.assertEquals(783, defs.getCool()); // this is the default value
+ assertEquals(783, defs.getCool()); // this is the default value
}
- public void testSourceName() throws Throwable
- {
+ @Test
+ public void testSourceName() throws IOException, XmlException {
String name = DefaultsDocument.type.getSourceName();
- Assert.assertEquals("defaults.xsd", name);
+ assertEquals("defaults.xsd", name);
InputStream str = XmlBeans.getContextTypeLoader().getSourceAsStream("defaults.xsd");
SchemaDocument doc = SchemaDocument.Factory.parse(str);
- Assert.assertTrue(doc.validate());
+ assertTrue(doc.validate());
}
- public void testRead() throws Throwable
- {
+ @Test
+ public void testRead() throws Exception {
ensureDoc();
// Move from the root to the root customer element
Person person = doc.getCustomer();
- Assert.assertEquals("Howdy", person.getFirstname());
- Assert.assertEquals(4, person.sizeOfNumberArray());
- Assert.assertEquals(436, person.getNumberArray(0));
- Assert.assertEquals(123, person.getNumberArray(1));
- Assert.assertEquals(44, person.getNumberArray(2));
- Assert.assertEquals(933, person.getNumberArray(3));
- Assert.assertEquals(2, person.sizeOfBirthdayArray());
- Assert.assertEquals(new XmlCalendar("1998-08-26Z"),
+ assertEquals("Howdy", person.getFirstname());
+ assertEquals(4, person.sizeOfNumberArray());
+ assertEquals(436, person.getNumberArray(0));
+ assertEquals(123, person.getNumberArray(1));
+ assertEquals(44, person.getNumberArray(2));
+ assertEquals(933, person.getNumberArray(3));
+ assertEquals(2, person.sizeOfBirthdayArray());
+ assertEquals(new XmlCalendar("1998-08-26Z"),
person.getBirthdayArray(0));
- Assert.assertEquals(new XmlCalendar("2000-08-06-08:00"),
+ assertEquals(new XmlCalendar("2000-08-06-08:00"),
person.getBirthdayArray(1));
Person.Gender.Enum g = person.getGender();
- Assert.assertEquals(Person.Gender.MALE, g);
+ assertEquals(Person.Gender.MALE, g);
- Assert.assertEquals("EGIQTWYZJ", new String(person.getHex()));
- Assert.assertEquals("This string is base64Binary encoded!",
+ assertEquals("EGIQTWYZJ", new String(person.getHex()));
+ assertEquals("This string is base64Binary encoded!",
new String(person.getBase64()));
- Assert.assertEquals("GGIQTWYGG", new String(person.getHexAtt()));
- Assert.assertEquals("This string is base64Binary encoded!",
+ assertEquals("GGIQTWYGG", new String(person.getHexAtt()));
+ assertEquals("This string is base64Binary encoded!",
new String(person.getBase64Att()));
- Assert.assertEquals("{some_uri}localname", person.getQnameAtt().toString());
- Assert.assertEquals("{http://openuri.org/xstypes/test}openuri_org_localname", person.getQname().toString());
+ assertEquals("{some_uri}localname", person.getQnameAtt().toString());
+ assertEquals("{http://openuri.org/xstypes/test}openuri_org_localname", person.getQname().toString());
- //Assert.assertEquals("http://dmoz.org/World/Fran\u00e7ais/", person.getAnyuriAtt().toString());
- Assert.assertEquals("http://3space.org/space%20space/", person.getAnyuri().toString());
+ //assertEquals("http://dmoz.org/World/Fran\u00e7ais/", person.getAnyuriAtt().toString());
+ assertEquals("http://3space.org/space%20space/", person.getAnyuri().toString());
//RuntimeException: src/xmlstore/org/apache/xmlbeans/impl/store/Splay.java(1537): ns != null && ns.length() > 0 failed
- //Assert.assertEquals("JPEG", person.getNotationAtt().toString());
- //Assert.assertEquals("GIF", person.getNotation().toString());
+ //assertEquals("JPEG", person.getNotationAtt().toString());
+ //assertEquals("GIF", person.getNotation().toString());
}
- public void testWriteRead() throws Throwable
- {
+ @Test
+ public void testWriteRead() throws Exception {
ensureDoc();
// Move from the root to the root customer element
Person person = doc.getCustomer();
person.setFirstname("George");
- Assert.assertEquals("George", person.getFirstname());
+ assertEquals("George", person.getFirstname());
person.setHex("hex encoding".getBytes());
- Assert.assertEquals("hex encoding", new String(person.getHex()));
+ assertEquals("hex encoding", new String(person.getHex()));
person.setBase64("base64 encoded".getBytes());
- Assert.assertEquals("base64 encoded",
+ assertEquals("base64 encoded",
new String(person.getBase64()));
person.setHexAtt("hex encoding in attributes".getBytes());
- Assert.assertEquals("hex encoding in attributes",
+ assertEquals("hex encoding in attributes",
new String(person.getHexAtt()));
person.setBase64Att("This string is base64Binary encoded!".getBytes());
- Assert.assertEquals("This string is base64Binary encoded!",
+ assertEquals("This string is base64Binary encoded!",
new String(person.getBase64Att()));
person.setAnyuri("a.c:7001");
- Assert.assertEquals("a.c:7001", person.getAnyuri());
+ assertEquals("a.c:7001", person.getAnyuri());
person.setAnyuriAtt("b.d:7002");
- Assert.assertEquals("b.d:7002", person.getAnyuriAtt());
+ assertEquals("b.d:7002", person.getAnyuriAtt());
person.setQnameAtt(new QName("aaa","bbb"));
- Assert.assertEquals("{aaa}bbb", person.getQnameAtt().toString());
+ assertEquals("{aaa}bbb", person.getQnameAtt().toString());
person.setQname(new QName("ddd","eee"));
- Assert.assertEquals("{ddd}eee", person.getQname().toString());
+ assertEquals("{ddd}eee", person.getQname().toString());
//Exception: src/xmlstore/org/apache/xmlbeans/impl/store/Type.java(189): user == _user failed
// person.setAnyuriAtt(URI.create("b.d:7002"));
-// Assert.assertEquals("b.d:7002", person.getAnyuriAtt().toString());
+// assertEquals("b.d:7002", person.getAnyuriAtt().toString());
//XmlNOTATION notation = (XmlNOTATION)Person.Notation.type.createNode();
//notation.setValue("JPEG");
//person.setNotation( notation );
- //Assert.assertEquals("JPEG", person.getNotation().toString());
+ //assertEquals("JPEG", person.getNotation().toString());
//XmlNOTATION notationAtt = (XmlNOTATION)Person.NotationAtt.type.createNode();
//notationAtt.setValue("GIF");
//person.setNotationAtt( notationAtt );
//person.setNotationAtt(notation);
- //Assert.assertEquals("GIF", person.getNotationAtt().toString());
+ //assertEquals("GIF", person.getNotationAtt().toString());
}
- public void testStoreWrite() throws Throwable
- {
+ @Test
+ public void testStoreWrite() throws Exception {
ensureDoc();
// Move from the root to the root customer element
Person person = doc.getCustomer();
@@ -178,36 +164,36 @@ public class SchemaTypesTests extends Te
person.setFirstname("George");
xmlobj = person.xgetFirstname();
xmlcurs = xmlobj.newCursor();
- Assert.assertEquals("George", xmlcurs.getTextValue() );
+ assertEquals("George", xmlcurs.getTextValue() );
person.setQnameAtt( new QName("http://ggg.com","hhh") );
xmlobj = person.xgetQnameAtt();
xmlcurs = xmlobj.newCursor();
- Assert.assertEquals("ggg:hhh", xmlcurs.getTextValue() );
+ assertEquals("ggg:hhh", xmlcurs.getTextValue() );
person.setQname( new QName("http://ggg.com/gggAgain","kkk") );
xmlobj = person.xgetQname();
xmlcurs = xmlobj.newCursor();
- Assert.assertEquals("ggg1:kkk", xmlcurs.getTextValue() );
+ assertEquals("ggg1:kkk", xmlcurs.getTextValue() );
person.setAnyuri( "crossgain.com" );
xmlobj = person.xgetAnyuri();
xmlcurs = xmlobj.newCursor();
- Assert.assertEquals("crossgain.com", xmlcurs.getTextValue() );
+ assertEquals("crossgain.com", xmlcurs.getTextValue() );
person.setAnyuriAtt( "www.crossgain.com" );
xmlobj = person.xgetAnyuriAtt();
xmlcurs = xmlobj.newCursor();
- Assert.assertEquals("www.crossgain.com", xmlcurs.getTextValue() );
+ assertEquals("www.crossgain.com", xmlcurs.getTextValue() );
//person.setNotation("GIF");
//xmlobj = person.getNotation();
//xmlcurs = xmlobj.newXmlCursor();
- //Assert.assertEquals("GIF", xmlcurs.getText() );
+ //assertEquals("GIF", xmlcurs.getText() );
//person.setNotationAtt("JPEGu");
//xmlobj = person.xgetNotationAtt();
//xmlcurs = xmlobj.newXmlCursor();
- //Assert.assertEquals("JPEG", xmlcurs.getText() );
+ //assertEquals("JPEG", xmlcurs.getText() );
}
}
Modified: xmlbeans/trunk/test/src/xmlobject/schematypes/detailed/ListAndUnionTests.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/xmlobject/schematypes/detailed/ListAndUnionTests.java?rev=1851656&r1=1851655&r2=1851656&view=diff
==============================================================================
--- xmlbeans/trunk/test/src/xmlobject/schematypes/detailed/ListAndUnionTests.java (original)
+++ xmlbeans/trunk/test/src/xmlobject/schematypes/detailed/ListAndUnionTests.java Fri Jan 18 23:08:44 2019
@@ -14,119 +14,108 @@
*/
package xmlobject.schematypes.detailed;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.framework.Assert;
+import org.junit.Assert;
+import org.apache.xmlbeans.*;
+import org.junit.Test;
+import org.openuri.lut.DateOrDateTime;
+import org.openuri.lut.IncidentReportsDocument;
import org.openuri.lut.ListsDocument;
import org.openuri.lut.UnionsDocument;
-import org.openuri.lut.IncidentReportsDocument;
-import org.openuri.lut.DateOrDateTime;
-import java.util.List;
+import java.math.BigInteger;
import java.util.Arrays;
import java.util.Calendar;
-import java.math.BigInteger;
+import java.util.List;
-import org.apache.xmlbeans.GDate;
-import org.apache.xmlbeans.SimpleValue;
-import org.apache.xmlbeans.XmlObject;
-import org.apache.xmlbeans.SchemaType;
-import org.apache.xmlbeans.XmlDate;
-import org.apache.xmlbeans.XmlDateTime;
-import org.apache.xmlbeans.XmlCalendar;
-
-public class ListAndUnionTests extends TestCase
-{
- public ListAndUnionTests(String name) { super(name); }
- public static Test suite() { return new TestSuite(ListAndUnionTests.class); }
+import static org.junit.Assert.assertEquals;
- public void testListGetters() throws Exception
- {
+public class ListAndUnionTests {
+ @Test
+ public void testListGetters() throws Exception {
ListsDocument lists = ListsDocument.Factory.parse(
- "<lut:lists xmlns:lut='http://openuri.org/lut'><lut:int-list>2 4 8 16 32</lut:int-list><lut:nni-list>unbounded 3 unbounded 6</lut:nni-list></lut:lists>");
+ "<lut:lists xmlns:lut='http://openuri.org/lut'><lut:int-list>2 4 8 16 32</lut:int-list><lut:nni-list>unbounded 3 unbounded 6</lut:nni-list></lut:lists>");
List intList = lists.getLists().getIntList();
- Assert.assertEquals(new Integer(2), intList.get(0));
- Assert.assertEquals(new Integer(4), intList.get(1));
- Assert.assertEquals(new Integer(8), intList.get(2));
- Assert.assertEquals(new Integer(16), intList.get(3));
- Assert.assertEquals(new Integer(32), intList.get(4));
- Assert.assertEquals(5, intList.size());
+ assertEquals(2, intList.get(0));
+ assertEquals(4, intList.get(1));
+ assertEquals(8, intList.get(2));
+ assertEquals(16, intList.get(3));
+ assertEquals(32, intList.get(4));
+ assertEquals(5, intList.size());
List nniList = lists.getLists().getNniList();
- Assert.assertEquals("unbounded", nniList.get(0));
- Assert.assertEquals(BigInteger.valueOf(3), nniList.get(1));
- Assert.assertEquals("unbounded", nniList.get(2));
- Assert.assertEquals(BigInteger.valueOf(6), nniList.get(3));
- Assert.assertEquals(4, nniList.size());
+ assertEquals("unbounded", nniList.get(0));
+ assertEquals(BigInteger.valueOf(3), nniList.get(1));
+ assertEquals("unbounded", nniList.get(2));
+ assertEquals(BigInteger.valueOf(6), nniList.get(3));
+ assertEquals(4, nniList.size());
}
- public void testListSetters() throws Exception
- {
+ @Test
+ public void testListSetters() throws Exception {
ListsDocument doc = ListsDocument.Factory.newInstance();
ListsDocument.Lists lists = doc.addNewLists();
- lists.setIntList(Arrays.asList(new Object[] { new Integer(4), new Integer(18) }));
- lists.setNniList(Arrays.asList(new Object[] { BigInteger.valueOf(1), BigInteger.valueOf(2), "unbounded" }));
+ lists.setIntList(Arrays.asList(4, 18));
+ lists.setNniList(Arrays.asList(BigInteger.valueOf(1), BigInteger.valueOf(2), "unbounded"));
String xtext = doc.xmlText();
ListsDocument docrt = ListsDocument.Factory.parse(xtext);
List intList = docrt.getLists().getIntList();
- Assert.assertEquals(new Integer(4), intList.get(0));
- Assert.assertEquals(new Integer(18), intList.get(1));
- Assert.assertEquals(2, intList.size());
+ assertEquals(4, intList.get(0));
+ assertEquals(18, intList.get(1));
+ assertEquals(2, intList.size());
List nniList = docrt.getLists().getNniList();
- Assert.assertEquals(BigInteger.valueOf(1), nniList.get(0));
- Assert.assertEquals(BigInteger.valueOf(2), nniList.get(1));
- Assert.assertEquals("unbounded", nniList.get(2));
- Assert.assertEquals(3, nniList.size());
+ assertEquals(BigInteger.valueOf(1), nniList.get(0));
+ assertEquals(BigInteger.valueOf(2), nniList.get(1));
+ assertEquals("unbounded", nniList.get(2));
+ assertEquals(3, nniList.size());
}
- public void testUnionGetters() throws Exception
- {
+ @Test
+ public void testUnionGetters() throws Exception {
UnionsDocument unions = UnionsDocument.Factory.parse(
- "<lut:unions xmlns:lut='http://openuri.org/lut'><lut:nni>unbounded</lut:nni><lut:sizes>2 3 5 7 11</lut:sizes></lut:unions>");
+ "<lut:unions xmlns:lut='http://openuri.org/lut'><lut:nni>unbounded</lut:nni><lut:sizes>2 3 5 7 11</lut:sizes></lut:unions>");
- Assert.assertEquals("unbounded", unions.getUnions().getNni());
+ assertEquals("unbounded", unions.getUnions().getNni());
Assert.assertTrue(unions.getUnions().getSizes() instanceof List);
- List sizes = (List)unions.getUnions().getSizes();
- Assert.assertEquals(new Integer(2), sizes.get(0));
- Assert.assertEquals(new Integer(3), sizes.get(1));
- Assert.assertEquals(new Integer(5), sizes.get(2));
- Assert.assertEquals(new Integer(7), sizes.get(3));
- Assert.assertEquals(new Integer(11), sizes.get(4));
- Assert.assertEquals(5, sizes.size());
+ List sizes = (List) unions.getUnions().getSizes();
+ assertEquals(2, sizes.get(0));
+ assertEquals(3, sizes.get(1));
+ assertEquals(5, sizes.get(2));
+ assertEquals(7, sizes.get(3));
+ assertEquals(11, sizes.get(4));
+ assertEquals(5, sizes.size());
UnionsDocument unions2 = UnionsDocument.Factory.parse(
- "<lut:unions xmlns:lut='http://openuri.org/lut'><lut:nni>37</lut:nni><lut:sizes>all</lut:sizes></lut:unions>");
+ "<lut:unions xmlns:lut='http://openuri.org/lut'><lut:nni>37</lut:nni><lut:sizes>all</lut:sizes></lut:unions>");
- Assert.assertEquals(BigInteger.valueOf(37), unions2.getUnions().getNni());
- Assert.assertEquals("all", unions2.getUnions().getSizes());
+ assertEquals(BigInteger.valueOf(37), unions2.getUnions().getNni());
+ assertEquals("all", unions2.getUnions().getSizes());
}
- public void testUnionSetters() throws Exception
- {
+ @Test
+ public void testUnionSetters() throws Exception {
// create a document
UnionsDocument doc = UnionsDocument.Factory.newInstance();
UnionsDocument.Unions unions = doc.addNewUnions();
unions.setNni("unbounded");
- unions.setSizes(Arrays.asList(new Object[] { new Integer(5), new Integer(22) }));
+ unions.setSizes(Arrays.asList(5, 22));
// round trip to s text
String xtext = doc.xmlText();
UnionsDocument docrt = UnionsDocument.Factory.parse(xtext);
// verify contents
- Assert.assertEquals("unbounded", docrt.getUnions().getNni());
- List sizes = (List)docrt.getUnions().getSizes();
- Assert.assertEquals(new Integer(5), sizes.get(0));
- Assert.assertEquals(new Integer(22), sizes.get(1));
- Assert.assertEquals(2, sizes.size());
+ assertEquals("unbounded", docrt.getUnions().getNni());
+ List sizes = (List) docrt.getUnions().getSizes();
+ assertEquals(5, sizes.get(0));
+ assertEquals(22, sizes.get(1));
+ assertEquals(2, sizes.size());
// change the original document
- unions.setNni(new Integer(11));
+ unions.setNni(11);
unions.setSizes("unknown");
// round trip it again
@@ -134,14 +123,14 @@ public class ListAndUnionTests extends T
docrt = UnionsDocument.Factory.parse(xtext);
// verify contents again
- Assert.assertEquals(BigInteger.valueOf(11), docrt.getUnions().getNni());
- Assert.assertEquals("unknown", docrt.getUnions().getSizes());
+ assertEquals(BigInteger.valueOf(11), docrt.getUnions().getNni());
+ assertEquals("unknown", docrt.getUnions().getSizes());
}
- public void testUnionArray() throws Exception
- {
+ @Test
+ public void testUnionArray() throws Exception {
IncidentReportsDocument doc = IncidentReportsDocument.Factory.parse(
- "<lut:incident-reports xmlns:lut='http://openuri.org/lut'>" +
+ "<lut:incident-reports xmlns:lut='http://openuri.org/lut'>" +
"<lut:when>2001-08-06T03:34:00</lut:when>" +
"<lut:when>2002-01-04</lut:when>" +
"<lut:when>2002-08-26T23:10:00</lut:when>" +
@@ -149,21 +138,20 @@ public class ListAndUnionTests extends T
IncidentReportsDocument.IncidentReports reports = doc.getIncidentReports();
DateOrDateTime[] dt = reports.xgetWhenArray();
Calendar[] gd = reports.getWhenArray();
- Assert.assertEquals(3, dt.length);
- Assert.assertEquals(3, gd.length);
- for (int i = 0; i < 3; i++)
- {
- Assert.assertEquals(((SimpleValue)dt[i]).getGDateValue(), new GDate(gd[i]));
- Assert.assertEquals(gd[i], dt[i].getObjectValue());
+ assertEquals(3, dt.length);
+ assertEquals(3, gd.length);
+ for (int i = 0; i < 3; i++) {
+ assertEquals(((SimpleValue) dt[i]).getGDateValue(), new GDate(gd[i]));
+ assertEquals(gd[i], dt[i].getObjectValue());
}
- Assert.assertEquals(new XmlCalendar("2001-08-06T03:34:00"), gd[0]);
- Assert.assertEquals(new XmlCalendar("2002-01-04"), gd[1]);
- Assert.assertEquals(new XmlCalendar("2002-08-26T23:10:00"), gd[2]);
-
- Assert.assertEquals(XmlDateTime.type, dt[0].instanceType());
- Assert.assertEquals(XmlDate.type, dt[1].instanceType());
- Assert.assertEquals(XmlDateTime.type, dt[2].instanceType());
+ assertEquals(new XmlCalendar("2001-08-06T03:34:00"), gd[0]);
+ assertEquals(new XmlCalendar("2002-01-04"), gd[1]);
+ assertEquals(new XmlCalendar("2002-08-26T23:10:00"), gd[2]);
+
+ assertEquals(XmlDateTime.type, dt[0].instanceType());
+ assertEquals(XmlDate.type, dt[1].instanceType());
+ assertEquals(XmlDateTime.type, dt[2].instanceType());
reports.setWhenArray(0, new XmlCalendar("1980-04-18"));
reports.setWhenArray(1, new XmlCalendar("1970-12-20T04:33:00"));
@@ -171,13 +159,13 @@ public class ListAndUnionTests extends T
dt = reports.xgetWhenArray();
gd = reports.getWhenArray();
- Assert.assertEquals(new XmlCalendar("1980-04-18"), gd[0]);
- Assert.assertEquals(new XmlCalendar("1970-12-20T04:33:00"), gd[1]);
- Assert.assertEquals(new XmlCalendar("2002-08-26T23:10:00"), gd[2]);
-
- Assert.assertEquals(XmlDate.type, dt[0].instanceType());
- Assert.assertEquals(XmlDateTime.type, dt[1].instanceType());
- Assert.assertEquals(XmlDateTime.type, dt[2].instanceType());
+ assertEquals(new XmlCalendar("1980-04-18"), gd[0]);
+ assertEquals(new XmlCalendar("1970-12-20T04:33:00"), gd[1]);
+ assertEquals(new XmlCalendar("2002-08-26T23:10:00"), gd[2]);
+
+ assertEquals(XmlDate.type, dt[0].instanceType());
+ assertEquals(XmlDateTime.type, dt[1].instanceType());
+ assertEquals(XmlDateTime.type, dt[2].instanceType());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org