8024427: Missing java.time.chrono serialization tests
Summary: Add tests and cleanup existing serialization tests
Reviewed-by: sherman
--- a/jdk/src/share/classes/java/time/temporal/ValueRange.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/src/share/classes/java/time/temporal/ValueRange.java Thu Oct 03 15:16:14 2013 -0400
@@ -61,6 +61,7 @@
*/
package java.time.temporal;
+import java.io.InvalidObjectException;
import java.io.Serializable;
import java.time.DateTimeException;
@@ -337,6 +338,21 @@
}
}
+ /**
+ * Return the ValueRange for the serialized values.
+ * The values are validated according to the constraints of the {@link #of}
+ * factory method.
+ * @return the ValueRange for the serialized fields
+ * @throws InvalidObjectException if the serialized object has invalid values
+ */
+ private Object readResolve() throws InvalidObjectException {
+ try {
+ return of(minSmallest, minLargest, maxSmallest, maxLargest);
+ } catch (IllegalArgumentException iae) {
+ throw new InvalidObjectException("Invalid serialized ValueRange: " + iae.getMessage());
+ }
+ }
+
//-----------------------------------------------------------------------
/**
* Checks if this range is equal to another range.
--- a/jdk/test/java/time/tck/java/time/AbstractTCKTest.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/AbstractTCKTest.java Thu Oct 03 15:16:14 2013 -0400
@@ -68,6 +68,8 @@
import java.io.ObjectStreamConstants;
import java.io.Serializable;
import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.Formatter;
/**
* Base test class.
@@ -131,10 +133,10 @@
assertEquals(dis.readByte(), ObjectStreamConstants.TC_NULL); // no superclasses
if (expectedBytes.length < 256) {
assertEquals(dis.readByte(), ObjectStreamConstants.TC_BLOCKDATA);
- assertEquals(dis.readUnsignedByte(), expectedBytes.length);
+ assertEquals(dis.readUnsignedByte(), expectedBytes.length, "blockdata length incorrect");
} else {
assertEquals(dis.readByte(), ObjectStreamConstants.TC_BLOCKDATALONG);
- assertEquals(dis.readInt(), expectedBytes.length);
+ assertEquals(dis.readInt(), expectedBytes.length, "blockdatalong length incorrect");
}
byte[] input = new byte[expectedBytes.length];
dis.readFully(input);
@@ -162,4 +164,33 @@
}
}
+
+ /**
+ * Utility method to dump a byte array in a java syntax.
+ * @param bytes and array of bytes
+ * @return a string containing the bytes formatted in java syntax
+ */
+ protected static String dumpSerialStream(byte[] bytes) {
+ StringBuilder sb = new StringBuilder(bytes.length * 5);
+ Formatter fmt = new Formatter(sb);
+ fmt.format(" byte[] bytes = {" );
+ final int linelen = 10;
+ for (int i = 0; i < bytes.length; i++) {
+ if (i % linelen == 0) {
+ fmt.format("%n ");
+ }
+ fmt.format(" %3d,", bytes[i] & 0xff);
+ if ((i % linelen) == (linelen-1) || i == bytes.length - 1) {
+ fmt.format(" /*");
+ int s = i / linelen * linelen;
+ int k = i % linelen;
+ for (int j = 0; j <= k && s + j < bytes.length; j++) {
+ fmt.format(" %c", bytes[s + j] & 0xff);
+ }
+ fmt.format(" */");
+ }
+ }
+ fmt.format("%n };%n");
+ return sb.toString();
+ }
}
--- a/jdk/test/java/time/tck/java/time/TCKClock_Fixed.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/TCKClock_Fixed.java Thu Oct 03 15:16:14 2013 -0400
@@ -80,12 +80,6 @@
private static final ZoneId PARIS = ZoneId.of("Europe/Paris");
private static final Instant INSTANT = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500).atZone(ZoneOffset.ofHours(2)).toInstant();
- //-----------------------------------------------------------------------
- public void test_isSerializable() throws IOException, ClassNotFoundException {
- assertSerializable(Clock.fixed(INSTANT, ZoneOffset.UTC));
- assertSerializable(Clock.fixed(INSTANT, PARIS));
- }
-
//-------------------------------------------------------------------------
public void test_fixed_InstantZoneId() {
Clock test = Clock.fixed(INSTANT, PARIS);
--- a/jdk/test/java/time/tck/java/time/TCKClock_Offset.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/TCKClock_Offset.java Thu Oct 03 15:16:14 2013 -0400
@@ -62,7 +62,6 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertSame;
-import java.io.IOException;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
@@ -84,11 +83,6 @@
private static final Duration OFFSET = Duration.ofSeconds(2);
//-----------------------------------------------------------------------
- public void test_isSerializable() throws IOException, ClassNotFoundException {
- assertSerializable(Clock.offset(Clock.system(PARIS), OFFSET));
- }
-
- //-----------------------------------------------------------------------
public void test_offset_ClockDuration() {
Clock test = Clock.offset(Clock.fixed(INSTANT, PARIS), OFFSET);
//System.out.println(test.instant());
--- a/jdk/test/java/time/tck/java/time/TCKClock_System.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/TCKClock_System.java Thu Oct 03 15:16:14 2013 -0400
@@ -62,7 +62,6 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
-import java.io.IOException;
import java.time.Clock;
import java.time.Instant;
import java.time.ZoneId;
@@ -80,13 +79,6 @@
private static final ZoneId PARIS = ZoneId.of("Europe/Paris");
//-----------------------------------------------------------------------
- public void test_isSerializable() throws IOException, ClassNotFoundException {
- assertSerializable(Clock.systemUTC());
- assertSerializable(Clock.systemDefaultZone());
- assertSerializable(Clock.system(PARIS));
- }
-
- //-----------------------------------------------------------------------
public void test_instant() {
Clock system = Clock.systemUTC();
assertEquals(system.getZone(), ZoneOffset.UTC);
--- a/jdk/test/java/time/tck/java/time/TCKClock_Tick.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/TCKClock_Tick.java Thu Oct 03 15:16:14 2013 -0400
@@ -62,7 +62,6 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertSame;
-import java.io.IOException;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
@@ -81,16 +80,7 @@
private static final ZoneId MOSCOW = ZoneId.of("Europe/Moscow");
private static final ZoneId PARIS = ZoneId.of("Europe/Paris");
- private static final Duration AMOUNT = Duration.ofSeconds(2);
private static final ZonedDateTime ZDT = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500).atZone(ZoneOffset.ofHours(2));
- private static final Instant INSTANT = ZDT.toInstant();
-
- //-----------------------------------------------------------------------
- public void test_isSerializable() throws IOException, ClassNotFoundException {
- assertSerializable(Clock.tickSeconds(PARIS));
- assertSerializable(Clock.tickMinutes(MOSCOW));
- assertSerializable(Clock.tick(Clock.fixed(INSTANT, PARIS), AMOUNT));
- }
//-----------------------------------------------------------------------
public void test_tick_ClockDuration_250millis() {
--- a/jdk/test/java/time/tck/java/time/chrono/CopticDate.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/chrono/CopticDate.java Thu Oct 03 15:16:14 2013 -0400
@@ -354,4 +354,27 @@
.append(dom < 10 ? "-0" : "-").append(dom);
return buf.toString();
}
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof CopticDate) {
+ CopticDate cd = (CopticDate)obj;
+ if (this.prolepticYear == cd.prolepticYear &&
+ this.month == cd.month &&
+ this.day == cd.day) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ long epDay = toEpochDay();
+ return getChronology().hashCode() ^ ((int) (epDay ^ (epDay >>> 32)));
+ }
+
}
--- a/jdk/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java Thu Oct 03 15:16:14 2013 -0400
@@ -321,24 +321,6 @@
}
//-----------------------------------------------------------------------
- // Test Serialization of ISO via chrono API
- //-----------------------------------------------------------------------
- @Test( dataProvider="calendars")
- public void test_ChronoZonedDateTimeSerialization(Chronology chrono) throws Exception {
- ZonedDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23"));
- ChronoZonedDateTime<?> orginal = chrono.date(ref).atTime(ref.toLocalTime()).atZone(ref.getZone());
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(orginal);
- out.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream in = new ObjectInputStream(bais);
- @SuppressWarnings("unchecked")
- ChronoZonedDateTime<?> ser = (ChronoZonedDateTime<?>) in.readObject();
- assertEquals(ser, orginal, "deserialized date is wrong");
- }
-
- //-----------------------------------------------------------------------
@Test(dataProvider="calendars")
public void test_from_TemporalAccessor(Chronology chrono) {
ZonedDateTime refDateTime = ZonedDateTime.of(2013, 1, 1, 12, 30, 0, 0, ZoneId.of("Europe/Paris"));
--- a/jdk/test/java/time/tck/java/time/chrono/TCKChronology.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/chrono/TCKChronology.java Thu Oct 03 15:16:14 2013 -0400
@@ -64,7 +64,6 @@
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
-import java.util.Locale;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
@@ -338,20 +337,4 @@
Chronology chrono = Chronology.of("FooFoo");
}
- //-----------------------------------------------------------------------
- // serialization; serialize and check each calendar system
- //-----------------------------------------------------------------------
- @Test(dataProvider = "calendarNameAndType")
- public void test_chronoSerializationSingleton(String id, String _calendarType) throws Exception {
- Chronology original = Chronology.of(id);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(original);
- out.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream in = new ObjectInputStream(bais);
- Chronology ser = (Chronology) in.readObject();
- assertEquals(ser, original, "Deserialized Chronology is not correct");
- }
-
}
--- a/jdk/test/java/time/tck/java/time/chrono/TCKTestServiceLoader.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/chrono/TCKTestServiceLoader.java Thu Oct 03 15:16:14 2013 -0400
@@ -60,10 +60,6 @@
import static org.testng.Assert.assertEquals;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.time.LocalDate;
import java.time.chrono.ChronoLocalDate;
import java.time.chrono.Chronology;
@@ -78,29 +74,11 @@
public class TCKTestServiceLoader {
@Test
- public void test_CopticServiceLoader() {
+ public void test_TestServiceLoader() {
Chronology chrono = Chronology.of("Coptic");
ChronoLocalDate copticDate = chrono.date(1729, 4, 27);
LocalDate ld = LocalDate.from(copticDate);
assertEquals(ld, LocalDate.of(2013, 1, 5), "CopticDate does not match LocalDate");
}
-
- //-----------------------------------------------------------------------
- // Test Serialization of Loaded Coptic Calendar
- //-----------------------------------------------------------------------
- @Test
- public void test_ChronoSerialization() throws Exception {
- Chronology chrono = Chronology.of("Coptic");
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(chrono);
- out.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-
- ObjectInputStream in = new ObjectInputStream(bais);
- @SuppressWarnings("unchecked")
- Chronology ser = (Chronology) in.readObject();
- assertEquals(ser, chrono, "deserialized Chronology is wrong");
- }
}
--- a/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronoLocalDate.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.chrono.serial;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.time.LocalDate;
-import java.time.chrono.*;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * Test assertions that must be true for all built-in chronologies.
- */
-@Test
-public class TCKChronoLocalDate {
-
- //-----------------------------------------------------------------------
- // regular data factory for names and descriptions of available calendars
- //-----------------------------------------------------------------------
- @DataProvider(name = "calendars")
- Chronology[][] data_of_calendars() {
- return new Chronology[][]{
- {HijrahChronology.INSTANCE},
- {IsoChronology.INSTANCE},
- {JapaneseChronology.INSTANCE},
- {MinguoChronology.INSTANCE},
- {ThaiBuddhistChronology.INSTANCE}};
- }
-
-
- //-----------------------------------------------------------------------
- // Test Serialization of Calendars
- //-----------------------------------------------------------------------
- @Test( dataProvider="calendars")
- public void test_ChronoSerialization(Chronology chrono) throws Exception {
- LocalDate ref = LocalDate.of(2013, 1, 5);
- ChronoLocalDate orginal = chrono.date(ref);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(orginal);
- out.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream in = new ObjectInputStream(bais);
- @SuppressWarnings("unchecked")
- ChronoLocalDate ser = (ChronoLocalDate) in.readObject();
- assertEquals(ser, orginal, "deserialized date is wrong");
- }
-
- //-----------------------------------------------------------------------
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronoLocalDateSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.chrono.serial;
+
+import static java.time.temporal.ChronoField.DAY_OF_MONTH;
+import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.YEAR;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.ObjectStreamConstants;
+import java.time.chrono.ChronoLocalDate;
+import java.time.chrono.HijrahChronology;
+import java.time.chrono.HijrahDate;
+import java.time.chrono.JapaneseDate;
+import java.time.chrono.JapaneseEra;
+import java.time.chrono.MinguoDate;
+import java.time.chrono.ThaiBuddhistDate;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+
+
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Test serialization of built-in chronologies.
+ */
+@Test
+public class TCKChronoLocalDateSerialization extends AbstractTCKTest {
+
+ static final int CHRONO_TYPE = 1; // java.time.chrono.Ser.CHRONO_TYPE
+ static final int JAPANESE_DATE_TYPE = 4; // java.time.chrono.Ser.JAPANESE_DATE_TYPE
+ static final int HIJRAH_DATE_TYPE = 6; // java.time.chrono.Ser.HIJRAH_DATE_TYPE
+ static final int MINGUO_DATE_TYPE = 7; // java.time.chrono.Ser.MINGUO_DATE_TYPE
+ static final int THAIBUDDHIST_DATE_TYPE = 8; // java.time.chrono.Ser.THAIBUDDHIST_DATE_TYPE
+
+ //-----------------------------------------------------------------------
+ // Regular data factory for names and descriptions of available calendars
+ //-----------------------------------------------------------------------
+ @DataProvider(name = "calendars")
+ Object[][] data_of_calendars() {
+ return new Object[][]{
+ {JapaneseDate.of(JapaneseEra.HEISEI, 25, 01, 05), JAPANESE_DATE_TYPE},
+ {MinguoDate.of(102, 01, 05), MINGUO_DATE_TYPE},
+ {ThaiBuddhistDate.of(2556, 01, 05), THAIBUDDHIST_DATE_TYPE},
+ };
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Test Serialization of Calendars
+ //-----------------------------------------------------------------------
+ @Test( dataProvider="calendars")
+ public void test_ChronoSerialization(ChronoLocalDate date, int dateType) throws Exception {
+ assertSerializable(date);
+ }
+
+ //-----------------------------------------------------------------------
+ // Test that serialization produces exact sequence of bytes
+ //-----------------------------------------------------------------------
+ @Test(dataProvider="calendars")
+ private void test_serialization_format(ChronoLocalDate date, int dateType) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(dateType);
+ dos.writeInt(date.get(YEAR));
+ dos.writeByte(date.get(MONTH_OF_YEAR));
+ dos.writeByte(date.get(DAY_OF_MONTH));
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(date, bytes);
+ }
+
+ //-----------------------------------------------------------------------
+ // Test HijrajDate serialization is a type, Chronology, year, month, day
+ //-----------------------------------------------------------------------
+ @Test()
+ public void test_hijrahSerialization_format() throws Exception {
+ HijrahChronology chrono = HijrahChronology.INSTANCE;
+ HijrahDate date = HijrahDate.of(1433, 10, 29);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ // Expect the type of the HijrahDate in the stream
+ byte[] hijrahDateBytes = new byte[] {HIJRAH_DATE_TYPE};
+
+ // Literal reference to Hijrah-Umalqura Chronology
+ byte[] hijrahChronoBytes = new byte[] {
+ 115, 113, 0, 126, 0, 0, /* p w \u0001 \u0006 s q \u0000 ~ \u0000 \u0000 */
+ 119, 18, 1, 0, 15, 72, 105, 106, 114, 97, /* w \u0012 \u0001 \u0000 \u000f H i j r a */
+ 104, 45, 117, 109, 97, 108, 113, 117, 114, 97, /* h - u m a l q u r a */
+ 120, /* \u001d x */
+ };
+
+ // Build the sequence that represents the data in the stream
+ baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(ObjectStreamConstants.TC_BLOCKDATA);
+ dos.writeByte(6); // 6 bytes follow
+ dos.writeInt(date.get(YEAR));
+ dos.writeByte(date.get(MONTH_OF_YEAR));
+ dos.writeByte(date.get(DAY_OF_MONTH));
+ dos.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA);
+ }
+ byte[] dateBytes = baos.toByteArray();
+
+ assertSerializedBySer(date, hijrahDateBytes, hijrahChronoBytes, dateBytes);
+ }
+}
--- a/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronoLocalDateTime.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.chrono.serial;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.chrono.*;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * Test assertions that must be true for all built-in chronologies.
- */
-@Test
-public class TCKChronoLocalDateTime {
-
- //-----------------------------------------------------------------------
- // regular data factory for available calendars
- //-----------------------------------------------------------------------
- @DataProvider(name = "calendars")
- Chronology[][] data_of_calendars() {
- return new Chronology[][]{
- {HijrahChronology.INSTANCE},
- {IsoChronology.INSTANCE},
- {JapaneseChronology.INSTANCE},
- {MinguoChronology.INSTANCE},
- {ThaiBuddhistChronology.INSTANCE}};
- }
-
- //-----------------------------------------------------------------------
- // Test Serialization ZonedDateTime for each Chronology
- //-----------------------------------------------------------------------
- @Test( dataProvider="calendars")
- public void test_ChronoLocalDateTimeSerialization(Chronology chrono) throws Exception {
- LocalDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3);
- ChronoLocalDateTime<?> orginal = chrono.date(ref).atTime(ref.toLocalTime());
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(orginal);
- out.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream in = new ObjectInputStream(bais);
- ChronoLocalDateTime<?> ser = (ChronoLocalDateTime<?>) in.readObject();
- assertEquals(ser, orginal, "deserialized date is wrong");
- }
-
- //-----------------------------------------------------------------------
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronoLocalDateTimeSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.chrono.serial;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.chrono.ChronoLocalDateTime;
+import java.time.chrono.Chronology;
+import java.time.chrono.HijrahChronology;
+import java.time.chrono.IsoChronology;
+import java.time.chrono.JapaneseChronology;
+import java.time.chrono.MinguoChronology;
+import java.time.chrono.ThaiBuddhistChronology;
+
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Test serialization of ChronoLocalDateTime for all built-in chronologies.
+ */
+@Test
+public class TCKChronoLocalDateTimeSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ // regular data factory for available calendars
+ //-----------------------------------------------------------------------
+ @DataProvider(name = "calendars")
+ Chronology[][] data_of_calendars() {
+ return new Chronology[][]{
+ {HijrahChronology.INSTANCE},
+ {IsoChronology.INSTANCE},
+ {JapaneseChronology.INSTANCE},
+ {MinguoChronology.INSTANCE},
+ {ThaiBuddhistChronology.INSTANCE}};
+ }
+
+ //-----------------------------------------------------------------------
+ // Test Serialization of ChronoLocalDateTime
+ //-----------------------------------------------------------------------
+ @Test(dataProvider="calendars")
+ public void test_ChronoLocalDateTimeSerialization(Chronology chrono) throws Exception {
+ LocalDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3);
+ ChronoLocalDateTime<?> original = chrono.date(ref).atTime(ref.toLocalTime());
+ assertSerializable(original);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronoZonedDateTimeSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.chrono.serial;
+
+import java.time.LocalDate;
+import java.time.ZoneId;
+import java.time.ZonedDateTime;
+import java.time.chrono.ChronoZonedDateTime;
+import java.time.chrono.Chronology;
+import java.time.chrono.HijrahChronology;
+import java.time.chrono.IsoChronology;
+import java.time.chrono.JapaneseChronology;
+import java.time.chrono.MinguoChronology;
+import java.time.chrono.ThaiBuddhistChronology;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Test assertions that must be true for all built-in chronologies.
+ */
+@Test
+public class TCKChronoZonedDateTimeSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ // regular data factory for names and descriptions of available calendars
+ //-----------------------------------------------------------------------
+ @DataProvider(name = "calendars")
+ Chronology[][] data_of_calendars() {
+ return new Chronology[][]{
+ {HijrahChronology.INSTANCE},
+ {IsoChronology.INSTANCE},
+ {JapaneseChronology.INSTANCE},
+ {MinguoChronology.INSTANCE},
+ {ThaiBuddhistChronology.INSTANCE},
+ };
+ }
+
+ //-----------------------------------------------------------------------
+ // Test Serialization of ISO via chrono API
+ //-----------------------------------------------------------------------
+ @Test( dataProvider="calendars")
+ public void test_ChronoZonedDateTimeSerialization(Chronology chrono) throws Exception {
+ ZonedDateTime ref = LocalDate.of(2013, 1, 5).atTime(12, 1, 2, 3).atZone(ZoneId.of("GMT+01:23"));
+ ChronoZonedDateTime<?> original = chrono.date(ref).atTime(ref.toLocalTime()).atZone(ref.getZone());
+ assertSerializable(original);
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronologySerialization.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/chrono/serial/TCKChronologySerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -56,13 +56,9 @@
*/
package tck.java.time.chrono.serial;
-import static org.testng.Assert.assertEquals;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.PrintStream;
import java.time.chrono.Chronology;
import java.time.chrono.HijrahChronology;
import java.time.chrono.IsoChronology;
@@ -73,11 +69,15 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
@Test
-public class TCKChronologySerialization {
+public class TCKChronologySerialization extends AbstractTCKTest {
+
+ static final int CHRONO_TYPE = 1; // java.time.chrono.Ser.CHRONO_TYPE
//-----------------------------------------------------------------------
- // regular data factory for names and descriptions of available calendars
+ // Regular data factory for available calendars
//-----------------------------------------------------------------------
@DataProvider(name = "calendars")
Chronology[][] data_of_calendars() {
@@ -93,44 +93,22 @@
// Test Serialization of Calendars
//-----------------------------------------------------------------------
@Test(dataProvider="calendars")
- public void test_ChronoSerialization(Chronology chrono) throws Exception {
- System.out.printf(" ChronoSerialization: %s%n", chrono);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(chrono);
- out.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
-
- ObjectInputStream in = new ObjectInputStream(bais);
- @SuppressWarnings("unchecked")
- Chronology ser = (Chronology) in.readObject();
- assertEquals(ser, chrono, "deserialized Chronology is wrong");
+ public void test_chronoSerialization(Chronology chrono) throws Exception {
+ assertSerializable(chrono);
}
- /**
- * Utility method to dump a byte array in a java syntax.
- * @param bytes and array of bytes
- * @param os the outputstream to receive the output.
- */
- static void dumpSerialStream(byte[] bytes, PrintStream os) {
- os.printf(" byte[] bytes = {" );
- final int linelen = 10;
- for (int i = 0; i < bytes.length; i++) {
- if (i % linelen == 0) {
- os.printf("%n ");
- }
- os.printf(" %3d,", bytes[i] & 0xff);
- if ((i % linelen) == (linelen-1) || i == bytes.length - 1) {
- os.printf(" /*");
- int s = i / linelen * linelen;
- int k = i % linelen;
- for (int j = 0; j <= k && s + j < bytes.length; j++) {
- os.printf(" %c", bytes[s + j] & 0xff);
- }
- os.printf(" */");
- }
+ //-----------------------------------------------------------------------
+ // Test that serialization produces exact sequence of bytes
+ //-----------------------------------------------------------------------
+ @Test(dataProvider="calendars")
+ private void test_serializationBytes(Chronology chrono) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(CHRONO_TYPE);
+ dos.writeUTF(chrono.getId());
}
- os.printf("%n };%n");
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(chrono, bytes);
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/chrono/serial/TCKCopticSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2011-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.chrono.serial;
+
+import java.io.IOException;
+import java.time.chrono.ChronoLocalDate;
+import java.time.chrono.Chronology;
+
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Tests the serialization of ChronoLocalDate using a CopticDate.
+ */
+@Test
+public class TCKCopticSerialization extends AbstractTCKTest {
+
+ @Test
+ public void test_eraSerialization() throws IOException, ClassNotFoundException {
+ Chronology chrono = Chronology.of("Coptic");
+ ChronoLocalDate copticDate = chrono.date(1729, 4, 27);
+ assertSerializable(copticDate);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/chrono/serial/TCKEraSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2011-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.chrono.serial;
+
+
+import static java.time.temporal.ChronoField.DAY_OF_MONTH;
+import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.YEAR;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.time.chrono.ChronoLocalDate;
+import java.time.chrono.Era;
+import java.time.chrono.HijrahEra;
+import java.time.chrono.IsoEra;
+import java.time.chrono.JapaneseEra;
+import java.time.chrono.MinguoEra;
+import java.time.chrono.ThaiBuddhistEra;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Tests the built-in Eras are serializable.
+ * Note that the serialized form of IsoEra, MinguoEra, ThaiBuddhistEra,
+ * and HijrahEra are defined and provided by Enum.
+ * The serialized form of these types are not tested, only that they are
+ * serializable.
+ */
+@Test
+public class TCKEraSerialization extends AbstractTCKTest {
+
+ static final int JAPANESE_ERA_TYPE = 5; // java.time.chrono.Ser.JAPANESE_ERA
+
+
+ //-----------------------------------------------------------------------
+ // Regular data factory for the available Eras
+ //-----------------------------------------------------------------------
+ @DataProvider(name = "Eras")
+ Era[][] data_of_calendars() {
+ return new Era[][] {
+ {HijrahEra.AH},
+ {IsoEra.BCE},
+ {IsoEra.CE},
+ {MinguoEra.BEFORE_ROC},
+ {MinguoEra.ROC},
+ {ThaiBuddhistEra.BEFORE_BE},
+ {ThaiBuddhistEra.BE},
+ };
+ }
+
+ @Test(dataProvider="Eras")
+ public void test_eraSerialization(Era era) throws IOException, ClassNotFoundException {
+ assertSerializableSame(era);
+ }
+
+ //-----------------------------------------------------------------------
+ // Test JapaneseEra serialization produces exact sequence of bytes
+ //-----------------------------------------------------------------------
+ @Test
+ private void test_JapaneseErasSerialization() throws Exception {
+ for (JapaneseEra era : JapaneseEra.values()) {
+ assertSerializableSame(era);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(JAPANESE_ERA_TYPE);
+ dos.writeByte(era.getValue());
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(era, bytes);
+ }
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKClockSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012 Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+
+import java.io.IOException;
+import java.time.Clock;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+
+import org.testng.annotations.Test;
+
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Test system and offset clocks serialization.
+ */
+@Test
+public class TCKClockSerialization extends AbstractTCKTest {
+
+ private static final ZoneId MOSCOW = ZoneId.of("Europe/Moscow");
+ private static final ZoneId PARIS = ZoneId.of("Europe/Paris");
+
+ private static final Duration AMOUNT = Duration.ofSeconds(2);
+ private static final ZonedDateTime ZDT = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500).atZone(ZoneOffset.ofHours(2));
+ private static final Instant INSTANT = ZDT.toInstant();
+
+ //-----------------------------------------------------------------------
+ public void test_systemClockSerializable() throws IOException, ClassNotFoundException {
+ assertSerializable(Clock.systemUTC());
+ assertSerializable(Clock.systemDefaultZone());
+ assertSerializable(Clock.system(PARIS));
+ }
+
+ //-----------------------------------------------------------------------
+ public void test_offsetClockSerializable() throws IOException, ClassNotFoundException {
+ assertSerializable(Clock.offset(Clock.system(PARIS), AMOUNT));
+ }
+
+ //-----------------------------------------------------------------------
+ public void test_tickClockSerializable() throws IOException, ClassNotFoundException {
+ assertSerializable(Clock.tickSeconds(PARIS));
+ assertSerializable(Clock.tickMinutes(MOSCOW));
+ assertSerializable(Clock.tick(Clock.fixed(INSTANT, PARIS), AMOUNT));
+ }
+
+ //-----------------------------------------------------------------------
+ public void test_fixedClockSerializable() throws IOException, ClassNotFoundException {
+ assertSerializable(Clock.fixed(INSTANT, ZoneOffset.UTC));
+ assertSerializable(Clock.fixed(INSTANT, PARIS));
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKDuration.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.time.Duration;
-
-/**
- * Test Duration.
- */
-@Test
-public class TCKDuration extends AbstractTCKTest {
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(Duration.ofHours(5));
- assertSerializable(Duration.ofHours(0));
- assertSerializable(Duration.ofHours(-5));
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(1);
- dos.writeLong(654321);
- dos.writeInt(123456789);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(Duration.ofSeconds(654321, 123456789), bytes);
- }
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKDurationSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.Serializable;
+import java.time.Duration;
+
+/**
+ * Test Duration serialization.
+ */
+@Test
+public class TCKDurationSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_interfaces() {
+ assertTrue(Serializable.class.isAssignableFrom(Duration.class));
+ assertTrue(Comparable.class.isAssignableFrom(Duration.class));
+ }
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(Duration.ofHours(5));
+ assertSerializable(Duration.ofHours(0));
+ assertSerializable(Duration.ofHours(-5));
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(1);
+ dos.writeLong(654321);
+ dos.writeInt(123456789);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(Duration.ofSeconds(654321, 123456789), bytes);
+ }
+
+ //-----------------------------------------------------------------------
+ // serialization
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_deserializationSingleton() throws Exception {
+ assertSerializableSame(Duration.ZERO);
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKInstant.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.time.Instant;
-
-/**
- * Test Instant.
- */
-@Test
-public class TCKInstant extends AbstractTCKTest {
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(Instant.ofEpochMilli(134l));
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(2);
- dos.writeLong(654321);
- dos.writeInt(123456789);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(Instant.ofEpochSecond(654321, 123456789), bytes);
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKInstantSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.time.Instant;
+
+/**
+ * Test Instant serialization.
+ */
+@Test
+public class TCKInstantSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(Instant.ofEpochMilli(134l));
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(2);
+ dos.writeLong(654321);
+ dos.writeInt(123456789);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(Instant.ofEpochSecond(654321, 123456789), bytes);
+ }
+
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKLocalDate.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.time.LocalDate;
-
-/**
- * Test LocalDate.
- */
-@Test
-public class TCKLocalDate extends AbstractTCKTest {
-
- private LocalDate TEST_2007_07_15;
-
- @BeforeMethod
- public void setUp() {
- TEST_2007_07_15 = LocalDate.of(2007, 7, 15);
- }
-
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(TEST_2007_07_15);
- assertSerializable(LocalDate.MIN);
- assertSerializable(LocalDate.MAX);
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(3);
- dos.writeInt(2012);
- dos.writeByte(9);
- dos.writeByte(16);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(LocalDate.of(2012, 9, 16), bytes);
- }
-
- //-----------------------------------------------------------------------
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKLocalDateSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.time.LocalDate;
+
+/**
+ * Test LocalDate serialization.
+ */
+@Test
+public class TCKLocalDateSerialization extends AbstractTCKTest {
+
+ private LocalDate TEST_2007_07_15;
+
+ @BeforeMethod
+ public void setUp() {
+ TEST_2007_07_15 = LocalDate.of(2007, 7, 15);
+ }
+
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(TEST_2007_07_15);
+ assertSerializable(LocalDate.MIN);
+ assertSerializable(LocalDate.MAX);
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(3);
+ dos.writeInt(2012);
+ dos.writeByte(9);
+ dos.writeByte(16);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(LocalDate.of(2012, 9, 16), bytes);
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKLocalDateTime.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.time.LocalDateTime;
-
-/**
- * Test LocalDateTime.
- */
-@Test
-public class TCKLocalDateTime extends AbstractTCKTest {
-
- private LocalDateTime TEST_2007_07_15_12_30_40_987654321 = LocalDateTime.of(2007, 7, 15, 12, 30, 40, 987654321);
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(TEST_2007_07_15_12_30_40_987654321);
- assertSerializable(LocalDateTime.MIN);
- assertSerializable(LocalDateTime.MAX);
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(5);
- dos.writeInt(2012);
- dos.writeByte(9);
- dos.writeByte(16);
- dos.writeByte(22);
- dos.writeByte(17);
- dos.writeByte(59);
- dos.writeInt(459_000_000);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(LocalDateTime.of(2012, 9, 16, 22, 17, 59, 459_000_000), bytes);
- }
-
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKLocalDateTimeSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.time.LocalDateTime;
+
+/**
+ * Test serialization of LocalDateTime.
+ */
+@Test
+public class TCKLocalDateTimeSerialization extends AbstractTCKTest {
+
+ private LocalDateTime TEST_2007_07_15_12_30_40_987654321 = LocalDateTime.of(2007, 7, 15, 12, 30, 40, 987654321);
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(TEST_2007_07_15_12_30_40_987654321);
+ assertSerializable(LocalDateTime.MIN);
+ assertSerializable(LocalDateTime.MAX);
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(5);
+ dos.writeInt(2012);
+ dos.writeByte(9);
+ dos.writeByte(16);
+ dos.writeByte(22);
+ dos.writeByte(17);
+ dos.writeByte(59);
+ dos.writeInt(459_000_000);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(LocalDateTime.of(2012, 9, 16, 22, 17, 59, 459_000_000), bytes);
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKLocalTime.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,145 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.time.LocalTime;
-
-/**
- * Test LocalTime.
- */
-@Test
-public class TCKLocalTime extends AbstractTCKTest {
-
-
- private LocalTime TEST_12_30_40_987654321;
-
-
- @BeforeMethod
- public void setUp() {
- TEST_12_30_40_987654321 = LocalTime.of(12, 30, 40, 987654321);
- }
-
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(TEST_12_30_40_987654321);
- assertSerializable(LocalTime.MIN);
- assertSerializable(LocalTime.MAX);
- }
-
- @Test
- public void test_serialization_format_h() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(4);
- dos.writeByte(-1 - 22);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(LocalTime.of(22, 0), bytes);
- }
-
- @Test
- public void test_serialization_format_hm() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(4);
- dos.writeByte(22);
- dos.writeByte(-1 - 17);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(LocalTime.of(22, 17), bytes);
- }
-
- @Test
- public void test_serialization_format_hms() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(4);
- dos.writeByte(22);
- dos.writeByte(17);
- dos.writeByte(-1 - 59);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(LocalTime.of(22, 17, 59), bytes);
- }
-
- @Test
- public void test_serialization_format_hmsn() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(4);
- dos.writeByte(22);
- dos.writeByte(17);
- dos.writeByte(59);
- dos.writeInt(459_000_000);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(LocalTime.of(22, 17, 59, 459_000_000), bytes);
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKLocalTimeSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2007-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.time.LocalTime;
+
+/**
+ * Test LocalTime serialization.
+ */
+@Test
+public class TCKLocalTimeSerialization extends AbstractTCKTest {
+
+
+ private LocalTime TEST_12_30_40_987654321;
+
+
+ @BeforeMethod
+ public void setUp() {
+ TEST_12_30_40_987654321 = LocalTime.of(12, 30, 40, 987654321);
+ }
+
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(TEST_12_30_40_987654321);
+ assertSerializable(LocalTime.MIN);
+ assertSerializable(LocalTime.MAX);
+ }
+
+ @Test
+ public void test_serialization_format_h() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(4);
+ dos.writeByte(-1 - 22);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(LocalTime.of(22, 0), bytes);
+ }
+
+ @Test
+ public void test_serialization_format_hm() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(4);
+ dos.writeByte(22);
+ dos.writeByte(-1 - 17);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(LocalTime.of(22, 17), bytes);
+ }
+
+ @Test
+ public void test_serialization_format_hms() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(4);
+ dos.writeByte(22);
+ dos.writeByte(17);
+ dos.writeByte(-1 - 59);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(LocalTime.of(22, 17, 59), bytes);
+ }
+
+ @Test
+ public void test_serialization_format_hmsn() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(4);
+ dos.writeByte(22);
+ dos.writeByte(17);
+ dos.writeByte(59);
+ dos.writeInt(459_000_000);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(LocalTime.of(22, 17, 59, 459_000_000), bytes);
+ }
+
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKMonthDay.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.time.MonthDay;
-
-/**
- * Test MonthDay.
- */
-@Test
-public class TCKMonthDay extends AbstractTCKTest {
-
- private MonthDay TEST_07_15;
-
- @BeforeMethod
- public void setUp() {
- TEST_07_15 = MonthDay.of(7, 15);
- }
-
-
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws ClassNotFoundException, IOException {
- assertSerializable(TEST_07_15);
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(13); // java.time.temporal.Ser.MONTH_DAY_TYPE
- dos.writeByte(9);
- dos.writeByte(16);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(MonthDay.of(9, 16), bytes);
- }
-
- //-----------------------------------------------------------------------
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKMonthDaySerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.time.MonthDay;
+
+/**
+ * Test MonthDay serialization.
+ */
+@Test
+public class TCKMonthDaySerialization extends AbstractTCKTest {
+
+ private MonthDay TEST_07_15;
+
+ @BeforeMethod
+ public void setUp() {
+ TEST_07_15 = MonthDay.of(7, 15);
+ }
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws ClassNotFoundException, IOException {
+ assertSerializable(TEST_07_15);
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(13); // java.time.temporal.Ser.MONTH_DAY_TYPE
+ dos.writeByte(9);
+ dos.writeByte(16);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(MonthDay.of(9, 16), bytes);
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKOffsetDateTime.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.time.LocalDateTime;
-import java.time.OffsetDateTime;
-import java.time.ZoneOffset;
-
-/**
- * Test OffsetDateTime.
- */
-@Test
-public class TCKOffsetDateTime extends AbstractTCKTest {
-
- private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
- private OffsetDateTime TEST_2008_6_30_11_30_59_000000500;
-
- @BeforeMethod
- public void setUp() {
- TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 500, OFFSET_PONE);
- }
-
- //-----------------------------------------------------------------------
-
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(TEST_2008_6_30_11_30_59_000000500);
- assertSerializable(OffsetDateTime.MIN);
- assertSerializable(OffsetDateTime.MAX);
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(10); // java.time.Ser.OFFSET_DATE_TIME_TYPE
- }
- byte[] bytes = baos.toByteArray();
- ByteArrayOutputStream baosDateTime = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baosDateTime) ) {
- dos.writeByte(5);
- dos.writeInt(2012);
- dos.writeByte(9);
- dos.writeByte(16);
- dos.writeByte(22);
- dos.writeByte(17);
- dos.writeByte(59);
- dos.writeInt(464_000_000);
- }
- byte[] bytesDateTime = baosDateTime.toByteArray();
- ByteArrayOutputStream baosOffset = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baosOffset) ) {
- dos.writeByte(8);
- dos.writeByte(4); // quarter hours stored: 3600 / 900
- }
- byte[] bytesOffset = baosOffset.toByteArray();
- LocalDateTime ldt = LocalDateTime.of(2012, 9, 16, 22, 17, 59, 464_000_000);
- assertSerializedBySer(OffsetDateTime.of(ldt, ZoneOffset.ofHours(1)), bytes, bytesDateTime, bytesOffset);
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKOffsetDateTimeSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.time.LocalDateTime;
+import java.time.OffsetDateTime;
+import java.time.ZoneOffset;
+
+/**
+ * Test OffsetDateTime serialization.
+ */
+@Test
+public class TCKOffsetDateTimeSerialization extends AbstractTCKTest {
+
+ private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
+ private OffsetDateTime TEST_2008_6_30_11_30_59_000000500;
+
+ @BeforeMethod
+ public void setUp() {
+ TEST_2008_6_30_11_30_59_000000500 = OffsetDateTime.of(2008, 6, 30, 11, 30, 59, 500, OFFSET_PONE);
+ }
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(TEST_2008_6_30_11_30_59_000000500);
+ assertSerializable(OffsetDateTime.MIN);
+ assertSerializable(OffsetDateTime.MAX);
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(10); // java.time.Ser.OFFSET_DATE_TIME_TYPE
+ }
+ byte[] bytes = baos.toByteArray();
+ ByteArrayOutputStream baosDateTime = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baosDateTime) ) {
+ dos.writeByte(5);
+ dos.writeInt(2012);
+ dos.writeByte(9);
+ dos.writeByte(16);
+ dos.writeByte(22);
+ dos.writeByte(17);
+ dos.writeByte(59);
+ dos.writeInt(464_000_000);
+ }
+ byte[] bytesDateTime = baosDateTime.toByteArray();
+ ByteArrayOutputStream baosOffset = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baosOffset) ) {
+ dos.writeByte(8);
+ dos.writeByte(4); // quarter hours stored: 3600 / 900
+ }
+ byte[] bytesOffset = baosOffset.toByteArray();
+ LocalDateTime ldt = LocalDateTime.of(2012, 9, 16, 22, 17, 59, 464_000_000);
+ assertSerializedBySer(OffsetDateTime.of(ldt, ZoneOffset.ofHours(1)), bytes, bytesDateTime, bytesOffset);
+ }
+
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKOffsetTime.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.time.OffsetTime;
-import java.time.ZoneOffset;
-
-/**
- * Test OffsetTime.
- */
-@Test
-public class TCKOffsetTime extends AbstractTCKTest {
-
- private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
- private OffsetTime TEST_11_30_59_500_PONE;
-
- @BeforeMethod
- public void setUp() {
- TEST_11_30_59_500_PONE = OffsetTime.of(11, 30, 59, 500, OFFSET_PONE);
- }
-
-
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(TEST_11_30_59_500_PONE);
- assertSerializable(OffsetTime.MIN);
- assertSerializable(OffsetTime.MAX);
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(9); // java.time.Ser.OFFSET_TIME_TYPE
- }
- byte[] bytes = baos.toByteArray();
- ByteArrayOutputStream baosTime = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baosTime) ) {
- dos.writeByte(4);
- dos.writeByte(22);
- dos.writeByte(17);
- dos.writeByte(59);
- dos.writeInt(464_000_000);
- }
- byte[] bytesTime = baosTime.toByteArray();
- ByteArrayOutputStream baosOffset = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baosOffset) ) {
- dos.writeByte(8);
- dos.writeByte(4); // quarter hours stored: 3600 / 900
- }
- byte[] bytesOffset = baosOffset.toByteArray();
- assertSerializedBySer(OffsetTime.of(22, 17, 59, 464_000_000, ZoneOffset.ofHours(1)), bytes,
- bytesTime, bytesOffset);
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKOffsetTimeSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.time.OffsetTime;
+import java.time.ZoneOffset;
+
+/**
+ * Test OffsetTime serialization.
+ */
+@Test
+public class TCKOffsetTimeSerialization extends AbstractTCKTest {
+
+ private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
+ private OffsetTime TEST_11_30_59_500_PONE;
+
+ @BeforeMethod
+ public void setUp() {
+ TEST_11_30_59_500_PONE = OffsetTime.of(11, 30, 59, 500, OFFSET_PONE);
+ }
+
+
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(TEST_11_30_59_500_PONE);
+ assertSerializable(OffsetTime.MIN);
+ assertSerializable(OffsetTime.MAX);
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(9); // java.time.Ser.OFFSET_TIME_TYPE
+ }
+ byte[] bytes = baos.toByteArray();
+ ByteArrayOutputStream baosTime = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baosTime) ) {
+ dos.writeByte(4);
+ dos.writeByte(22);
+ dos.writeByte(17);
+ dos.writeByte(59);
+ dos.writeInt(464_000_000);
+ }
+ byte[] bytesTime = baosTime.toByteArray();
+ ByteArrayOutputStream baosOffset = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baosOffset) ) {
+ dos.writeByte(8);
+ dos.writeByte(4); // quarter hours stored: 3600 / 900
+ }
+ byte[] bytesOffset = baosOffset.toByteArray();
+ assertSerializedBySer(OffsetTime.of(22, 17, 59, 464_000_000, ZoneOffset.ofHours(1)), bytes,
+ bytesTime, bytesOffset);
+ }
+
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKPeriod.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.time.Period;
-
-/**
- * Test Period.
- */
-@Test
-public class TCKPeriod extends AbstractTCKTest {
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(Period.ZERO);
- assertSerializable(Period.ofDays(1));
- assertSerializable(Period.of(1, 2, 3));
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKPeriodSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.time.Period;
+
+/**
+ * Test serialization of Period.
+ */
+@Test
+public class TCKPeriodSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(Period.ZERO);
+ assertSerializable(Period.ofDays(1));
+ assertSerializable(Period.of(1, 2, 3));
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKYear.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.time.Year;
-
-/**
- * Test Year.
- */
-@Test
-public class TCKYear extends AbstractTCKTest {
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(Year.of(2));
- assertSerializable(Year.of(0));
- assertSerializable(Year.of(-2));
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(11); // java.time.temporal.Ser.YEAR_TYPE
- dos.writeInt(2012);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(Year.of(2012), bytes);
- }
-
-}
--- a/jdk/test/java/time/tck/java/time/serial/TCKYearMonth.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.time.YearMonth;
-
-/**
- * Test YearMonth.
- */
-@Test
-public class TCKYearMonth extends AbstractTCKTest {
-
- private YearMonth TEST_2008_06;
-
- @BeforeMethod
- public void setUp() {
- TEST_2008_06 = YearMonth.of(2008, 6);
- }
-
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws IOException, ClassNotFoundException {
- assertSerializable(TEST_2008_06);
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(12); // java.time.temporal.Ser.YEAR_MONTH_TYPE
- dos.writeInt(2012);
- dos.writeByte(9);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(YearMonth.of(2012, 9), bytes);
- }
-
- //-----------------------------------------------------------------------
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKYearMonthSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.time.YearMonth;
+
+/**
+ * Test serialization of YearMonth.
+ */
+@Test
+public class TCKYearMonthSerialization extends AbstractTCKTest {
+
+ private YearMonth TEST_2008_06;
+
+ @BeforeMethod
+ public void setUp() {
+ TEST_2008_06 = YearMonth.of(2008, 6);
+ }
+
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws IOException, ClassNotFoundException {
+ assertSerializable(TEST_2008_06);
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(12); // java.time.temporal.Ser.YEAR_MONTH_TYPE
+ dos.writeInt(2012);
+ dos.writeByte(9);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(YearMonth.of(2012, 9), bytes);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKYearSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.time.Year;
+
+/**
+ * Test Year serialization.
+ */
+@Test
+public class TCKYearSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(Year.of(2));
+ assertSerializable(Year.of(0));
+ assertSerializable(Year.of(-2));
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(11); // java.time.temporal.Ser.YEAR_TYPE
+ dos.writeInt(2012);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(Year.of(2012), bytes);
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKZoneId.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.*;
-import java.lang.reflect.Field;
-import java.time.DateTimeException;
-import java.time.ZoneId;
-import java.time.zone.ZoneRulesException;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.fail;
-
-/**
- * Test ZoneId.
- */
-@Test
-public class TCKZoneId extends AbstractTCKTest {
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(ZoneId.of("Europe/London"));
- assertSerializable(ZoneId.of("America/Chicago"));
- }
-
- @Test
- public void test_serialization_format() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(7);
- dos.writeUTF("Europe/London");
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(ZoneId.of("Europe/London"), bytes);
- }
-
- @Test
- public void test_deserialization_lenient_characters() throws Exception {
- // an ID can be loaded without validation during deserialization
- String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-";
- ZoneId deser = deserialize(id);
- // getId, equals, hashCode, toString and normalized are OK
- assertEquals(deser.getId(), id);
- assertEquals(deser.toString(), id);
- assertEquals(deser, deser);
- assertEquals(deser.hashCode(), deser.hashCode());
- assertEquals(deser.normalized(), deser);
- // getting the rules is not
- try {
- deser.getRules();
- fail();
- } catch (ZoneRulesException ex) {
- // expected
- }
- }
-
- @Test(expectedExceptions=DateTimeException.class)
- public void test_deserialization_lenient_badCharacters() throws Exception {
- // an ID can be loaded without validation during deserialization
- // but there is a check to ensure the ID format is valid
- deserialize("|!?");
- }
-
- @Test(dataProvider="offsetBasedValid")
- public void test_deserialization_lenient_offsetNotAllowed_noPrefix(String input, String resolvedId) throws Exception {
- ZoneId deserialized = deserialize(input);
- assertEquals(deserialized, ZoneId.of(input));
- assertEquals(deserialized, ZoneId.of(resolvedId));
- }
-
- @Test(dataProvider="offsetBasedValidPrefix")
- public void test_deserialization_lenient_offsetNotAllowed_prefixUTC(String input, String resolvedId, String offsetId) throws Exception {
- ZoneId deserialized = deserialize("UTC" + input);
- assertEquals(deserialized, ZoneId.of("UTC" + input));
- assertEquals(deserialized, ZoneId.of("UTC" + resolvedId));
- }
-
- @Test(dataProvider="offsetBasedValidPrefix")
- public void test_deserialization_lenient_offsetNotAllowed_prefixGMT(String input, String resolvedId, String offsetId) throws Exception {
- ZoneId deserialized = deserialize("GMT" + input);
- assertEquals(deserialized, ZoneId.of("GMT" + input));
- assertEquals(deserialized, ZoneId.of("GMT" + resolvedId));
- }
-
- @Test(dataProvider="offsetBasedValidPrefix")
- public void test_deserialization_lenient_offsetNotAllowed_prefixUT(String input, String resolvedId, String offsetId) throws Exception {
- ZoneId deserialized = deserialize("UT" + input);
- assertEquals(deserialized, ZoneId.of("UT" + input));
- assertEquals(deserialized, ZoneId.of("UT" + resolvedId));
- }
-
- private ZoneId deserialize(String id) throws Exception {
- String serClass = ZoneId.class.getPackage().getName() + ".Ser";
- Class<?> serCls = Class.forName(serClass);
- Field field = serCls.getDeclaredField("serialVersionUID");
- field.setAccessible(true);
- long serVer = (Long) field.get(null);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos)) {
- dos.writeShort(ObjectStreamConstants.STREAM_MAGIC);
- dos.writeShort(ObjectStreamConstants.STREAM_VERSION);
- dos.writeByte(ObjectStreamConstants.TC_OBJECT);
- dos.writeByte(ObjectStreamConstants.TC_CLASSDESC);
- dos.writeUTF(serClass);
- dos.writeLong(serVer);
- dos.writeByte(ObjectStreamConstants.SC_EXTERNALIZABLE | ObjectStreamConstants.SC_BLOCK_DATA);
- dos.writeShort(0); // number of fields
- dos.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA); // end of classdesc
- dos.writeByte(ObjectStreamConstants.TC_NULL); // no superclasses
- dos.writeByte(ObjectStreamConstants.TC_BLOCKDATA);
- dos.writeByte(1 + 2 + id.length()); // length of data (1 byte + 2 bytes UTF length + 32 bytes UTF)
- dos.writeByte(7); // ZoneId
- dos.writeUTF(id);
- dos.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA); // end of blockdata
- }
- ZoneId deser = null;
- try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
- deser = (ZoneId) ois.readObject();
- }
- return deser;
- }
-
- //-----------------------------------------------------------------------
- // regular factory and .normalized()
- //-----------------------------------------------------------------------
- @DataProvider(name="offsetBasedValid")
- Object[][] data_offsetBasedValid() {
- return new Object[][] {
- {"Z", "Z"},
- {"+0", "Z"},
- {"-0", "Z"},
- {"+00", "Z"},
- {"+0000", "Z"},
- {"+00:00", "Z"},
- {"+000000", "Z"},
- {"+00:00:00", "Z"},
- {"-00", "Z"},
- {"-0000", "Z"},
- {"-00:00", "Z"},
- {"-000000", "Z"},
- {"-00:00:00", "Z"},
- {"+5", "+05:00"},
- {"+01", "+01:00"},
- {"+0100", "+01:00"},
- {"+01:00", "+01:00"},
- {"+010000", "+01:00"},
- {"+01:00:00", "+01:00"},
- {"+12", "+12:00"},
- {"+1234", "+12:34"},
- {"+12:34", "+12:34"},
- {"+123456", "+12:34:56"},
- {"+12:34:56", "+12:34:56"},
- {"-02", "-02:00"},
- {"-5", "-05:00"},
- {"-0200", "-02:00"},
- {"-02:00", "-02:00"},
- {"-020000", "-02:00"},
- {"-02:00:00", "-02:00"},
- };
- }
-
- //-----------------------------------------------------------------------
- @DataProvider(name="offsetBasedValidPrefix")
- Object[][] data_offsetBasedValidPrefix() {
- return new Object[][] {
- {"", "", "Z"},
- {"+0", "", "Z"},
- {"-0", "", "Z"},
- {"+00", "", "Z"},
- {"+0000", "", "Z"},
- {"+00:00", "", "Z"},
- {"+000000", "", "Z"},
- {"+00:00:00", "", "Z"},
- {"-00", "", "Z"},
- {"-0000", "", "Z"},
- {"-00:00", "", "Z"},
- {"-000000", "", "Z"},
- {"-00:00:00", "", "Z"},
- {"+5", "+05:00", "+05:00"},
- {"+01", "+01:00", "+01:00"},
- {"+0100", "+01:00", "+01:00"},
- {"+01:00", "+01:00", "+01:00"},
- {"+010000", "+01:00", "+01:00"},
- {"+01:00:00", "+01:00", "+01:00"},
- {"+12", "+12:00", "+12:00"},
- {"+1234", "+12:34", "+12:34"},
- {"+12:34", "+12:34", "+12:34"},
- {"+123456", "+12:34:56", "+12:34:56"},
- {"+12:34:56", "+12:34:56", "+12:34:56"},
- {"-02", "-02:00", "-02:00"},
- {"-5", "-05:00", "-05:00"},
- {"-0200", "-02:00", "-02:00"},
- {"-02:00", "-02:00", "-02:00"},
- {"-020000", "-02:00", "-02:00"},
- {"-02:00:00", "-02:00", "-02:00"},
- };
- }
-
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKZoneIdSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,263 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.*;
+import java.lang.reflect.Field;
+import java.time.DateTimeException;
+import java.time.ZoneId;
+import java.time.zone.ZoneRulesException;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+/**
+ * Test serialization of ZoneId.
+ */
+@Test
+public class TCKZoneIdSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(ZoneId.of("Europe/London"));
+ assertSerializable(ZoneId.of("America/Chicago"));
+ }
+
+ @Test
+ public void test_serialization_format() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(7);
+ dos.writeUTF("Europe/London");
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(ZoneId.of("Europe/London"), bytes);
+ }
+
+ @Test
+ public void test_deserialization_lenient_characters() throws Exception {
+ // an ID can be loaded without validation during deserialization
+ String id = "QWERTYUIOPASDFGHJKLZXCVBNM~/._+-";
+ ZoneId deser = deserialize(id);
+ // getId, equals, hashCode, toString and normalized are OK
+ assertEquals(deser.getId(), id);
+ assertEquals(deser.toString(), id);
+ assertEquals(deser, deser);
+ assertEquals(deser.hashCode(), deser.hashCode());
+ assertEquals(deser.normalized(), deser);
+ // getting the rules is not
+ try {
+ deser.getRules();
+ fail();
+ } catch (ZoneRulesException ex) {
+ // expected
+ }
+ }
+
+ @Test(expectedExceptions=DateTimeException.class)
+ public void test_deserialization_lenient_badCharacters() throws Exception {
+ // an ID can be loaded without validation during deserialization
+ // but there is a check to ensure the ID format is valid
+ deserialize("|!?");
+ }
+
+ @Test(dataProvider="offsetBasedValid")
+ public void test_deserialization_lenient_offsetNotAllowed_noPrefix(String input, String resolvedId) throws Exception {
+ ZoneId deserialized = deserialize(input);
+ assertEquals(deserialized, ZoneId.of(input));
+ assertEquals(deserialized, ZoneId.of(resolvedId));
+ }
+
+ @Test(dataProvider="offsetBasedValidPrefix")
+ public void test_deserialization_lenient_offsetNotAllowed_prefixUTC(String input, String resolvedId, String offsetId) throws Exception {
+ ZoneId deserialized = deserialize("UTC" + input);
+ assertEquals(deserialized, ZoneId.of("UTC" + input));
+ assertEquals(deserialized, ZoneId.of("UTC" + resolvedId));
+ }
+
+ @Test(dataProvider="offsetBasedValidPrefix")
+ public void test_deserialization_lenient_offsetNotAllowed_prefixGMT(String input, String resolvedId, String offsetId) throws Exception {
+ ZoneId deserialized = deserialize("GMT" + input);
+ assertEquals(deserialized, ZoneId.of("GMT" + input));
+ assertEquals(deserialized, ZoneId.of("GMT" + resolvedId));
+ }
+
+ @Test(dataProvider="offsetBasedValidPrefix")
+ public void test_deserialization_lenient_offsetNotAllowed_prefixUT(String input, String resolvedId, String offsetId) throws Exception {
+ ZoneId deserialized = deserialize("UT" + input);
+ assertEquals(deserialized, ZoneId.of("UT" + input));
+ assertEquals(deserialized, ZoneId.of("UT" + resolvedId));
+ }
+
+ private ZoneId deserialize(String id) throws Exception {
+ String serClass = ZoneId.class.getPackage().getName() + ".Ser";
+ Class<?> serCls = Class.forName(serClass);
+ Field field = serCls.getDeclaredField("serialVersionUID");
+ field.setAccessible(true);
+ long serVer = (Long) field.get(null);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos)) {
+ dos.writeShort(ObjectStreamConstants.STREAM_MAGIC);
+ dos.writeShort(ObjectStreamConstants.STREAM_VERSION);
+ dos.writeByte(ObjectStreamConstants.TC_OBJECT);
+ dos.writeByte(ObjectStreamConstants.TC_CLASSDESC);
+ dos.writeUTF(serClass);
+ dos.writeLong(serVer);
+ dos.writeByte(ObjectStreamConstants.SC_EXTERNALIZABLE | ObjectStreamConstants.SC_BLOCK_DATA);
+ dos.writeShort(0); // number of fields
+ dos.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA); // end of classdesc
+ dos.writeByte(ObjectStreamConstants.TC_NULL); // no superclasses
+ dos.writeByte(ObjectStreamConstants.TC_BLOCKDATA);
+ dos.writeByte(1 + 2 + id.length()); // length of data (1 byte + 2 bytes UTF length + 32 bytes UTF)
+ dos.writeByte(7); // ZoneId
+ dos.writeUTF(id);
+ dos.writeByte(ObjectStreamConstants.TC_ENDBLOCKDATA); // end of blockdata
+ }
+ ZoneId deser = null;
+ try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
+ deser = (ZoneId) ois.readObject();
+ }
+ return deser;
+ }
+
+ //-----------------------------------------------------------------------
+ // regular factory and .normalized()
+ //-----------------------------------------------------------------------
+ @DataProvider(name="offsetBasedValid")
+ Object[][] data_offsetBasedValid() {
+ return new Object[][] {
+ {"Z", "Z"},
+ {"+0", "Z"},
+ {"-0", "Z"},
+ {"+00", "Z"},
+ {"+0000", "Z"},
+ {"+00:00", "Z"},
+ {"+000000", "Z"},
+ {"+00:00:00", "Z"},
+ {"-00", "Z"},
+ {"-0000", "Z"},
+ {"-00:00", "Z"},
+ {"-000000", "Z"},
+ {"-00:00:00", "Z"},
+ {"+5", "+05:00"},
+ {"+01", "+01:00"},
+ {"+0100", "+01:00"},
+ {"+01:00", "+01:00"},
+ {"+010000", "+01:00"},
+ {"+01:00:00", "+01:00"},
+ {"+12", "+12:00"},
+ {"+1234", "+12:34"},
+ {"+12:34", "+12:34"},
+ {"+123456", "+12:34:56"},
+ {"+12:34:56", "+12:34:56"},
+ {"-02", "-02:00"},
+ {"-5", "-05:00"},
+ {"-0200", "-02:00"},
+ {"-02:00", "-02:00"},
+ {"-020000", "-02:00"},
+ {"-02:00:00", "-02:00"},
+ };
+ }
+
+ //-----------------------------------------------------------------------
+ @DataProvider(name="offsetBasedValidPrefix")
+ Object[][] data_offsetBasedValidPrefix() {
+ return new Object[][] {
+ {"", "", "Z"},
+ {"+0", "", "Z"},
+ {"-0", "", "Z"},
+ {"+00", "", "Z"},
+ {"+0000", "", "Z"},
+ {"+00:00", "", "Z"},
+ {"+000000", "", "Z"},
+ {"+00:00:00", "", "Z"},
+ {"-00", "", "Z"},
+ {"-0000", "", "Z"},
+ {"-00:00", "", "Z"},
+ {"-000000", "", "Z"},
+ {"-00:00:00", "", "Z"},
+ {"+5", "+05:00", "+05:00"},
+ {"+01", "+01:00", "+01:00"},
+ {"+0100", "+01:00", "+01:00"},
+ {"+01:00", "+01:00", "+01:00"},
+ {"+010000", "+01:00", "+01:00"},
+ {"+01:00:00", "+01:00", "+01:00"},
+ {"+12", "+12:00", "+12:00"},
+ {"+1234", "+12:34", "+12:34"},
+ {"+12:34", "+12:34", "+12:34"},
+ {"+123456", "+12:34:56", "+12:34:56"},
+ {"+12:34:56", "+12:34:56", "+12:34:56"},
+ {"-02", "-02:00", "-02:00"},
+ {"-5", "-05:00", "-05:00"},
+ {"-0200", "-02:00", "-02:00"},
+ {"-02:00", "-02:00", "-02:00"},
+ {"-020000", "-02:00", "-02:00"},
+ {"-02:00:00", "-02:00", "-02:00"},
+ };
+ }
+
+
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKZoneOffset.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.time.ZoneOffset;
-
-/**
- * Test ZoneOffset.
- */
-@Test
-public class TCKZoneOffset extends AbstractTCKTest {
-
-
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws Exception {
- assertSerializable(ZoneOffset.of("+01:30"));
- }
-
- @Test
- public void test_serialization_format_quarterPositive() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(8);
- dos.writeByte(6); // stored as quarter hours
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(ZoneOffset.ofHoursMinutes(1, 30), bytes);
- }
-
- @Test
- public void test_serialization_format_quarterNegative() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(8);
- dos.writeByte(-10); // stored as quarter hours
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(ZoneOffset.ofHoursMinutes(-2, -30), bytes);
- }
-
- @Test
- public void test_serialization_format_full() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(8);
- dos.writeByte(127);
- dos.writeInt(53265);
- }
- byte[] bytes = baos.toByteArray();
- assertSerializedBySer(ZoneOffset.ofTotalSeconds(53265), bytes);
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKZoneOffsetSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.time.ZoneOffset;
+
+/**
+ * Test serialization of ZoneOffset.
+ */
+@Test
+public class TCKZoneOffsetSerialization extends AbstractTCKTest {
+
+
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws Exception {
+ assertSerializable(ZoneOffset.of("+01:30"));
+ }
+
+ @Test
+ public void test_serialization_format_quarterPositive() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(8);
+ dos.writeByte(6); // stored as quarter hours
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(ZoneOffset.ofHoursMinutes(1, 30), bytes);
+ }
+
+ @Test
+ public void test_serialization_format_quarterNegative() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(8);
+ dos.writeByte(-10); // stored as quarter hours
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(ZoneOffset.ofHoursMinutes(-2, -30), bytes);
+ }
+
+ @Test
+ public void test_serialization_format_full() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(8);
+ dos.writeByte(127);
+ dos.writeInt(53265);
+ }
+ byte[] bytes = baos.toByteArray();
+ assertSerializedBySer(ZoneOffset.ofTotalSeconds(53265), bytes);
+ }
+
+
+}
--- a/jdk/test/java/time/tck/java/time/serial/TCKZonedDateTime.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,143 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.serial;
-
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-
-/**
- * Test ZonedDateTime.
- */
-@Test
-public class TCKZonedDateTime extends AbstractTCKTest {
-
- private static final ZoneOffset OFFSET_0100 = ZoneOffset.ofHours(1);
- private static final ZoneId ZONE_0100 = OFFSET_0100;
- private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris");
- private LocalDateTime TEST_LOCAL_2008_06_30_11_30_59_500;
- private ZonedDateTime TEST_DATE_TIME;
-
-
- @BeforeMethod
- public void setUp() {
- TEST_LOCAL_2008_06_30_11_30_59_500 = LocalDateTime.of(2008, 6, 30, 11, 30, 59, 500);
- TEST_DATE_TIME = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100);
- }
-
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization() throws ClassNotFoundException, IOException {
- assertSerializable(TEST_DATE_TIME);
- }
-
- @Test
- public void test_serialization_format_zoneId() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(6);
- dos.writeInt(2012); // date
- dos.writeByte(9);
- dos.writeByte(16);
- dos.writeByte(22); // time
- dos.writeByte(17);
- dos.writeByte(59);
- dos.writeInt(470_000_000);
- dos.writeByte(4); // offset
- dos.writeByte(7); // zoneId
- dos.writeUTF("Europe/London");
- }
- byte[] bytes = baos.toByteArray();
- ZonedDateTime zdt = LocalDateTime.of(2012, 9, 16, 22, 17, 59, 470_000_000).atZone(ZoneId.of("Europe/London"));
- assertSerializedBySer(zdt, bytes);
- }
-
- @Test
- public void test_serialization_format_zoneOffset() throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (DataOutputStream dos = new DataOutputStream(baos) ) {
- dos.writeByte(6);
- dos.writeInt(2012); // date
- dos.writeByte(9);
- dos.writeByte(16);
- dos.writeByte(22); // time
- dos.writeByte(17);
- dos.writeByte(59);
- dos.writeInt(470_000_000);
- dos.writeByte(4); // offset
- dos.writeByte(8); // zoneId
- dos.writeByte(4);
- }
- byte[] bytes = baos.toByteArray();
- ZonedDateTime zdt = LocalDateTime.of(2012, 9, 16, 22, 17, 59, 470_000_000).atZone(ZoneOffset.ofHours(1));
- assertSerializedBySer(zdt, bytes);
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/serial/TCKZonedDateTimeSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,142 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.serial;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.ZonedDateTime;
+
+/**
+ * Test serialization of ZonedDateTime.
+ */
+@Test
+public class TCKZonedDateTimeSerialization extends AbstractTCKTest {
+
+ private static final ZoneOffset OFFSET_0100 = ZoneOffset.ofHours(1);
+ private static final ZoneId ZONE_0100 = OFFSET_0100;
+ private static final ZoneId ZONE_PARIS = ZoneId.of("Europe/Paris");
+ private LocalDateTime TEST_LOCAL_2008_06_30_11_30_59_500;
+ private ZonedDateTime TEST_DATE_TIME;
+
+
+ @BeforeMethod
+ public void setUp() {
+ TEST_LOCAL_2008_06_30_11_30_59_500 = LocalDateTime.of(2008, 6, 30, 11, 30, 59, 500);
+ TEST_DATE_TIME = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100);
+ }
+
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization() throws ClassNotFoundException, IOException {
+ assertSerializable(TEST_DATE_TIME);
+ }
+
+ @Test
+ public void test_serialization_format_zoneId() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(6);
+ dos.writeInt(2012); // date
+ dos.writeByte(9);
+ dos.writeByte(16);
+ dos.writeByte(22); // time
+ dos.writeByte(17);
+ dos.writeByte(59);
+ dos.writeInt(470_000_000);
+ dos.writeByte(4); // offset
+ dos.writeByte(7); // zoneId
+ dos.writeUTF("Europe/London");
+ }
+ byte[] bytes = baos.toByteArray();
+ ZonedDateTime zdt = LocalDateTime.of(2012, 9, 16, 22, 17, 59, 470_000_000).atZone(ZoneId.of("Europe/London"));
+ assertSerializedBySer(zdt, bytes);
+ }
+
+ @Test
+ public void test_serialization_format_zoneOffset() throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (DataOutputStream dos = new DataOutputStream(baos) ) {
+ dos.writeByte(6);
+ dos.writeInt(2012); // date
+ dos.writeByte(9);
+ dos.writeByte(16);
+ dos.writeByte(22); // time
+ dos.writeByte(17);
+ dos.writeByte(59);
+ dos.writeInt(470_000_000);
+ dos.writeByte(4); // offset
+ dos.writeByte(8); // zoneId
+ dos.writeByte(4);
+ }
+ byte[] bytes = baos.toByteArray();
+ ZonedDateTime zdt = LocalDateTime.of(2012, 9, 16, 22, 17, 59, 470_000_000).atZone(ZoneOffset.ofHours(1));
+ assertSerializedBySer(zdt, bytes);
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/temporal/TCKJulianFields.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/temporal/TCKJulianFields.java Thu Oct 03 15:16:14 2013 -0400
@@ -76,7 +76,7 @@
import tck.java.time.AbstractTCKTest;
/**
- * Test.
+ * Test Julian Fields.
*/
@Test
public class TCKJulianFields extends AbstractTCKTest {
@@ -86,16 +86,6 @@
private static final LocalDate NOV12_1945 = LocalDate.of(1945, 11, 12);
private static final LocalDate JAN01_0001 = LocalDate.of(1, 1, 1);
- //-----------------------------------------------------------------------
- @DataProvider(name="julian_fields")
- Object[][] julian_samples() {
- return new Object[][] {
- {JulianFields.JULIAN_DAY},
- {JulianFields.MODIFIED_JULIAN_DAY},
- {JulianFields.RATA_DIE},
- };
- }
-
@DataProvider(name="samples")
Object[][] data_samples() {
return new Object[][] {
@@ -122,11 +112,6 @@
}
//-----------------------------------------------------------------------
- @Test(dataProvider="julian_fields")
- public void test_serializable(TemporalField field) throws IOException, ClassNotFoundException {
- assertSerializable(field);
- }
-
public void test_basics() {
assertEquals(JulianFields.JULIAN_DAY.isDateBased(), true);
assertEquals(JulianFields.JULIAN_DAY.isTimeBased(), false);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/temporal/serial/TCKChronoFieldSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.temporal.serial;
+
+import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_MONTH;
+import static java.time.temporal.ChronoField.ALIGNED_DAY_OF_WEEK_IN_YEAR;
+import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_MONTH;
+import static java.time.temporal.ChronoField.ALIGNED_WEEK_OF_YEAR;
+import static java.time.temporal.ChronoField.AMPM_OF_DAY;
+import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_AMPM;
+import static java.time.temporal.ChronoField.CLOCK_HOUR_OF_DAY;
+import static java.time.temporal.ChronoField.DAY_OF_MONTH;
+import static java.time.temporal.ChronoField.DAY_OF_WEEK;
+import static java.time.temporal.ChronoField.DAY_OF_YEAR;
+import static java.time.temporal.ChronoField.EPOCH_DAY;
+import static java.time.temporal.ChronoField.HOUR_OF_AMPM;
+import static java.time.temporal.ChronoField.HOUR_OF_DAY;
+import static java.time.temporal.ChronoField.MICRO_OF_DAY;
+import static java.time.temporal.ChronoField.MICRO_OF_SECOND;
+import static java.time.temporal.ChronoField.MILLI_OF_DAY;
+import static java.time.temporal.ChronoField.MILLI_OF_SECOND;
+import static java.time.temporal.ChronoField.MINUTE_OF_DAY;
+import static java.time.temporal.ChronoField.MINUTE_OF_HOUR;
+import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
+import static java.time.temporal.ChronoField.NANO_OF_DAY;
+import static java.time.temporal.ChronoField.NANO_OF_SECOND;
+import static java.time.temporal.ChronoField.PROLEPTIC_MONTH;
+import static java.time.temporal.ChronoField.SECOND_OF_DAY;
+import static java.time.temporal.ChronoField.SECOND_OF_MINUTE;
+import static java.time.temporal.ChronoField.YEAR;
+import static java.time.temporal.ChronoField.YEAR_OF_ERA;
+import static java.time.temporal.ChronoField.ERA;
+
+import java.io.IOException;
+import java.time.temporal.ChronoField;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Test serialization of ChronoField.
+ */
+@Test
+public class TCKChronoFieldSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ // List of Fields
+ //-----------------------------------------------------------------------
+ @DataProvider(name="fieldBased")
+ Object[][] data_fieldBased() {
+ return new Object[][] {
+ {DAY_OF_WEEK},
+ {ALIGNED_DAY_OF_WEEK_IN_MONTH},
+ {ALIGNED_DAY_OF_WEEK_IN_YEAR},
+ {DAY_OF_MONTH},
+ {DAY_OF_YEAR},
+ {EPOCH_DAY},
+ {ALIGNED_WEEK_OF_MONTH},
+ {ALIGNED_WEEK_OF_YEAR},
+ {MONTH_OF_YEAR},
+ {PROLEPTIC_MONTH},
+ {YEAR_OF_ERA},
+ {YEAR},
+ {ERA},
+
+ {AMPM_OF_DAY},
+ {CLOCK_HOUR_OF_DAY},
+ {HOUR_OF_DAY},
+ {CLOCK_HOUR_OF_AMPM},
+ {HOUR_OF_AMPM},
+ {MINUTE_OF_DAY},
+ {MINUTE_OF_HOUR},
+ {SECOND_OF_DAY},
+ {SECOND_OF_MINUTE},
+ {MILLI_OF_DAY},
+ {MILLI_OF_SECOND},
+ {MICRO_OF_DAY},
+ {MICRO_OF_SECOND},
+ {NANO_OF_DAY},
+ {NANO_OF_SECOND},
+ };
+ }
+
+ @Test(dataProvider = "fieldBased")
+ public void test_fieldSerializable(ChronoField field) throws IOException, ClassNotFoundException {
+ assertSerializableSame(field);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/temporal/serial/TCKChronoUnitSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.temporal.serial;
+
+import static java.time.temporal.ChronoUnit.CENTURIES;
+import static java.time.temporal.ChronoUnit.DAYS;
+import static java.time.temporal.ChronoUnit.DECADES;
+import static java.time.temporal.ChronoUnit.ERAS;
+import static java.time.temporal.ChronoUnit.FOREVER;
+import static java.time.temporal.ChronoUnit.HALF_DAYS;
+import static java.time.temporal.ChronoUnit.HOURS;
+import static java.time.temporal.ChronoUnit.MICROS;
+import static java.time.temporal.ChronoUnit.MILLENNIA;
+import static java.time.temporal.ChronoUnit.MILLIS;
+import static java.time.temporal.ChronoUnit.MINUTES;
+import static java.time.temporal.ChronoUnit.MONTHS;
+import static java.time.temporal.ChronoUnit.NANOS;
+import static java.time.temporal.ChronoUnit.SECONDS;
+import static java.time.temporal.ChronoUnit.WEEKS;
+import static java.time.temporal.ChronoUnit.YEARS;
+
+import java.io.IOException;
+import java.time.temporal.ChronoUnit;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Test.
+ */
+@Test
+public class TCKChronoUnitSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ // ChronoUnits
+ //-----------------------------------------------------------------------
+ @DataProvider(name="chronoUnit")
+ Object[][] data_chronoUnit() {
+ return new Object[][] {
+ {FOREVER},
+ {ERAS},
+ {MILLENNIA},
+ {CENTURIES},
+ {DECADES},
+ {YEARS},
+ {MONTHS},
+ {WEEKS},
+ {DAYS},
+
+ {HALF_DAYS},
+ {HOURS},
+ {MINUTES},
+ {SECONDS},
+ {MICROS},
+ {MILLIS},
+ {NANOS},
+
+ };
+ }
+
+ @Test(dataProvider = "chronoUnit")
+ public void test_unitType(ChronoUnit unit) throws IOException, ClassNotFoundException {
+ assertSerializableSame(unit);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/temporal/serial/TCKJulianFieldsSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.temporal.serial;
+
+import java.io.IOException;
+import java.time.temporal.JulianFields;
+import java.time.temporal.TemporalField;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Test serialization of JulianFields
+ */
+@Test
+public class TCKJulianFieldsSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ @DataProvider(name="julian_fields")
+ Object[][] julian_samples() {
+ return new Object[][] {
+ {JulianFields.JULIAN_DAY},
+ {JulianFields.MODIFIED_JULIAN_DAY},
+ {JulianFields.RATA_DIE},
+ };
+ }
+
+
+ //-----------------------------------------------------------------------
+ @Test(dataProvider="julian_fields")
+ public void test_serializable(TemporalField field) throws IOException, ClassNotFoundException {
+ assertSerializable(field);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/temporal/serial/TCKValueRangeSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2009-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.temporal.serial;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.time.temporal.ValueRange;
+
+import org.testng.annotations.Test;
+
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Test serialization of ValueRange.
+ */
+@Test
+public class TCKValueRangeSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ // Serialization
+ //-----------------------------------------------------------------------
+ public void test_serialization() throws Exception {
+ ValueRange range = ValueRange.of(1, 2, 3, 4);
+ assertSerializable(range);
+ }
+
+
+ /**
+ * Verify Serialized bytes of a ValueRange.
+ * @throws IOException if thrown during serialization is an unexpected test tailure
+ */
+ public void test_valueRangeSerialized() throws IOException {
+ byte[] expected = {
+ (byte)172, (byte)237, 0, 5, 115, 114, 0, 29, 106, 97, /* \u00ac \u00ed \u0000 \u0005 s r \u0000 \u001d j a */
+ 118, 97, 46, 116, 105, 109, 101, 46, 116, 101, /* v a . t i m e . t e */
+ 109, 112, 111, 114, 97, 108, 46, 86, 97, 108, /* m p o r a l . V a l */
+ 117, 101, 82, 97, 110, 103, 101, (byte)154, 113, (byte)169, /* u e R a n g e \u009a q \u00a9 */
+ 86, (byte)242, (byte)205, 90, (byte)184, 2, 0, 4, 74, 0, /* V \u00f2 \u00cd Z \u00b8 \u0002 \u0000 \u0004 J \u0000 */
+ 10, 109, 97, 120, 76, 97, 114, 103, 101, 115, /* m a x L a r g e s */
+ 116, 74, 0, 11, 109, 97, 120, 83, 109, 97, /* t J \u0000 \u000b m a x S m a */
+ 108, 108, 101, 115, 116, 74, 0, 10, 109, 105,/* l l e s t J \u0000 m i */
+ 110, 76, 97, 114, 103, 101, 115, 116, 74, 0, /* n L a r g e s t J \u0000 */
+ 11, 109, 105, 110, 83, 109, 97, 108, 108, 101, /* \u000b m i n S m a l l e */
+ 115, 116, 120, 112, 0, 0, 0, 0, 0, 0, /* s t x p \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 */
+ 0, 40, 0, 0, 0, 0, 0, 0, 0, 30, /* \u0000 ( \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u001e */
+ 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, /* \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0000 \u0014 \u0000 \u0000 */
+ 0, 0, 0, 0, 0, 10, /* \u0000 \u0000 \u0000 \u0000 \u0000 */
+ };
+
+ ValueRange range = ValueRange.of(10, 20, 30, 40);
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos) ) {
+ oos.writeObject(range);
+
+ byte[] actual = baos.toByteArray();
+ assertEquals(actual, expected, "Serialized bytes incorrect");
+ }
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/temporal/serial/TCKWeekFields.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.temporal.serial;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.io.IOException;
-import java.time.DayOfWeek;
-import java.time.temporal.WeekFields;
-
-/**
- * Test WeekFields.
- */
-@Test
-public class TCKWeekFields extends AbstractTCKTest {
-
- //-----------------------------------------------------------------------
- @Test(dataProvider="weekFields")
- public void test_serializable_singleton(DayOfWeek firstDayOfWeek, int minDays) throws IOException, ClassNotFoundException {
- WeekFields weekDef = WeekFields.of(firstDayOfWeek, minDays);
- assertSerializableSame(weekDef); // spec state singleton
- }
-
- //-----------------------------------------------------------------------
- @DataProvider(name="weekFields")
- Object[][] data_weekFields() {
- Object[][] objects = new Object[49][];
- int i = 0;
- for (DayOfWeek firstDayOfWeek : DayOfWeek.values()) {
- for (int minDays = 1; minDays <= 7; minDays++) {
- objects[i++] = new Object[] {firstDayOfWeek, minDays};
- }
- }
- return objects;
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/temporal/serial/TCKWeekFieldsSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.temporal.serial;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.io.IOException;
+import java.time.DayOfWeek;
+import java.time.temporal.WeekFields;
+
+/**
+ * Test serialization of WeekFields.
+ */
+@Test
+public class TCKWeekFieldsSerialization extends AbstractTCKTest {
+
+ //-----------------------------------------------------------------------
+ @Test(dataProvider="weekFields")
+ public void test_serializable_singleton(DayOfWeek firstDayOfWeek, int minDays) throws IOException, ClassNotFoundException {
+ WeekFields weekDef = WeekFields.of(firstDayOfWeek, minDays);
+ assertSerializableSame(weekDef); // spec state singleton
+ }
+
+ //-----------------------------------------------------------------------
+ @DataProvider(name="weekFields")
+ Object[][] data_weekFields() {
+ Object[][] objects = new Object[49][];
+ int i = 0;
+ for (DayOfWeek firstDayOfWeek : DayOfWeek.values()) {
+ for (int minDays = 1; minDays <= 7; minDays++) {
+ objects[i++] = new Object[] {firstDayOfWeek, minDays};
+ }
+ }
+ return objects;
+ }
+
+
+}
--- a/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransition.java Thu Oct 03 15:16:14 2013 -0400
@@ -127,7 +127,6 @@
assertEquals(test.getOffsetBefore(), OFFSET_0200);
assertEquals(test.getOffsetAfter(), OFFSET_0300);
assertEquals(test.getDuration(), Duration.of(1, HOURS));
- assertSerializable(test);
}
@Test
@@ -143,7 +142,6 @@
assertEquals(test.getOffsetBefore(), OFFSET_0300);
assertEquals(test.getOffsetAfter(), OFFSET_0200);
assertEquals(test.getDuration(), Duration.of(-1, HOURS));
- assertSerializable(test);
}
--- a/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/tck/java/time/zone/TCKZoneOffsetTransitionRule.java Thu Oct 03 15:16:14 2013 -0400
@@ -173,7 +173,6 @@
assertEquals(test.getStandardOffset(), OFFSET_0200);
assertEquals(test.getOffsetBefore(), OFFSET_0200);
assertEquals(test.getOffsetAfter(), OFFSET_0300);
- assertSerializable(test);
}
@Test
@@ -190,7 +189,6 @@
assertEquals(test.getStandardOffset(), OFFSET_0200);
assertEquals(test.getOffsetBefore(), OFFSET_0200);
assertEquals(test.getOffsetAfter(), OFFSET_0300);
- assertSerializable(test);
}
@Test
@@ -207,7 +205,6 @@
assertEquals(test.getStandardOffset(), OFFSET_0200);
assertEquals(test.getOffsetBefore(), OFFSET_0200);
assertEquals(test.getOffsetAfter(), OFFSET_0300);
- assertSerializable(test);
}
--- a/jdk/test/java/time/tck/java/time/zone/serial/TCKFixedZoneRules.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2010-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.zone.serial;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.time.ZoneOffset;
-import java.time.zone.ZoneRules;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * Test ZoneRules for fixed offset time-zones.
- */
-@Test
-public class TCKFixedZoneRules {
-
- private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
- private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2);
- private static final ZoneOffset OFFSET_M18 = ZoneOffset.ofHours(-18);
-
- private ZoneRules make(ZoneOffset offset) {
- return offset.getRules();
- }
-
- @DataProvider(name="rules")
- Object[][] data_rules() {
- return new Object[][] {
- {make(OFFSET_PONE), OFFSET_PONE},
- {make(OFFSET_PTWO), OFFSET_PTWO},
- {make(OFFSET_M18), OFFSET_M18},
- };
- }
-
- //-----------------------------------------------------------------------
- // Basics
- //-----------------------------------------------------------------------
- @Test(dataProvider="rules")
- public void test_serialization(ZoneRules test, ZoneOffset expectedOffset) throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(test);
- baos.close();
- byte[] bytes = baos.toByteArray();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream in = new ObjectInputStream(bais);
- ZoneRules result = (ZoneRules) in.readObject();
-
- assertEquals(result, test);
- assertEquals(result.getClass(), test.getClass());
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/zone/serial/TCKFixedZoneRulesSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2010-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.zone.serial;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.time.ZoneOffset;
+import java.time.zone.ZoneRules;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * Test serialization of ZoneRules for fixed offset time-zones.
+ */
+@Test
+public class TCKFixedZoneRulesSerialization {
+
+ private static final ZoneOffset OFFSET_PONE = ZoneOffset.ofHours(1);
+ private static final ZoneOffset OFFSET_PTWO = ZoneOffset.ofHours(2);
+ private static final ZoneOffset OFFSET_M18 = ZoneOffset.ofHours(-18);
+
+ private ZoneRules make(ZoneOffset offset) {
+ return offset.getRules();
+ }
+
+ @DataProvider(name="rules")
+ Object[][] data_rules() {
+ return new Object[][] {
+ {make(OFFSET_PONE), OFFSET_PONE},
+ {make(OFFSET_PTWO), OFFSET_PTWO},
+ {make(OFFSET_M18), OFFSET_M18},
+ };
+ }
+
+ //-----------------------------------------------------------------------
+ // Basics
+ //-----------------------------------------------------------------------
+ @Test(dataProvider="rules")
+ public void test_serialization(ZoneRules test, ZoneOffset expectedOffset) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(baos);
+ out.writeObject(test);
+ baos.close();
+ byte[] bytes = baos.toByteArray();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream in = new ObjectInputStream(bais);
+ ZoneRules result = (ZoneRules) in.readObject();
+
+ assertEquals(result, test);
+ assertEquals(result.getClass(), test.getClass());
+ }
+
+
+}
--- a/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransition.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2010-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.zone.serial;
-
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-import java.time.LocalDateTime;
-import java.time.Year;
-import java.time.ZoneOffset;
-import java.time.zone.ZoneOffsetTransition;
-
-/**
- * Test ZoneOffsetTransition.
- */
-@Test
-public class TCKZoneOffsetTransition extends AbstractTCKTest {
-
- //-----------------------------------------------------------------------
- @Test
- public void test_serialization_unusual1() throws Exception {
- LocalDateTime ldt = LocalDateTime.of(Year.MAX_VALUE, 12, 31, 1, 31, 53);
- ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, ZoneOffset.of("+02:04:56"), ZoneOffset.of("-10:02:34"));
- assertSerializable(test);
- }
-
- @Test
- public void test_serialization_unusual2() throws Exception {
- LocalDateTime ldt = LocalDateTime.of(Year.MIN_VALUE, 1, 1, 12, 1, 3);
- ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, ZoneOffset.of("+02:04:56"), ZoneOffset.of("+10:02:34"));
- assertSerializable(test);
- }
-
-}
--- a/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRule.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2010-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.zone.serial;
-
-import static org.testng.Assert.assertEquals;
-
-import java.time.DayOfWeek;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.Month;
-import java.time.ZoneOffset;
-import java.time.zone.ZoneOffsetTransitionRule;
-import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition;
-
-import org.testng.annotations.Test;
-import tck.java.time.AbstractTCKTest;
-
-/**
- * Test ZoneOffsetTransitionRule.
- */
-@Test
-public class TCKZoneOffsetTransitionRule extends AbstractTCKTest {
-
- private static final LocalTime TIME_0100 = LocalTime.of(1, 0);
- private static final ZoneOffset OFFSET_0200 = ZoneOffset.ofHours(2);
- private static final ZoneOffset OFFSET_0300 = ZoneOffset.ofHours(3);
-
-
-
- @Test
- public void test_serialization_unusualOffsets() throws Exception {
- ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
- Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD,
- ZoneOffset.ofHoursMinutesSeconds(-12, -20, -50),
- ZoneOffset.ofHoursMinutesSeconds(-4, -10, -34),
- ZoneOffset.ofHours(-18));
- assertSerializable(test);
- }
-
- @Test
- public void test_serialization_endOfDay() throws Exception {
- ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
- Month.MARCH, 20, DayOfWeek.FRIDAY, LocalTime.MIDNIGHT, true, TimeDefinition.UTC,
- OFFSET_0200, OFFSET_0200, OFFSET_0300);
- assertSerializable(test);
- }
-
- @Test
- public void test_serialization_unusualTime() throws Exception {
- ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
- Month.MARCH, 20, DayOfWeek.WEDNESDAY, LocalTime.of(13, 34, 56), false, TimeDefinition.STANDARD,
- OFFSET_0200, OFFSET_0200, OFFSET_0300);
- assertSerializable(test);
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionRuleSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,136 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2010-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.zone.serial;
+
+import java.time.DayOfWeek;
+import java.time.LocalTime;
+import java.time.Month;
+import java.time.ZoneOffset;
+import java.time.zone.ZoneOffsetTransitionRule;
+import java.time.zone.ZoneOffsetTransitionRule.TimeDefinition;
+
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+/**
+ * Test ZoneOffsetTransitionRule serialization.
+ */
+@Test
+public class TCKZoneOffsetTransitionRuleSerialization extends AbstractTCKTest {
+
+ private static final LocalTime TIME_0100 = LocalTime.of(1, 0);
+ private static final ZoneOffset OFFSET_0200 = ZoneOffset.ofHours(2);
+ private static final ZoneOffset OFFSET_0300 = ZoneOffset.ofHours(3);
+
+
+ //-----------------------------------------------------------------------
+ // Test serialization
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization_unusualOffsets() throws Exception {
+ ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
+ Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD,
+ ZoneOffset.ofHoursMinutesSeconds(-12, -20, -50),
+ ZoneOffset.ofHoursMinutesSeconds(-4, -10, -34),
+ ZoneOffset.ofHours(-18));
+ assertSerializable(test);
+ }
+
+ @Test
+ public void test_serialization_endOfDay() throws Exception {
+ ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
+ Month.MARCH, 20, DayOfWeek.FRIDAY, LocalTime.MIDNIGHT, true, TimeDefinition.UTC,
+ OFFSET_0200, OFFSET_0200, OFFSET_0300);
+ assertSerializable(test);
+ }
+
+ @Test
+ public void test_serialization_unusualTime() throws Exception {
+ ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
+ Month.MARCH, 20, DayOfWeek.WEDNESDAY, LocalTime.of(13, 34, 56), false, TimeDefinition.STANDARD,
+ OFFSET_0200, OFFSET_0200, OFFSET_0300);
+ assertSerializable(test);
+ }
+
+ @Test
+ public void test_serialization_floatingWeek() throws Exception {
+ ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
+ Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
+ OFFSET_0200, OFFSET_0200, OFFSET_0300);
+ assertSerializable(test);
+ }
+
+ @Test
+ public void test_serialization_floatingWeekBackwards() throws Exception {
+ ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
+ Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL,
+ OFFSET_0200, OFFSET_0200, OFFSET_0300);
+ assertSerializable(test);
+ }
+
+ @Test
+ public void test_serialization_fixedDate() throws Exception {
+ ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(
+ Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL,
+ OFFSET_0200, OFFSET_0200, OFFSET_0300);
+ assertSerializable(test);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneOffsetTransitionSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2010-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.zone.serial;
+
+import static java.time.temporal.ChronoUnit.HOURS;
+
+import java.time.Duration;
+import org.testng.annotations.Test;
+import tck.java.time.AbstractTCKTest;
+
+import java.time.LocalDateTime;
+import java.time.Year;
+import java.time.ZoneOffset;
+import java.time.zone.ZoneOffsetTransition;
+
+/**
+ * Test serialization of ZoneOffsetTransition.
+ */
+@Test
+public class TCKZoneOffsetTransitionSerialization extends AbstractTCKTest {
+
+ private static final ZoneOffset OFFSET_0200 = ZoneOffset.ofHours(2);
+ private static final ZoneOffset OFFSET_0300 = ZoneOffset.ofHours(3);
+
+ //-----------------------------------------------------------------------
+ @Test
+ public void test_serialization_unusual1() throws Exception {
+ LocalDateTime ldt = LocalDateTime.of(Year.MAX_VALUE, 12, 31, 1, 31, 53);
+ ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, ZoneOffset.of("+02:04:56"), ZoneOffset.of("-10:02:34"));
+ assertSerializable(test);
+ }
+
+ @Test
+ public void test_serialization_unusual2() throws Exception {
+ LocalDateTime ldt = LocalDateTime.of(Year.MIN_VALUE, 1, 1, 12, 1, 3);
+ ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, ZoneOffset.of("+02:04:56"), ZoneOffset.of("+10:02:34"));
+ assertSerializable(test);
+ }
+
+ @Test
+ public void test_serialization_gap() throws Exception {
+ LocalDateTime before = LocalDateTime.of(2010, 3, 31, 1, 0);
+ LocalDateTime after = LocalDateTime.of(2010, 3, 31, 2, 0);
+ ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0200, OFFSET_0300);
+ assertSerializable(test);
+ }
+
+ @Test
+ public void test_serialization_overlap() throws Exception {
+ LocalDateTime before = LocalDateTime.of(2010, 10, 31, 1, 0);
+ LocalDateTime after = LocalDateTime.of(2010, 10, 31, 0, 0);
+ ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0300, OFFSET_0200);
+ assertSerializable(test);
+ }
+
+}
--- a/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneRules.java Thu Aug 22 10:01:47 2013 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * This file is available under and governed by the GNU General Public
- * License version 2 only, as published by the Free Software Foundation.
- * However, the following notice accompanied the original version of this
- * file:
- *
- * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
- *
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * * Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * * Neither the name of JSR-310 nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-package tck.java.time.zone.serial;
-
-import org.testng.annotations.Test;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.time.ZoneId;
-import java.time.zone.ZoneRules;
-
-import static org.testng.Assert.assertEquals;
-
-/**
- * Test ZoneRules.
- */
-@Test
-public class TCKZoneRules {
-
- public void test_serialization_loaded() throws Exception {
- assertSerialization(europeLondon());
- assertSerialization(europeParis());
- assertSerialization(americaNewYork());
- }
-
- private void assertSerialization(ZoneRules test) throws Exception {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(test);
- baos.close();
- byte[] bytes = baos.toByteArray();
-
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream in = new ObjectInputStream(bais);
- ZoneRules result = (ZoneRules) in.readObject();
-
- assertEquals(result, test);
- }
-
- //-----------------------------------------------------------------------
- // Europe/London
- //-----------------------------------------------------------------------
- private ZoneRules europeLondon() {
- return ZoneId.of("Europe/London").getRules();
- }
-
-
- //-----------------------------------------------------------------------
- // Europe/Paris
- //-----------------------------------------------------------------------
- private ZoneRules europeParis() {
- return ZoneId.of("Europe/Paris").getRules();
- }
-
- //-----------------------------------------------------------------------
- // America/New_York
- //-----------------------------------------------------------------------
- private ZoneRules americaNewYork() {
- return ZoneId.of("America/New_York").getRules();
- }
-
-
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/time/tck/java/time/zone/serial/TCKZoneRulesSerialization.java Thu Oct 03 15:16:14 2013 -0400
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * This file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file:
+ *
+ * Copyright (c) 2008-2012, Stephen Colebourne & Michael Nascimento Santos
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * * Neither the name of JSR-310 nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package tck.java.time.zone.serial;
+
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.time.ZoneId;
+import java.time.zone.ZoneRules;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * Test serialization of ZoneRules.
+ */
+@Test
+public class TCKZoneRulesSerialization {
+
+ public void test_serialization_loaded() throws Exception {
+ assertSerialization(europeLondon());
+ assertSerialization(europeParis());
+ assertSerialization(americaNewYork());
+ }
+
+ private void assertSerialization(ZoneRules test) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(baos);
+ out.writeObject(test);
+ baos.close();
+ byte[] bytes = baos.toByteArray();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream in = new ObjectInputStream(bais);
+ ZoneRules result = (ZoneRules) in.readObject();
+
+ assertEquals(result, test);
+ }
+
+ //-----------------------------------------------------------------------
+ // Europe/London
+ //-----------------------------------------------------------------------
+ private ZoneRules europeLondon() {
+ return ZoneId.of("Europe/London").getRules();
+ }
+
+
+ //-----------------------------------------------------------------------
+ // Europe/Paris
+ //-----------------------------------------------------------------------
+ private ZoneRules europeParis() {
+ return ZoneId.of("Europe/Paris").getRules();
+ }
+
+ //-----------------------------------------------------------------------
+ // America/New_York
+ //-----------------------------------------------------------------------
+ private ZoneRules americaNewYork() {
+ return ZoneId.of("America/New_York").getRules();
+ }
+
+
+}
--- a/jdk/test/java/time/test/java/time/AbstractTest.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/test/java/time/AbstractTest.java Thu Oct 03 15:16:14 2013 -0400
@@ -63,11 +63,6 @@
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
@@ -87,27 +82,6 @@
return true;
}
- protected static void assertSerializable(Object o) throws IOException, ClassNotFoundException {
- Object deserialisedObject = writeThenRead(o);
- assertEquals(deserialisedObject, o);
- }
-
- protected static void assertSerializableAndSame(Object o) throws IOException, ClassNotFoundException {
- Object deserialisedObject = writeThenRead(o);
- assertSame(deserialisedObject, o);
- }
-
- private static Object writeThenRead(Object o) throws IOException, ClassNotFoundException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try (ObjectOutputStream oos = new ObjectOutputStream(baos) ) {
- oos.writeObject(o);
- }
-
- try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()))) {
- return ois.readObject();
- }
- }
-
protected static void assertImmutable(Class<?> cls) {
assertTrue(Modifier.isPublic(cls.getModifiers()));
assertTrue(Modifier.isFinal(cls.getModifiers()));
--- a/jdk/test/java/time/test/java/time/TestDuration.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/test/java/time/TestDuration.java Thu Oct 03 15:16:14 2013 -0400
@@ -63,11 +63,6 @@
import static org.testng.Assert.assertSame;
import static org.testng.Assert.assertTrue;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
import java.time.Duration;
import org.testng.annotations.Test;
@@ -84,29 +79,6 @@
assertImmutable(Duration.class);
}
- //-----------------------------------------------------------------------
- @Test
- public void test_interfaces() {
- assertTrue(Serializable.class.isAssignableFrom(Duration.class));
- assertTrue(Comparable.class.isAssignableFrom(Duration.class));
- }
-
- //-----------------------------------------------------------------------
- // serialization
- //-----------------------------------------------------------------------
- @Test
- public void test_deserializationSingleton() throws Exception {
- Duration orginal = Duration.ZERO;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(orginal);
- out.close();
- ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
- ObjectInputStream in = new ObjectInputStream(bais);
- Duration ser = (Duration) in.readObject();
- assertSame(ser, Duration.ZERO);
- }
-
@Test
public void plus_zeroReturnsThis() {
Duration t = Duration.ofSeconds(-1);
--- a/jdk/test/java/time/test/java/time/temporal/TestDateTimeValueRange.java Thu Aug 22 10:01:47 2013 -0700
+++ b/jdk/test/java/time/test/java/time/temporal/TestDateTimeValueRange.java Thu Oct 03 15:16:14 2013 -0400
@@ -88,19 +88,6 @@
}
//-----------------------------------------------------------------------
- // Serialization
- //-----------------------------------------------------------------------
- public void test_serialization() throws Exception {
- Object obj = ValueRange.of(1, 2, 3, 4);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(obj);
- oos.close();
- ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
- assertEquals(ois.readObject(), obj);
- }
-
- //-----------------------------------------------------------------------
// of(long,long)
//-----------------------------------------------------------------------
public void test_of_longlong() {