From 32f5b23cd758ebc3696020e3bd699766959469f8 Mon Sep 17 00:00:00 2001 From: erikj Date: Wed, 3 Jul 2013 10:14:02 +0200 Subject: 8012146: Improve tool support Reviewed-by: ksrini, dholmes, alanb, anthony --- test/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/Makefile b/test/Makefile index de6b4a783..aac9ef422 100644 --- a/test/Makefile +++ b/test/Makefile @@ -521,7 +521,8 @@ jdk_other: $(call TestDirs, \ com/sun/org/apache/xerces \ com/sun/corba \ com/sun/tracing \ - sun/usagetracker) + sun/usagetracker \ + misc) $(call RunAgentvmBatch) # Stable agentvm testruns (minus items from PROBLEM_LIST) -- cgit v1.2.3 From 3b9707c9da2642f272ea0a2b1a3421046b368a7a Mon Sep 17 00:00:00 2001 From: rriggs Date: Thu, 26 Sep 2013 23:05:29 -0700 Subject: 8025720: Separate temporal interface layer Summary: Remove ZoneId and Chronology from TemporalField interface Reviewed-by: sherman Contributed-by: scolebourne@joda.org --- .../time/tck/java/time/format/TCKDateTimeParseResolver.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java b/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java index 4ef01317b..b99d9bb47 100644 --- a/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java +++ b/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java @@ -927,8 +927,7 @@ public class TCKDateTimeParseResolver { } @Override public TemporalAccessor resolve( - Map fieldValues, Chronology chronology, - ZoneId zone, ResolverStyle resolverStyle) { + Map fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) { return LocalTime.MIDNIGHT.plusNanos(fieldValues.remove(this)); } }; @@ -979,8 +978,7 @@ public class TCKDateTimeParseResolver { } @Override public TemporalAccessor resolve( - Map fieldValues, Chronology chronology, - ZoneId zone, ResolverStyle resolverStyle) { + Map fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) { fieldValues.remove(this); return LocalDateTime.of(2010, 6, 30, 12, 30); } @@ -1032,8 +1030,7 @@ public class TCKDateTimeParseResolver { } @Override public TemporalAccessor resolve( - Map fieldValues, Chronology chronology, - ZoneId zone, ResolverStyle resolverStyle) { + Map fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) { return ThaiBuddhistChronology.INSTANCE.dateNow(); } }; @@ -1082,8 +1079,7 @@ public class TCKDateTimeParseResolver { } @Override public TemporalAccessor resolve( - Map fieldValues, Chronology chronology, - ZoneId zone, ResolverStyle resolverStyle) { + Map fieldValues, TemporalAccessor partialTemporal, ResolverStyle resolverStyle) { return ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, ZoneId.of("Europe/Paris")); } }; -- cgit v1.2.3 From a1b2a1a708a23fb37ff2d1080e79dec025226df6 Mon Sep 17 00:00:00 2001 From: scolebourne Date: Tue, 9 Jul 2013 21:35:04 +0100 Subject: 8025719: Change Chronology to an interface Summary: Split Chronology and add AbstractChronology Reviewed-by: darcy Contributed-by: scolebourne@joda.org --- test/java/time/tck/java/time/chrono/CopticChronology.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/java/time/tck/java/time/chrono/CopticChronology.java b/test/java/time/tck/java/time/chrono/CopticChronology.java index c111eed36..c72b7370d 100644 --- a/test/java/time/tck/java/time/chrono/CopticChronology.java +++ b/test/java/time/tck/java/time/chrono/CopticChronology.java @@ -59,13 +59,11 @@ package tck.java.time.chrono; import static java.time.temporal.ChronoField.EPOCH_DAY; import java.io.Serializable; - +import java.time.chrono.AbstractChronology; +import java.time.chrono.Era; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.time.temporal.ValueRange; -import java.time.chrono.Chronology; -import java.time.chrono.Era; - import java.util.Arrays; import java.util.List; import java.util.Locale; @@ -95,7 +93,7 @@ import java.util.Locale; *

Implementation notes

* This class is immutable and thread-safe. */ -public final class CopticChronology extends Chronology implements Serializable { +public final class CopticChronology extends AbstractChronology implements Serializable { /** * Singleton instance of the Coptic chronology. -- cgit v1.2.3 From 77d582abe684b588a27f2d42d05cfdc9db3df4f4 Mon Sep 17 00:00:00 2001 From: michaelm Date: Thu, 18 Jul 2013 18:52:14 +0100 Subject: 8015743: Address internet addresses Reviewed-by: alanb, khazra, skoivu --- .../java/net/Inet6Address/serialize/Serialize.java | 181 ++++++++++++++++++++- 1 file changed, 179 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/java/net/Inet6Address/serialize/Serialize.java b/test/java/net/Inet6Address/serialize/Serialize.java index c563c8b11..f7c6fe735 100644 --- a/test/java/net/Inet6Address/serialize/Serialize.java +++ b/test/java/net/Inet6Address/serialize/Serialize.java @@ -94,7 +94,26 @@ public class Serialize { } finally { ois.close(); } - System.out.println(nobj); + + nobj = (Inet6Address)InetAddress.getByAddress("foo.com", new byte[] { + (byte)0xfe,(byte)0x80,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0, + (byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)1 + }); + if (!test1(nobj, addr1)) { + throw new RuntimeException("failed with " + nobj.toString()); + } + nobj = (Inet6Address)InetAddress.getByAddress("x.bar.com", new byte[] { + (byte)0xfe,(byte)0xC0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0, + (byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)0,(byte)1 + }); + if (!test1(nobj, addr2)) { + throw new RuntimeException("failed with " + nobj.toString()); + } + nobj = (Inet6Address)InetAddress.getByName("::1"); + if (!test1(nobj, addr3)) { + throw new RuntimeException("failed with " + nobj.toString()); + } + System.out.println("All tests passed"); } @@ -113,4 +132,162 @@ public class Serialize { return false; } } - } + + static boolean test1 (Inet6Address obj, byte[] buf) throws Exception { + ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buf)); + Inet6Address nobj = (Inet6Address) ois.readObject(); + ois.close(); + + if (nobj.equals(obj)) { + return true; + } else { + return false; + } + } + + // Inet6Address instances serialized with JDK 6 + + static byte[] addr1 = { + (byte)0xac,(byte)0xed,(byte)0x00,(byte)0x05,(byte)0x73,(byte)0x72, + (byte)0x00,(byte)0x15,(byte)0x6a,(byte)0x61,(byte)0x76,(byte)0x61, + (byte)0x2e,(byte)0x6e,(byte)0x65,(byte)0x74,(byte)0x2e,(byte)0x49, + (byte)0x6e,(byte)0x65,(byte)0x74,(byte)0x36,(byte)0x41,(byte)0x64, + (byte)0x64,(byte)0x72,(byte)0x65,(byte)0x73,(byte)0x73,(byte)0x5f, + (byte)0x7c,(byte)0x20,(byte)0x81,(byte)0x52,(byte)0x2c,(byte)0x80, + (byte)0x21,(byte)0x03,(byte)0x00,(byte)0x05,(byte)0x49,(byte)0x00, + (byte)0x08,(byte)0x73,(byte)0x63,(byte)0x6f,(byte)0x70,(byte)0x65, + (byte)0x5f,(byte)0x69,(byte)0x64,(byte)0x5a,(byte)0x00,(byte)0x0c, + (byte)0x73,(byte)0x63,(byte)0x6f,(byte)0x70,(byte)0x65,(byte)0x5f, + (byte)0x69,(byte)0x64,(byte)0x5f,(byte)0x73,(byte)0x65,(byte)0x74, + (byte)0x5a,(byte)0x00,(byte)0x10,(byte)0x73,(byte)0x63,(byte)0x6f, + (byte)0x70,(byte)0x65,(byte)0x5f,(byte)0x69,(byte)0x66,(byte)0x6e, + (byte)0x61,(byte)0x6d,(byte)0x65,(byte)0x5f,(byte)0x73,(byte)0x65, + (byte)0x74,(byte)0x4c,(byte)0x00,(byte)0x06,(byte)0x69,(byte)0x66, + (byte)0x6e,(byte)0x61,(byte)0x6d,(byte)0x65,(byte)0x74,(byte)0x00, + (byte)0x12,(byte)0x4c,(byte)0x6a,(byte)0x61,(byte)0x76,(byte)0x61, + (byte)0x2f,(byte)0x6c,(byte)0x61,(byte)0x6e,(byte)0x67,(byte)0x2f, + (byte)0x53,(byte)0x74,(byte)0x72,(byte)0x69,(byte)0x6e,(byte)0x67, + (byte)0x3b,(byte)0x5b,(byte)0x00,(byte)0x09,(byte)0x69,(byte)0x70, + (byte)0x61,(byte)0x64,(byte)0x64,(byte)0x72,(byte)0x65,(byte)0x73, + (byte)0x73,(byte)0x74,(byte)0x00,(byte)0x02,(byte)0x5b,(byte)0x42, + (byte)0x78,(byte)0x72,(byte)0x00,(byte)0x14,(byte)0x6a,(byte)0x61, + (byte)0x76,(byte)0x61,(byte)0x2e,(byte)0x6e,(byte)0x65,(byte)0x74, + (byte)0x2e,(byte)0x49,(byte)0x6e,(byte)0x65,(byte)0x74,(byte)0x41, + (byte)0x64,(byte)0x64,(byte)0x72,(byte)0x65,(byte)0x73,(byte)0x73, + (byte)0x2d,(byte)0x9b,(byte)0x57,(byte)0xaf,(byte)0x9f,(byte)0xe3, + (byte)0xeb,(byte)0xdb,(byte)0x02,(byte)0x00,(byte)0x03,(byte)0x49, + (byte)0x00,(byte)0x07,(byte)0x61,(byte)0x64,(byte)0x64,(byte)0x72, + (byte)0x65,(byte)0x73,(byte)0x73,(byte)0x49,(byte)0x00,(byte)0x06, + (byte)0x66,(byte)0x61,(byte)0x6d,(byte)0x69,(byte)0x6c,(byte)0x79, + (byte)0x4c,(byte)0x00,(byte)0x08,(byte)0x68,(byte)0x6f,(byte)0x73, + (byte)0x74,(byte)0x4e,(byte)0x61,(byte)0x6d,(byte)0x65,(byte)0x71, + (byte)0x00,(byte)0x7e,(byte)0x00,(byte)0x01,(byte)0x78,(byte)0x70, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x02,(byte)0x74,(byte)0x00,(byte)0x07,(byte)0x66, + (byte)0x6f,(byte)0x6f,(byte)0x2e,(byte)0x63,(byte)0x6f,(byte)0x6d, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x70,(byte)0x75,(byte)0x72,(byte)0x00,(byte)0x02,(byte)0x5b, + (byte)0x42,(byte)0xac,(byte)0xf3,(byte)0x17,(byte)0xf8,(byte)0x06, + (byte)0x08,(byte)0x54,(byte)0xe0,(byte)0x02,(byte)0x00,(byte)0x00, + (byte)0x78,(byte)0x70,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x10, + (byte)0xfe,(byte)0x80,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01,(byte)0x78 + }; + + static byte[] addr2 = { + (byte)0xac,(byte)0xed,(byte)0x00,(byte)0x05,(byte)0x73,(byte)0x72, + (byte)0x00,(byte)0x15,(byte)0x6a,(byte)0x61,(byte)0x76,(byte)0x61, + (byte)0x2e,(byte)0x6e,(byte)0x65,(byte)0x74,(byte)0x2e,(byte)0x49, + (byte)0x6e,(byte)0x65,(byte)0x74,(byte)0x36,(byte)0x41,(byte)0x64, + (byte)0x64,(byte)0x72,(byte)0x65,(byte)0x73,(byte)0x73,(byte)0x5f, + (byte)0x7c,(byte)0x20,(byte)0x81,(byte)0x52,(byte)0x2c,(byte)0x80, + (byte)0x21,(byte)0x03,(byte)0x00,(byte)0x05,(byte)0x49,(byte)0x00, + (byte)0x08,(byte)0x73,(byte)0x63,(byte)0x6f,(byte)0x70,(byte)0x65, + (byte)0x5f,(byte)0x69,(byte)0x64,(byte)0x5a,(byte)0x00,(byte)0x0c, + (byte)0x73,(byte)0x63,(byte)0x6f,(byte)0x70,(byte)0x65,(byte)0x5f, + (byte)0x69,(byte)0x64,(byte)0x5f,(byte)0x73,(byte)0x65,(byte)0x74, + (byte)0x5a,(byte)0x00,(byte)0x10,(byte)0x73,(byte)0x63,(byte)0x6f, + (byte)0x70,(byte)0x65,(byte)0x5f,(byte)0x69,(byte)0x66,(byte)0x6e, + (byte)0x61,(byte)0x6d,(byte)0x65,(byte)0x5f,(byte)0x73,(byte)0x65, + (byte)0x74,(byte)0x4c,(byte)0x00,(byte)0x06,(byte)0x69,(byte)0x66, + (byte)0x6e,(byte)0x61,(byte)0x6d,(byte)0x65,(byte)0x74,(byte)0x00, + (byte)0x12,(byte)0x4c,(byte)0x6a,(byte)0x61,(byte)0x76,(byte)0x61, + (byte)0x2f,(byte)0x6c,(byte)0x61,(byte)0x6e,(byte)0x67,(byte)0x2f, + (byte)0x53,(byte)0x74,(byte)0x72,(byte)0x69,(byte)0x6e,(byte)0x67, + (byte)0x3b,(byte)0x5b,(byte)0x00,(byte)0x09,(byte)0x69,(byte)0x70, + (byte)0x61,(byte)0x64,(byte)0x64,(byte)0x72,(byte)0x65,(byte)0x73, + (byte)0x73,(byte)0x74,(byte)0x00,(byte)0x02,(byte)0x5b,(byte)0x42, + (byte)0x78,(byte)0x72,(byte)0x00,(byte)0x14,(byte)0x6a,(byte)0x61, + (byte)0x76,(byte)0x61,(byte)0x2e,(byte)0x6e,(byte)0x65,(byte)0x74, + (byte)0x2e,(byte)0x49,(byte)0x6e,(byte)0x65,(byte)0x74,(byte)0x41, + (byte)0x64,(byte)0x64,(byte)0x72,(byte)0x65,(byte)0x73,(byte)0x73, + (byte)0x2d,(byte)0x9b,(byte)0x57,(byte)0xaf,(byte)0x9f,(byte)0xe3, + (byte)0xeb,(byte)0xdb,(byte)0x02,(byte)0x00,(byte)0x03,(byte)0x49, + (byte)0x00,(byte)0x07,(byte)0x61,(byte)0x64,(byte)0x64,(byte)0x72, + (byte)0x65,(byte)0x73,(byte)0x73,(byte)0x49,(byte)0x00,(byte)0x06, + (byte)0x66,(byte)0x61,(byte)0x6d,(byte)0x69,(byte)0x6c,(byte)0x79, + (byte)0x4c,(byte)0x00,(byte)0x08,(byte)0x68,(byte)0x6f,(byte)0x73, + (byte)0x74,(byte)0x4e,(byte)0x61,(byte)0x6d,(byte)0x65,(byte)0x71, + (byte)0x00,(byte)0x7e,(byte)0x00,(byte)0x01,(byte)0x78,(byte)0x70, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x02,(byte)0x74,(byte)0x00,(byte)0x09,(byte)0x78, + (byte)0x2e,(byte)0x62,(byte)0x61,(byte)0x72,(byte)0x2e,(byte)0x63, + (byte)0x6f,(byte)0x6d,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x70,(byte)0x75,(byte)0x72,(byte)0x00, + (byte)0x02,(byte)0x5b,(byte)0x42,(byte)0xac,(byte)0xf3,(byte)0x17, + (byte)0xf8,(byte)0x06,(byte)0x08,(byte)0x54,(byte)0xe0,(byte)0x02, + (byte)0x00,(byte)0x00,(byte)0x78,(byte)0x70,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x10,(byte)0xfe,(byte)0xc0,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x01, + (byte)0x78 + }; + + static byte[] addr3 = { + (byte)0xac,(byte)0xed,(byte)0x00,(byte)0x05,(byte)0x73,(byte)0x72, + (byte)0x00,(byte)0x15,(byte)0x6a,(byte)0x61,(byte)0x76,(byte)0x61, + (byte)0x2e,(byte)0x6e,(byte)0x65,(byte)0x74,(byte)0x2e,(byte)0x49, + (byte)0x6e,(byte)0x65,(byte)0x74,(byte)0x36,(byte)0x41,(byte)0x64, + (byte)0x64,(byte)0x72,(byte)0x65,(byte)0x73,(byte)0x73,(byte)0x5f, + (byte)0x7c,(byte)0x20,(byte)0x81,(byte)0x52,(byte)0x2c,(byte)0x80, + (byte)0x21,(byte)0x03,(byte)0x00,(byte)0x05,(byte)0x49,(byte)0x00, + (byte)0x08,(byte)0x73,(byte)0x63,(byte)0x6f,(byte)0x70,(byte)0x65, + (byte)0x5f,(byte)0x69,(byte)0x64,(byte)0x5a,(byte)0x00,(byte)0x0c, + (byte)0x73,(byte)0x63,(byte)0x6f,(byte)0x70,(byte)0x65,(byte)0x5f, + (byte)0x69,(byte)0x64,(byte)0x5f,(byte)0x73,(byte)0x65,(byte)0x74, + (byte)0x5a,(byte)0x00,(byte)0x10,(byte)0x73,(byte)0x63,(byte)0x6f, + (byte)0x70,(byte)0x65,(byte)0x5f,(byte)0x69,(byte)0x66,(byte)0x6e, + (byte)0x61,(byte)0x6d,(byte)0x65,(byte)0x5f,(byte)0x73,(byte)0x65, + (byte)0x74,(byte)0x4c,(byte)0x00,(byte)0x06,(byte)0x69,(byte)0x66, + (byte)0x6e,(byte)0x61,(byte)0x6d,(byte)0x65,(byte)0x74,(byte)0x00, + (byte)0x12,(byte)0x4c,(byte)0x6a,(byte)0x61,(byte)0x76,(byte)0x61, + (byte)0x2f,(byte)0x6c,(byte)0x61,(byte)0x6e,(byte)0x67,(byte)0x2f, + (byte)0x53,(byte)0x74,(byte)0x72,(byte)0x69,(byte)0x6e,(byte)0x67, + (byte)0x3b,(byte)0x5b,(byte)0x00,(byte)0x09,(byte)0x69,(byte)0x70, + (byte)0x61,(byte)0x64,(byte)0x64,(byte)0x72,(byte)0x65,(byte)0x73, + (byte)0x73,(byte)0x74,(byte)0x00,(byte)0x02,(byte)0x5b,(byte)0x42, + (byte)0x78,(byte)0x72,(byte)0x00,(byte)0x14,(byte)0x6a,(byte)0x61, + (byte)0x76,(byte)0x61,(byte)0x2e,(byte)0x6e,(byte)0x65,(byte)0x74, + (byte)0x2e,(byte)0x49,(byte)0x6e,(byte)0x65,(byte)0x74,(byte)0x41, + (byte)0x64,(byte)0x64,(byte)0x72,(byte)0x65,(byte)0x73,(byte)0x73, + (byte)0x2d,(byte)0x9b,(byte)0x57,(byte)0xaf,(byte)0x9f,(byte)0xe3, + (byte)0xeb,(byte)0xdb,(byte)0x02,(byte)0x00,(byte)0x03,(byte)0x49, + (byte)0x00,(byte)0x07,(byte)0x61,(byte)0x64,(byte)0x64,(byte)0x72, + (byte)0x65,(byte)0x73,(byte)0x73,(byte)0x49,(byte)0x00,(byte)0x06, + (byte)0x66,(byte)0x61,(byte)0x6d,(byte)0x69,(byte)0x6c,(byte)0x79, + (byte)0x4c,(byte)0x00,(byte)0x08,(byte)0x68,(byte)0x6f,(byte)0x73, + (byte)0x74,(byte)0x4e,(byte)0x61,(byte)0x6d,(byte)0x65,(byte)0x71, + (byte)0x00,(byte)0x7e,(byte)0x00,(byte)0x01,(byte)0x78,(byte)0x70, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x02,(byte)0x70,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x70,(byte)0x75,(byte)0x72, + (byte)0x00,(byte)0x02,(byte)0x5b,(byte)0x42,(byte)0xac,(byte)0xf3, + (byte)0x17,(byte)0xf8,(byte)0x06,(byte)0x08,(byte)0x54,(byte)0xe0, + (byte)0x02,(byte)0x00,(byte)0x00,(byte)0x78,(byte)0x70,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x10,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00, + (byte)0x01,(byte)0x78 + }; +} -- cgit v1.2.3 From 7db9849873ff6f4166d400fb3a246a9637ec7081 Mon Sep 17 00:00:00 2001 From: okutsu Date: Fri, 19 Jul 2013 12:14:34 +0900 Subject: 8001029: Add new date/time capability Reviewed-by: mchung, hawtin --- .../java/util/TimeZone/SetDefaultSecurityTest.java | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 test/java/util/TimeZone/SetDefaultSecurityTest.java (limited to 'test') diff --git a/test/java/util/TimeZone/SetDefaultSecurityTest.java b/test/java/util/TimeZone/SetDefaultSecurityTest.java new file mode 100644 index 000000000..e749ffe94 --- /dev/null +++ b/test/java/util/TimeZone/SetDefaultSecurityTest.java @@ -0,0 +1,67 @@ +/* + * 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. 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. + */ + +/* + * @test + * @bug 8001029 + * @summary Make sure that TimeZone.setDefault throws a SecurityException if the + * security manager doesn't permit. + * @run main/othervm SetDefaultSecurityTest + */ + +import java.util.SimpleTimeZone; +import java.util.TimeZone; + +public class SetDefaultSecurityTest { + static final TimeZone NOWHERE = new SimpleTimeZone(Integer.MAX_VALUE, "Nowhere"); + + public static void main(String[] args) { + TimeZone defaultZone = TimeZone.getDefault(); + + // Make sure that TimeZone.setDefault works for trusted code + TimeZone.setDefault(NOWHERE); + if (!NOWHERE.equals(TimeZone.getDefault())) { + new RuntimeException("TimeZone.setDefault doesn't work for trusted code."); + } + // Restore defaultZone + TimeZone.setDefault(defaultZone); + if (!defaultZone.equals(TimeZone.getDefault())) { + new RuntimeException("TimeZone.setDefault doesn't restore defaultZone."); + } + + // Install a SecurityManager. + System.setSecurityManager(new SecurityManager()); + try { + TimeZone.setDefault(NOWHERE); + throw new RuntimeException("TimeZone.setDefault doesn't throw a SecurityException."); + } catch (SecurityException se) { + // OK + } + TimeZone tz = TimeZone.getDefault(); + if (!defaultZone.equals(tz)) { + throw new RuntimeException("Default TimeZone changed: " + tz); + } + } +} -- cgit v1.2.3 From c0ef1e516d1ffedd8a0a1458eaaaa1498f87d1b6 Mon Sep 17 00:00:00 2001 From: jbachorik Date: Fri, 19 Jul 2013 16:29:26 +0200 Subject: 8019584: javax/management/remote/mandatory/loading/MissingClassTest.java failed in nightly against jdk7u45: java.io.InvalidObjectException: Invalid notification: null Reviewed-by: mchung, sjiang, dfuchs, ahgross --HG-- extra : rebase_source : 5662c73937b9cdb37c95712cd5472de77b099342 --- test/javax/management/remote/mandatory/loading/MissingClassTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/javax/management/remote/mandatory/loading/MissingClassTest.java b/test/javax/management/remote/mandatory/loading/MissingClassTest.java index e70d0adfe..98eead895 100644 --- a/test/javax/management/remote/mandatory/loading/MissingClassTest.java +++ b/test/javax/management/remote/mandatory/loading/MissingClassTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4915825 4921009 4934965 4977469 + * @bug 4915825 4921009 4934965 4977469 8019584 * @summary Tests behavior when client or server gets object of unknown class * @author Eamonn McManus * @run clean MissingClassTest SingleClassLoader -- cgit v1.2.3 From 130aecc85fbe88523820b5602c4b3fd9744c981a Mon Sep 17 00:00:00 2001 From: twisti Date: Mon, 12 Aug 2013 13:47:21 -0700 Subject: 8022066: Evaluation of method reference to signature polymorphic method crashes VM Reviewed-by: jrose --- test/java/lang/invoke/MethodHandleConstants.java | 188 +++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 test/java/lang/invoke/MethodHandleConstants.java (limited to 'test') diff --git a/test/java/lang/invoke/MethodHandleConstants.java b/test/java/lang/invoke/MethodHandleConstants.java new file mode 100644 index 000000000..57e041ba7 --- /dev/null +++ b/test/java/lang/invoke/MethodHandleConstants.java @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2010, 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. + */ + +/* @test + * @bug 8022066 + * @summary smoke test for method handle constants + * @build indify.Indify + * @compile MethodHandleConstants.java + * @run main/othervm + * indify.Indify + * --verify-specifier-count=0 + * --expand-properties --classpath ${test.classes} + * --java test.java.lang.invoke.MethodHandleConstants --check-output + * @run main/othervm + * indify.Indify + * --expand-properties --classpath ${test.classes} + * --java test.java.lang.invoke.MethodHandleConstants --security-manager + */ + +package test.java.lang.invoke; + +import java.util.*; +import java.io.*; +import java.lang.invoke.*; +import java.security.*; + +import static java.lang.invoke.MethodHandles.*; +import static java.lang.invoke.MethodType.*; + +public class MethodHandleConstants { + public static void main(String... av) throws Throwable { + if (av.length > 0 && av[0].equals("--check-output")) openBuf(); + if (av.length > 0 && av[0].equals("--security-manager")) setSM(); + System.out.println("Obtaining method handle constants:"); + testCase(MH_String_replace_C2(), String.class, "replace", String.class, String.class, char.class, char.class); + testCase(MH_MethodHandle_invokeExact_SC2(), MethodHandle.class, "invokeExact", String.class, MethodHandle.class, String.class, char.class, char.class); + testCase(MH_MethodHandle_invoke_SC2(), MethodHandle.class, "invoke", String.class, MethodHandle.class, String.class, char.class, char.class); + testCase(MH_Class_forName_S(), Class.class, "forName", Class.class, String.class); + testCase(MH_Class_forName_SbCL(), Class.class, "forName", Class.class, String.class, boolean.class, ClassLoader.class); + System.out.println("Done."); + closeBuf(); + } + + private static void testCase(MethodHandle mh, Class defc, String name, Class rtype, Class... ptypes) throws Throwable { + System.out.println(mh); + // we include defc, because we assume it is a non-static MH: + MethodType mt = methodType(rtype, ptypes); + assertEquals(mh.type(), mt); + // FIXME: Use revealDirect to find out more + } + private static void assertEquals(Object exp, Object act) { + if (exp == act || (exp != null && exp.equals(act))) return; + throw new AssertionError("not equal: "+exp+", "+act); + } + + private static void setSM() { + Policy.setPolicy(new TestPolicy()); + System.setSecurityManager(new SecurityManager()); + } + + private static PrintStream oldOut; + private static ByteArrayOutputStream buf; + private static void openBuf() { + oldOut = System.out; + buf = new ByteArrayOutputStream(); + System.setOut(new PrintStream(buf)); + } + private static void closeBuf() { + if (buf == null) return; + System.out.flush(); + System.setOut(oldOut); + String[] haveLines = new String(buf.toByteArray()).split("[\n\r]+"); + for (String line : haveLines) System.out.println(line); + Iterator iter = Arrays.asList(haveLines).iterator(); + for (String want : EXPECT_OUTPUT) { + String have = iter.hasNext() ? iter.next() : "[EOF]"; + if (want.equals(have)) continue; + System.err.println("want line: "+want); + System.err.println("have line: "+have); + throw new AssertionError("unexpected output: "+have); + } + if (iter.hasNext()) + throw new AssertionError("unexpected output: "+iter.next()); + } + private static final String[] EXPECT_OUTPUT = { + "Obtaining method handle constants:", + "MethodHandle(String,char,char)String", + "MethodHandle(MethodHandle,String,char,char)String", + "MethodHandle(MethodHandle,String,char,char)String", + "MethodHandle(String)Class", + "MethodHandle(String,boolean,ClassLoader)Class", + "Done." + }; + + // String.replace(String, char, char) + private static MethodType MT_String_replace_C2() { + shouldNotCallThis(); + return methodType(String.class, char.class, char.class); + } + private static MethodHandle MH_String_replace_C2() throws ReflectiveOperationException { + shouldNotCallThis(); + return lookup().findVirtual(String.class, "replace", MT_String_replace_C2()); + } + + // MethodHandle.invokeExact(...) + private static MethodType MT_MethodHandle_invokeExact_SC2() { + shouldNotCallThis(); + return methodType(String.class, String.class, char.class, char.class); + } + private static MethodHandle MH_MethodHandle_invokeExact_SC2() throws ReflectiveOperationException { + shouldNotCallThis(); + return lookup().findVirtual(MethodHandle.class, "invokeExact", MT_MethodHandle_invokeExact_SC2()); + } + + // MethodHandle.invoke(...) + private static MethodType MT_MethodHandle_invoke_SC2() { + shouldNotCallThis(); + return methodType(String.class, String.class, char.class, char.class); + } + private static MethodHandle MH_MethodHandle_invoke_SC2() throws ReflectiveOperationException { + shouldNotCallThis(); + return lookup().findVirtual(MethodHandle.class, "invoke", MT_MethodHandle_invoke_SC2()); + } + + // Class.forName(String) + private static MethodType MT_Class_forName_S() { + shouldNotCallThis(); + return methodType(Class.class, String.class); + } + private static MethodHandle MH_Class_forName_S() throws ReflectiveOperationException { + shouldNotCallThis(); + return lookup().findStatic(Class.class, "forName", MT_Class_forName_S()); + } + + // Class.forName(String, boolean, ClassLoader) + private static MethodType MT_Class_forName_SbCL() { + shouldNotCallThis(); + return methodType(Class.class, String.class, boolean.class, ClassLoader.class); + } + private static MethodHandle MH_Class_forName_SbCL() throws ReflectiveOperationException { + shouldNotCallThis(); + return lookup().findStatic(Class.class, "forName", MT_Class_forName_SbCL()); + } + + private static void shouldNotCallThis() { + // if this gets called, the transformation has not taken place + if (System.getProperty("MethodHandleConstants.allow-untransformed") != null) return; + throw new AssertionError("this code should be statically transformed away by Indify"); + } + + static class TestPolicy extends Policy { + final PermissionCollection permissions = new Permissions(); + TestPolicy() { + permissions.add(new java.io.FilePermission("<>", "read")); + } + public PermissionCollection getPermissions(ProtectionDomain domain) { + return permissions; + } + + public PermissionCollection getPermissions(CodeSource codesource) { + return permissions; + } + + public boolean implies(ProtectionDomain domain, Permission perm) { + return permissions.implies(perm); + } + } +} -- cgit v1.2.3 From 560c48dd4bf6a116acc02ede4020dfe02e05fd83 Mon Sep 17 00:00:00 2001 From: erikj Date: Mon, 19 Aug 2013 12:30:48 +0200 Subject: 8022719: tools/launcher/RunpathTest.java fails after 8012146 Reviewed-by: chegar --- test/tools/launcher/RunpathTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/tools/launcher/RunpathTest.java b/test/tools/launcher/RunpathTest.java index 631be16d9..675d7630d 100644 --- a/test/tools/launcher/RunpathTest.java +++ b/test/tools/launcher/RunpathTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 7190813 + * @bug 7190813, 8022719 * @summary Check for extended RPATHs on *nixes * @compile -XDignore.symbol.file RunpathTest.java * @run main RunpathTest @@ -65,12 +65,10 @@ public class RunpathTest extends TestHelper { void testRpath() { if (isDualMode && is64Bit) { - String expectedRpath = ".*RPATH.*\\$ORIGIN/../../lib/" + getJreArch() - + ":\\$ORIGIN/../../jre/lib/" + getJreArch() + ".*"; + String expectedRpath = ".*RPATH.*\\$ORIGIN/../../lib/" + getJreArch() + ".*"; elfCheck(java64Cmd, expectedRpath); } else { - String expectedRpath = ".*RPATH.*\\$ORIGIN/../lib/" + getJreArch() - + ":\\$ORIGIN/../jre/lib/" + getJreArch() + ".*"; + String expectedRpath = ".*RPATH.*\\$ORIGIN/../lib/" + getJreArch() + ".*"; elfCheck(javaCmd, expectedRpath); } } -- cgit v1.2.3 From 511156563af851ed4e4014ed35415392f93c766c Mon Sep 17 00:00:00 2001 From: erikj Date: Mon, 19 Aug 2013 14:48:08 +0200 Subject: 8023231: Remove comma from jtreg bug line Reviewed-by: alanb, chegar --- test/tools/launcher/RunpathTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/tools/launcher/RunpathTest.java b/test/tools/launcher/RunpathTest.java index 675d7630d..79b8b0ecc 100644 --- a/test/tools/launcher/RunpathTest.java +++ b/test/tools/launcher/RunpathTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 7190813, 8022719 + * @bug 7190813 8022719 * @summary Check for extended RPATHs on *nixes * @compile -XDignore.symbol.file RunpathTest.java * @run main RunpathTest -- cgit v1.2.3 From 0c101d3700eeaf17e6e5f1c08ae84e5a0cfb7b81 Mon Sep 17 00:00:00 2001 From: vinnie Date: Wed, 9 Oct 2013 10:48:44 +0100 Subject: 8008171: Refactor KeyStore.DomainLoadStoreParameter as a standalone class Reviewed-by: mullan, weijun --- test/sun/security/provider/KeyStore/DKSTest.java | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'test') diff --git a/test/sun/security/provider/KeyStore/DKSTest.java b/test/sun/security/provider/KeyStore/DKSTest.java index c2b6baf3a..d1c4f18fc 100644 --- a/test/sun/security/provider/KeyStore/DKSTest.java +++ b/test/sun/security/provider/KeyStore/DKSTest.java @@ -81,8 +81,7 @@ public class DKSTest { int expected; KeyStore keystore = KeyStore.getInstance("DKS"); // load entries - keystore.load( - new KeyStore.DomainLoadStoreParameter(config, PASSWORDS)); + keystore.load(new DomainLoadStoreParameter(config, PASSWORDS)); cacertsCount = expected = keystore.size(); System.out.println("\nLoading domain keystore: " + config + "\t[" + expected + " entries]"); @@ -95,8 +94,7 @@ public class DKSTest { expected = cacertsCount + 1; keystore = KeyStore.getInstance("DKS"); // load entries - keystore.load( - new KeyStore.DomainLoadStoreParameter(config, PASSWORDS)); + keystore.load(new DomainLoadStoreParameter(config, PASSWORDS)); System.out.println("\nLoading domain keystore: " + config + "\t[" + expected + " entries]"); checkEntries(keystore, expected); @@ -109,7 +107,7 @@ public class DKSTest { keystore = KeyStore.getInstance("DKS"); // load entries keystore.load( - new KeyStore.DomainLoadStoreParameter(config, + new DomainLoadStoreParameter(config, Collections.emptyMap())); System.out.println("\nLoading domain keystore: " + config + "\t[" + expected + " entries]"); @@ -129,8 +127,7 @@ public class DKSTest { expected = 0; keystore = KeyStore.getInstance("DKS"); // load entries - keystore.load( - new KeyStore.DomainLoadStoreParameter(config, PASSWORDS)); + keystore.load(new DomainLoadStoreParameter(config, PASSWORDS)); System.out.println("\nLoading domain keystore: " + config + "\t[" + expected + " entries]"); checkEntries(keystore, expected); @@ -142,8 +139,7 @@ public class DKSTest { expected = 2 + 1 + 1 + 1; keystore = KeyStore.getInstance("DKS"); // load entries - keystore.load( - new KeyStore.DomainLoadStoreParameter(config, PASSWORDS)); + keystore.load(new DomainLoadStoreParameter(config, PASSWORDS)); System.out.println("\nLoading domain keystore: " + config + "\t[" + expected + " entries]"); checkEntries(keystore, expected); @@ -158,12 +154,10 @@ public class DKSTest { config = new URI(CONFIG + "#keystores_tmp"); System.out.println("Storing domain keystore: " + config + "\t[" + expected + " entries]"); - keystore.store( - new KeyStore.DomainLoadStoreParameter(config, PASSWORDS)); + keystore.store(new DomainLoadStoreParameter(config, PASSWORDS)); keystore = KeyStore.getInstance("DKS"); // reload entries - keystore.load( - new KeyStore.DomainLoadStoreParameter(config, PASSWORDS)); + keystore.load(new DomainLoadStoreParameter(config, PASSWORDS)); System.out.println("Reloading domain keystore: " + config + "\t[" + expected + " entries]"); checkEntries(keystore, expected); -- cgit v1.2.3 From 5cae1e3dda2c21d748c9b5d58347390e7b6849f0 Mon Sep 17 00:00:00 2001 From: mchung Date: Wed, 9 Oct 2013 06:24:42 -0700 Subject: 8026027: Level.parse should return the custom Level instance instead of the mirrored Level Reviewed-by: dfuchs, chegar --- test/java/util/logging/Level/CustomLevel.java | 96 ++++++++++++++++++++++ test/java/util/logging/Level/myresource.properties | 5 ++ 2 files changed, 101 insertions(+) create mode 100644 test/java/util/logging/Level/CustomLevel.java create mode 100644 test/java/util/logging/Level/myresource.properties (limited to 'test') diff --git a/test/java/util/logging/Level/CustomLevel.java b/test/java/util/logging/Level/CustomLevel.java new file mode 100644 index 000000000..a3c452a1e --- /dev/null +++ b/test/java/util/logging/Level/CustomLevel.java @@ -0,0 +1,96 @@ +/* + * 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. + */ + +import java.io.*; +import java.util.*; +import java.util.logging.*; + +/* + * @test + * @bug 8026027 + * @summary Test Level.parse to look up custom levels by name and its + * localized name + * + * @run main/othervm CustomLevel + */ + +public class CustomLevel extends Level { + public CustomLevel(String name, int value, String resourceBundleName) { + super(name, value, resourceBundleName); + } + + private static final List levels = new ArrayList<>(); + private static final String RB_NAME = "myresource"; + public static void main(String[] args) throws Exception { + setupCustomLevels(); + + // Level.parse will return the custom Level instance + ResourceBundle rb = ResourceBundle.getBundle(RB_NAME); + for (Level level : levels) { + String name = level.getName(); + if (!name.equals("WARNING") && !name.equals("INFO")) { + // custom level whose name doesn't conflict with any standard one + checkCustomLevel(Level.parse(name), level); + } + String localizedName = rb.getString(level.getName()); + Level l = Level.parse(localizedName); + if (l != level) { + throw new RuntimeException("Unexpected level " + l + " " + l.getClass()); + } + } + } + + private static void setupCustomLevels() throws IOException { + levels.add(new CustomLevel("EMERGENCY", 1090, RB_NAME)); + levels.add(new CustomLevel("ALERT", 1060, RB_NAME)); + levels.add(new CustomLevel("CRITICAL", 1030, RB_NAME)); + levels.add(new CustomLevel("WARNING", 1010, RB_NAME)); + levels.add(new CustomLevel("INFO", 1000, RB_NAME)); + } + static void checkCustomLevel(Level level, Level expected) { + // Level value must be the same + if (!level.equals(expected)) { + throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected)); + } + + if (!level.getName().equals(expected.getName())) { + throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected)); + } + + // Level.parse is expected to return the custom Level + if (level != expected) { + throw new RuntimeException(formatLevel(level) + " != " + formatLevel(expected)); + } + + ResourceBundle rb = ResourceBundle.getBundle(RB_NAME); + String name = rb.getString(level.getName()); + if (!level.getLocalizedName().equals(name)) { + // must have the same localized name + throw new RuntimeException(level.getLocalizedName() + " != " + name); + } + } + + static String formatLevel(Level l) { + return l + ":" + l.intValue() + ":" + l.getClass().getName(); + } +} diff --git a/test/java/util/logging/Level/myresource.properties b/test/java/util/logging/Level/myresource.properties new file mode 100644 index 000000000..2c8c41205 --- /dev/null +++ b/test/java/util/logging/Level/myresource.properties @@ -0,0 +1,5 @@ +EMERGENCY=localized.emergency +ALERT=localized.alert +CRITICAL=localized.critical +WARNING=localized.warning +INFO=localized.info -- cgit v1.2.3 From 319101f24a472e9ddafcf994a187d35c8b69c3cd Mon Sep 17 00:00:00 2001 From: rriggs Date: Wed, 9 Oct 2013 11:02:55 -0400 Subject: 8024612: java/time/tck/java/time/format/TCKDateTimeFormatters.java failed Summary: The test should be using the Locale.Category.FORMAT to verify the test data Reviewed-by: lancea --- test/java/time/tck/java/time/format/TCKDateTimeFormatters.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java b/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java index f30eb9906..d431fa4ac 100644 --- a/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java +++ b/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java @@ -126,9 +126,10 @@ public class TCKDateTimeFormatters { @Test public void test_pattern_String() { DateTimeFormatter test = DateTimeFormatter.ofPattern("d MMM yyyy"); + Locale fmtLocale = Locale.getDefault(Locale.Category.FORMAT); assertEquals(test.format(LocalDate.of(2012, 6, 30)), "30 " + - Month.JUNE.getDisplayName(TextStyle.SHORT, Locale.getDefault()) + " 2012"); - assertEquals(test.getLocale(), Locale.getDefault()); + Month.JUNE.getDisplayName(TextStyle.SHORT, fmtLocale) + " 2012"); + assertEquals(test.getLocale(), fmtLocale, "Locale.Category.FORMAT"); } @Test(expectedExceptions=IllegalArgumentException.class) -- cgit v1.2.3 From 9e1116decdc051aa289b2afb81525e7ad7dc4998 Mon Sep 17 00:00:00 2001 From: rriggs Date: Thu, 26 Sep 2013 15:19:27 -0700 Subject: 8025718: Enhance error messages for parsing Summary: Add values and types to exception messages Reviewed-by: lancea Contributed-by: scolebourne@joda.org --- .../java/time/format/TestDateTimeFormatter.java | 111 ++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/java/time/test/java/time/format/TestDateTimeFormatter.java b/test/java/time/test/java/time/format/TestDateTimeFormatter.java index 540a0e89a..1bfa47993 100644 --- a/test/java/time/test/java/time/format/TestDateTimeFormatter.java +++ b/test/java/time/test/java/time/format/TestDateTimeFormatter.java @@ -61,12 +61,32 @@ package test.java.time.format; import static java.time.temporal.ChronoField.DAY_OF_MONTH; import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.fail; -import java.time.format.DecimalStyle; +import java.time.DateTimeException; +import java.time.DayOfWeek; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Month; +import java.time.MonthDay; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.Year; +import java.time.YearMonth; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.chrono.ThaiBuddhistChronology; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; +import java.time.format.DecimalStyle; import java.time.format.SignStyle; +import java.time.temporal.TemporalAccessor; import java.util.Locale; +import java.util.function.Function; import org.testng.annotations.Test; @@ -87,4 +107,93 @@ public class TestDateTimeFormatter { assertSame(test, base); } + @Test + public void test_parse_errorMessage() throws Exception { + assertGoodErrorDate(DayOfWeek::from, "DayOfWeek"); + assertGoodErrorDate(Month::from, "Month"); + assertGoodErrorDate(YearMonth::from, "YearMonth"); + assertGoodErrorDate(MonthDay::from, "MonthDay"); + assertGoodErrorDate(LocalDate::from, "LocalDate"); + assertGoodErrorDate(LocalTime::from, "LocalTime"); + assertGoodErrorDate(LocalDateTime::from, "LocalDateTime"); + assertGoodErrorDate(OffsetTime::from, "OffsetTime"); + assertGoodErrorDate(OffsetDateTime::from, "OffsetDateTime"); + assertGoodErrorDate(ZonedDateTime::from, "ZonedDateTime"); + assertGoodErrorDate(Instant::from, "Instant"); + assertGoodErrorDate(ZoneOffset::from, "ZoneOffset"); + assertGoodErrorDate(ZoneId::from, "ZoneId"); + assertGoodErrorDate(ThaiBuddhistChronology.INSTANCE::date, ""); + + assertGoodErrorTime(DayOfWeek::from, "DayOfWeek"); + assertGoodErrorTime(Month::from, "Month"); + assertGoodErrorTime(Year::from, "Year"); + assertGoodErrorTime(YearMonth::from, "YearMonth"); + assertGoodErrorTime(MonthDay::from, "MonthDay"); + assertGoodErrorTime(LocalDate::from, "LocalDate"); + assertGoodErrorTime(LocalTime::from, "LocalTime"); + assertGoodErrorTime(LocalDateTime::from, "LocalDateTime"); + assertGoodErrorTime(OffsetTime::from, "OffsetTime"); + assertGoodErrorTime(OffsetDateTime::from, "OffsetDateTime"); + assertGoodErrorTime(ZonedDateTime::from, "ZonedDateTime"); + assertGoodErrorTime(Instant::from, "Instant"); + assertGoodErrorTime(ZoneOffset::from, "ZoneOffset"); + assertGoodErrorTime(ZoneId::from, "ZoneId"); + assertGoodErrorTime(ThaiBuddhistChronology.INSTANCE::date, ""); + } + + private void assertGoodErrorDate(Function function, String expectedText) { + DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-mm-dd"); + TemporalAccessor temporal = f.parse("2010-06-30"); + try { + function.apply(temporal); + fail("Should have failed"); + } catch (DateTimeException ex) { + String msg = ex.getMessage(); + assertTrue(msg.contains(expectedText), msg); + assertTrue(msg.contains("Year"), msg); + assertTrue(msg.contains("MinuteOfHour"), msg); + assertTrue(msg.contains("DayOfMonth"), msg); + } + } + + private void assertGoodErrorTime(Function function, String expectedText) { + DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:MM:ss"); + TemporalAccessor temporal = f.parse("11:30:56"); + try { + function.apply(temporal); + fail("Should have failed"); + } catch (DateTimeException ex) { + String msg = ex.getMessage(); + assertTrue(msg.contains(expectedText), msg); + assertTrue(msg.contains("HourOfDay"), msg); + assertTrue(msg.contains("MonthOfYear"), msg); + assertTrue(msg.contains("SecondOfMinute"), msg); + } + } + + @Test + public void test_parsed_toString_resolvedTime() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("HH:mm:ss"); + TemporalAccessor temporal = f.parse("11:30:56"); + String msg = temporal.toString(); + assertTrue(msg.contains("11:30:56"), msg); + } + + @Test + public void test_parsed_toString_resolvedDate() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + TemporalAccessor temporal = f.parse("2010-06-30"); + String msg = temporal.toString(); + assertTrue(msg.contains("2010-06-30"), msg); + } + + @Test + public void test_parsed_toString_resolvedDateTime() { + DateTimeFormatter f = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + TemporalAccessor temporal = f.parse("2010-06-30 11:30:56"); + String msg = temporal.toString(); + assertTrue(msg.contains("2010-06-30"), msg); + assertTrue(msg.contains("11:30:56"), msg); + } + } -- cgit v1.2.3 From 86c648b7084e6767e429ea05d96213977f6224ba Mon Sep 17 00:00:00 2001 From: chegar Date: Mon, 7 Oct 2013 11:31:37 +0100 Subject: 8025991: tools/launcher/RunpathTest.java fails Reviewed-by: erikj --- test/tools/launcher/RunpathTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/tools/launcher/RunpathTest.java b/test/tools/launcher/RunpathTest.java index a04609934..26233b285 100644 --- a/test/tools/launcher/RunpathTest.java +++ b/test/tools/launcher/RunpathTest.java @@ -64,8 +64,8 @@ public class RunpathTest extends TestHelper { } void testRpath() { - String expectedRpath = ".*RPATH.*\\$ORIGIN/../../lib/" + getJreArch() + ".*"; - elfCheck(java64Cmd, expectedRpath); + String expectedRpath = ".*RPATH.*\\$ORIGIN/../lib/" + getJreArch() + ".*"; + elfCheck(javaCmd, expectedRpath); } public static void main(String... args) throws Exception { -- cgit v1.2.3 From 612e6c934952893c61882fe7da5071357353fb65 Mon Sep 17 00:00:00 2001 From: valeriep Date: Tue, 8 Oct 2013 11:07:31 -0700 Subject: 7196382: PKCS11 provider should support 2048-bit DH Summary: Query and enforce range checking using the values from native PKCS11 library. Reviewed-by: xuelei --- .../pkcs11/KeyPairGenerator/TestDH2048.java | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java (limited to 'test') diff --git a/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java b/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java new file mode 100644 index 000000000..c11911a12 --- /dev/null +++ b/test/sun/security/pkcs11/KeyPairGenerator/TestDH2048.java @@ -0,0 +1,66 @@ +/* + * 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. + */ + +/** + * @test + * @bug 7196382 + * @summary Ensure that 2048-bit DH key pairs can be generated + * @author Valerie Peng + * @library .. + */ + +import java.io.*; +import java.util.*; + +import java.security.*; + +import javax.crypto.*; + +public class TestDH2048 extends PKCS11Test { + + private static void checkUnsupportedKeySize(KeyPairGenerator kpg, int ks) + throws Exception { + try { + kpg.initialize(ks); + throw new Exception("Expected IPE not thrown for " + ks); + } catch (InvalidParameterException ipe) { + } + } + + public void main(Provider p) throws Exception { + if (p.getService("KeyPairGenerator", "DH") == null) { + System.out.println("KPG for DH not supported, skipping"); + return; + } + KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", p); + kpg.initialize(2048); + KeyPair kp1 = kpg.generateKeyPair(); + checkUnsupportedKeySize(kpg, 1536); + checkUnsupportedKeySize(kpg, 2176); + checkUnsupportedKeySize(kpg, 3072); + } + + public static void main(String[] args) throws Exception { + main(new TestDH2048()); + } +} -- cgit v1.2.3 From 15fc43d1844f4e4198228df40da85650258e399a Mon Sep 17 00:00:00 2001 From: valeriep Date: Tue, 8 Oct 2013 11:17:53 -0700 Subject: 8012900: CICO ignores AAD in GCM mode Summary: Change GCM decryption to not return result until tag verification passed Reviewed-by: xuelei --- .../provider/Cipher/AES/TestCICOWithGCMAndAAD.java | 105 +++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 test/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java (limited to 'test') diff --git a/test/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java b/test/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java new file mode 100644 index 000000000..816f764f9 --- /dev/null +++ b/test/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java @@ -0,0 +1,105 @@ +/* + * 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 + * questions. + */ + +/* + * @test + * @bug 8012900 + * @library ../UTIL + * @build TestUtil + * @run main TestCICOWithGCMAndAAD + * @summary Test CipherInputStream/OutputStream with AES GCM mode with AAD. + * @author Valerie Peng + */ +import java.io.*; +import java.security.*; +import java.util.*; +import javax.crypto.*; + +public class TestCICOWithGCMAndAAD { + public static void main(String[] args) throws Exception { + //init Secret Key + KeyGenerator kg = KeyGenerator.getInstance("AES", "SunJCE"); + kg.init(128); + SecretKey key = kg.generateKey(); + + //Do initialization of the plainText + byte[] plainText = new byte[700]; + Random rdm = new Random(); + rdm.nextBytes(plainText); + + byte[] aad = new byte[128]; + rdm.nextBytes(aad); + byte[] aad2 = aad.clone(); + aad2[50]++; + + Cipher encCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + encCipher.init(Cipher.ENCRYPT_MODE, key); + encCipher.updateAAD(aad); + Cipher decCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + decCipher.init(Cipher.DECRYPT_MODE, key, encCipher.getParameters()); + decCipher.updateAAD(aad); + + byte[] recovered = test(encCipher, decCipher, plainText); + if (!Arrays.equals(plainText, recovered)) { + throw new Exception("sameAAD: diff check failed!"); + } else System.out.println("sameAAD: passed"); + + encCipher.init(Cipher.ENCRYPT_MODE, key); + encCipher.updateAAD(aad2); + recovered = test(encCipher, decCipher, plainText); + if (recovered != null && recovered.length != 0) { + throw new Exception("diffAAD: no data should be returned!"); + } else System.out.println("diffAAD: passed"); + } + + private static byte[] test(Cipher encCipher, Cipher decCipher, byte[] plainText) + throws Exception { + //init cipher streams + ByteArrayInputStream baInput = new ByteArrayInputStream(plainText); + CipherInputStream ciInput = new CipherInputStream(baInput, encCipher); + ByteArrayOutputStream baOutput = new ByteArrayOutputStream(); + CipherOutputStream ciOutput = new CipherOutputStream(baOutput, decCipher); + + //do test + byte[] buffer = new byte[200]; + int len = ciInput.read(buffer); + System.out.println("read " + len + " bytes from input buffer"); + + while (len != -1) { + ciOutput.write(buffer, 0, len); + System.out.println("wite " + len + " bytes to output buffer"); + len = ciInput.read(buffer); + if (len != -1) { + System.out.println("read " + len + " bytes from input buffer"); + } else { + System.out.println("finished reading"); + } + } + + ciOutput.flush(); + ciInput.close(); + ciOutput.close(); + + return baOutput.toByteArray(); + } +} -- cgit v1.2.3 From 79a5c00712dbed8c28b1a62e47262681065cf755 Mon Sep 17 00:00:00 2001 From: valeriep Date: Tue, 8 Oct 2013 11:35:29 -0700 Subject: 8014374: Cannot initialize "AES/GCM/NoPadding" on wrap/unseal on solaris with OracleUcrypto Summary: Removed OracleUcrypto provider regression tests from OpenJDK Reviewed-by: xuelei --- test/com/oracle/security/ucrypto/TestAES.java | 339 ----------------- test/com/oracle/security/ucrypto/TestDigest.java | 127 ------- test/com/oracle/security/ucrypto/TestRSA.java | 421 ---------------------- test/com/oracle/security/ucrypto/UcryptoTest.java | 65 ---- 4 files changed, 952 deletions(-) delete mode 100644 test/com/oracle/security/ucrypto/TestAES.java delete mode 100644 test/com/oracle/security/ucrypto/TestDigest.java delete mode 100644 test/com/oracle/security/ucrypto/TestRSA.java delete mode 100644 test/com/oracle/security/ucrypto/UcryptoTest.java (limited to 'test') diff --git a/test/com/oracle/security/ucrypto/TestAES.java b/test/com/oracle/security/ucrypto/TestAES.java deleted file mode 100644 index 9f280aea0..000000000 --- a/test/com/oracle/security/ucrypto/TestAES.java +++ /dev/null @@ -1,339 +0,0 @@ -/* - * Copyright (c) 2012, 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. - */ - -/* - * @test - * @bug 7088989 - * @summary Ensure the AES ciphers of OracleUcrypto provider works correctly - */ -import java.io.*; -import java.security.*; -import java.security.spec.*; -import java.util.*; -import javax.crypto.*; -import javax.crypto.spec.*; - -public class TestAES extends UcryptoTest { - - private static final String[] PADDEDCIPHER_ALGOS = { - "AES/ECB/PKCS5Padding", - "AES/CBC/PKCS5Padding", - "AES/CFB128/PKCS5Padding" - }; - - private static final String[] CIPHER_ALGOS = { - "AES/ECB/NoPadding", - "AES/CBC/NoPadding", - "AES/CFB128/NoPadding", - "AES/CTR/NoPadding", - }; - - private static final SecretKey CIPHER_KEY = - new SecretKeySpec(new byte[16], "AES"); - - public static void main(String[] args) throws Exception { - main(new TestAES(), null); - } - - public void doTest(Provider prov) throws Exception { - // Provider for testing Interoperability - Provider sunJCEProv = Security.getProvider("SunJCE"); - - testCipherInterop(CIPHER_ALGOS, CIPHER_KEY, prov, sunJCEProv); - testCipherInterop(PADDEDCIPHER_ALGOS, CIPHER_KEY, prov, sunJCEProv); - - testCipherOffset(CIPHER_ALGOS, CIPHER_KEY, prov); - testCipherOffset(PADDEDCIPHER_ALGOS, CIPHER_KEY, prov); - - testCipherKeyWrapping(PADDEDCIPHER_ALGOS, CIPHER_KEY, prov, sunJCEProv); - testCipherGCM(CIPHER_KEY, prov); - } - - private static void testCipherInterop(String[] algos, SecretKey key, - Provider p, - Provider interopP) { - boolean testPassed = true; - byte[] in = new byte[32]; - (new SecureRandom()).nextBytes(in); - - for (String algo : algos) { - try { - // check ENC - Cipher c; - try { - c = Cipher.getInstance(algo, p); - } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skipping Unsupported CIP algo: " + algo); - continue; - } - c.init(Cipher.ENCRYPT_MODE, key, (AlgorithmParameters)null, null); - byte[] eout = c.doFinal(in, 0, in.length); - - AlgorithmParameters params = c.getParameters(); - Cipher c2 = Cipher.getInstance(algo, interopP); - c2.init(Cipher.ENCRYPT_MODE, key, params, null); - byte[] eout2 = c2.doFinal(in, 0, in.length); - - if (!Arrays.equals(eout, eout2)) { - System.out.println(algo + ": DIFF FAILED"); - testPassed = false; - } else { - System.out.println(algo + ": ENC Passed"); - } - - // check DEC - c.init(Cipher.DECRYPT_MODE, key, params, null); - byte[] dout = c.doFinal(eout); - c2.init(Cipher.DECRYPT_MODE, key, params, null); - byte[] dout2 = c2.doFinal(eout2); - - if (!Arrays.equals(dout, dout2)) { - System.out.println(algo + ": DIFF FAILED"); - testPassed = false; - } else { - System.out.println(algo + ": DEC Passed"); - } - } catch(Exception ex) { - System.out.println("Unexpected Exception: " + algo); - ex.printStackTrace(); - testPassed = false; - } - } - - if (!testPassed) { - throw new RuntimeException("One or more CIPHER test failed!"); - } else { - System.out.println("CIPHER Interop Tests Passed"); - } - } - - private static void testCipherOffset(String[] algos, SecretKey key, - Provider p) { - boolean testPassed = true; - byte[] in = new byte[16]; - (new SecureRandom()).nextBytes(in); - int blockSize = 16; - - for (int j = 1; j < (in.length - 1); j++) { - System.out.println("Input offset size: " + j); - for (int i = 0; i < algos.length; i++) { - try { - // check ENC - Cipher c; - try { - c = Cipher.getInstance(algos[i], p); - } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skip Unsupported CIP algo: " + algos[i]); - continue; - } - c.init(Cipher.ENCRYPT_MODE, key, (AlgorithmParameters)null, null); - byte[] eout = new byte[c.getOutputSize(in.length)]; - int firstPartLen = in.length - j - 1; - //System.out.print("1st UPDATE: " + firstPartLen); - int k = c.update(in, 0, firstPartLen, eout, 0); - k += c.update(in, firstPartLen, 1, eout, k); - k += c.doFinal(in, firstPartLen+1, j, eout, k); - - AlgorithmParameters params = c.getParameters(); - - Cipher c2 = Cipher.getInstance(algos[i], p); - c2.init(Cipher.ENCRYPT_MODE, key, params, null); - byte[] eout2 = new byte[c2.getOutputSize(in.length)]; - int k2 = c2.update(in, 0, j, eout2, 0); - k2 += c2.update(in, j, 1, eout2, k2); - k2 += c2.doFinal(in, j+1, firstPartLen, eout2, k2); - - if (!checkArrays(eout, k, eout2, k2)) testPassed = false; - - // check DEC - c.init(Cipher.DECRYPT_MODE, key, params, null); - byte[] dout = new byte[c.getOutputSize(eout.length)]; - k = c.update(eout, 0, firstPartLen, dout, 0); - k += c.update(eout, firstPartLen, 1, dout, k); - k += c.doFinal(eout, firstPartLen+1, eout.length - firstPartLen - 1, dout, k); - if (!checkArrays(in, in.length, dout, k)) testPassed = false; - } catch(Exception ex) { - System.out.println("Unexpected Exception: " + algos[i]); - ex.printStackTrace(); - testPassed = false; - } - } - } - if (!testPassed) { - throw new RuntimeException("One or more CIPHER test failed!"); - } else { - System.out.println("CIPHER Offset Tests Passed"); - } - } - - private static void testCipherKeyWrapping(String[] algos, SecretKey key, - Provider p, Provider interopP) - throws NoSuchAlgorithmException { - boolean testPassed = true; - - // Test SecretKey, PrivateKey and PublicKey - Key[] tbwKeys = new Key[3]; - int[] tbwKeyTypes = { Cipher.SECRET_KEY, Cipher.PRIVATE_KEY, Cipher.PUBLIC_KEY }; - tbwKeys[0] = new SecretKeySpec(new byte[20], "Blowfish"); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); - kpg.initialize(1024); - KeyPair kp = kpg.generateKeyPair(); - tbwKeys[1] = kp.getPrivate(); - tbwKeys[2] = kp.getPublic(); - - for (int i = 0; i < algos.length; i++) { - try { - System.out.println(algos[i] + " - Native WRAP/Java UNWRAP"); - - Cipher c1; - try { - c1 = Cipher.getInstance(algos[i], p); - } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skipping Unsupported CIP algo: " + algos[i]); - continue; - } - c1.init(Cipher.WRAP_MODE, key, (AlgorithmParameters)null, null); - AlgorithmParameters params = c1.getParameters(); - Cipher c2 = Cipher.getInstance(algos[i], interopP); - c2.init(Cipher.UNWRAP_MODE, key, params, null); - - for (int j = 0; j < tbwKeys.length ; j++) { - byte[] wrappedKey = c1.wrap(tbwKeys[j]); - Key recovered = c2.unwrap(wrappedKey, - tbwKeys[j].getAlgorithm(), tbwKeyTypes[j]); - if (!checkKeys(tbwKeys[j], recovered)) testPassed = false; - } - - System.out.println(algos[i] + " - Java WRAP/Native UNWRAP"); - c1 = Cipher.getInstance(algos[i], interopP); - c1.init(Cipher.WRAP_MODE, key, (AlgorithmParameters)null, null); - params = c1.getParameters(); - c2 = Cipher.getInstance(algos[i], p); - c2.init(Cipher.UNWRAP_MODE, key, params, null); - - for (int j = 0; j < tbwKeys.length ; j++) { - byte[] wrappedKey = c1.wrap(tbwKeys[j]); - Key recovered = c2.unwrap(wrappedKey, - tbwKeys[j].getAlgorithm(), tbwKeyTypes[j]); - if (!checkKeys(tbwKeys[j], recovered)) testPassed = false; - } - - } catch(Exception ex) { - System.out.println("Unexpected Exception: " + algos[i]); - ex.printStackTrace(); - testPassed = false; - } - } - if (!testPassed) { - throw new RuntimeException("One or more CIPHER test failed!"); - } else { - System.out.println("CIPHER KeyWrapping Tests Passed"); - } - } - - - private static void testCipherGCM(SecretKey key, - Provider p) { - boolean testPassed = true; - byte[] in = new byte[16]; - (new SecureRandom()).nextBytes(in); - - byte[] iv = new byte[16]; - (new SecureRandom()).nextBytes(iv); - - - String algo = "AES/GCM/NoPadding"; - int tagLen[] = { 128, 120, 112, 104, 96, 64, 32 }; - - try { - Cipher c; - try { - c = Cipher.getInstance(algo, p); - } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skipping Unsupported CIP algo: " + algo); - return; - } - for (int i = 0; i < tagLen.length; i++) { - AlgorithmParameterSpec paramSpec = new GCMParameterSpec(tagLen[i], iv); - // check ENC - c.init(Cipher.ENCRYPT_MODE, key, paramSpec, null); - c.updateAAD(iv); - byte[] eout = c.doFinal(in, 0, in.length); - - AlgorithmParameters param = c.getParameters(); - // check DEC - c.init(Cipher.DECRYPT_MODE, key, param, null); - c.updateAAD(iv); - byte[] dout = c.doFinal(eout, 0, eout.length); - - if (!Arrays.equals(dout, in)) { - System.out.println(algo + ": PT and RT DIFF FAILED"); - testPassed = false; - } else { - System.out.println(algo + ": tagLen " + tagLen[i] + " done"); - } - } - } catch(Exception ex) { - System.out.println("Unexpected Exception: " + algo); - ex.printStackTrace(); - testPassed = false; - } - if (!testPassed) { - throw new RuntimeException("One or more CIPHER test failed!"); - } else { - System.out.println("CIPHER GCM Tests Passed"); - } - } - - private static boolean checkArrays(byte[] a1, int a1Len, byte[] a2, int a2Len) { - boolean equal = true; - if (a1Len != a2Len) { - System.out.println("DIFFERENT OUT LENGTH"); - equal = false; - } else { - for (int p = 0; p < a1Len; p++) { - if (a1[p] != a2[p]) { - System.out.println("DIFF FAILED"); - equal = false; - break; - } - } - } - return equal; - } - - private static boolean checkKeys(Key k1, Key k2) { - boolean equal = true; - if (!k1.getAlgorithm().equalsIgnoreCase(k2.getAlgorithm())) { - System.out.println("DIFFERENT Key Algorithm"); - equal = false; - } else if (!k1.getFormat().equalsIgnoreCase(k2.getFormat())) { - System.out.println("DIFFERENT Key Format"); - equal = false; - } else if (!Arrays.equals(k1.getEncoded(), k2.getEncoded())) { - System.out.println("DIFFERENT Key Encoding"); - equal = false; - } - return equal; - } -} diff --git a/test/com/oracle/security/ucrypto/TestDigest.java b/test/com/oracle/security/ucrypto/TestDigest.java deleted file mode 100644 index 3bc85dc23..000000000 --- a/test/com/oracle/security/ucrypto/TestDigest.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2012, 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. - */ - -/* - * @test - * @bug 7088989 - * @summary Ensure the various message digests works correctly - */ -import java.io.*; -import java.security.*; -import java.security.spec.*; -import java.util.*; -import javax.crypto.*; -import javax.crypto.spec.*; - -public class TestDigest extends UcryptoTest { - - private static final String[] MD_ALGOS = { - "MD5", - "SHA", - "SHA-256", - "SHA-384", - "SHA-512" - }; - - public static void main(String[] args) throws Exception { - main(new TestDigest(), null); - } - - public void doTest(Provider p) { - boolean testPassed = true; - byte[] msg = new byte[200]; - (new SecureRandom()).nextBytes(msg); - String interopProvName = "SUN"; - - for (String a : MD_ALGOS) { - try { - MessageDigest md, md2; - try { - md = MessageDigest.getInstance(a, p); - } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skipping Unsupported MD algo: " + a); - continue; - } - md2 = MessageDigest.getInstance(a, interopProvName); - // Test Interoperability for update+digest calls - for (int i = 0; i < 3; i++) { - md.update(msg); - byte[] digest = md.digest(); - md2.update(msg); - byte[] digest2 = md2.digest(); - if (!Arrays.equals(digest, digest2)) { - System.out.println("DIFF1 FAILED for: " + a + " at iter " + i); - testPassed = false; - } - } - - // Test Interoperability for digest calls - md = MessageDigest.getInstance(a, p); - md2 = MessageDigest.getInstance(a, interopProvName); - - for (int i = 0; i < 3; i++) { - byte[] digest = md.digest(); - byte[] digest2 = md2.digest(); - if (!Arrays.equals(digest, digest2)) { - System.out.println("DIFF2 FAILED for: " + a + " at iter " + i); - testPassed = false; - } - } - - // Test Cloning functionality - md = MessageDigest.getInstance(a, p); - md2 = (MessageDigest) md.clone(); // clone right after construction - byte[] digest = md.digest(); - byte[] digest2 = md2.digest(); - if (!Arrays.equals(digest, digest2)) { - System.out.println("DIFF-3.1 FAILED for: " + a); - testPassed = false; - } - md.update(msg); - md2 = (MessageDigest) md.clone(); // clone again after update call - digest = md.digest(); - digest2 = md2.digest(); - if (!Arrays.equals(digest, digest2)) { - System.out.println("DIFF-3.2 FAILED for: " + a); - testPassed = false; - } - md2 = (MessageDigest) md.clone(); // clone after digest - digest = md.digest(); - digest2 = md2.digest(); - if (!Arrays.equals(digest, digest2)) { - System.out.println("DIFF-3.3 FAILED for: " + a); - testPassed = false; - } - } catch(Exception ex) { - System.out.println("Unexpected Exception: " + a); - ex.printStackTrace(); - testPassed = false; - } - } - if (!testPassed) { - throw new RuntimeException("One or more MD test failed!"); - } else { - System.out.println("MD Tests Passed"); - } - } -} diff --git a/test/com/oracle/security/ucrypto/TestRSA.java b/test/com/oracle/security/ucrypto/TestRSA.java deleted file mode 100644 index 3f4364e27..000000000 --- a/test/com/oracle/security/ucrypto/TestRSA.java +++ /dev/null @@ -1,421 +0,0 @@ -/* - * Copyright (c) 2012, 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. - */ - -/* - * @test - * @bug 7088989 - * @summary Ensure the RSA ciphers and signatures works correctly - */ -import java.io.*; -import java.security.*; -import java.security.spec.*; -import java.util.*; -import java.math.*; -import javax.crypto.*; - -public class TestRSA extends UcryptoTest { - - // KAT - private static final byte PLAINTEXT[] = Arrays.copyOf - (new String("Known plaintext message utilized" + - "for RSA Encryption & Decryption" + - "block, SHA1, SHA256, SHA384 and" + - "SHA512 RSA Signature KAT tests.").getBytes(), 128); - - private static final byte MOD[] = { - (byte)0xd5, (byte)0x84, (byte)0x95, (byte)0x07, (byte)0xf4, (byte)0xd0, - (byte)0x1f, (byte)0x82, (byte)0xf3, (byte)0x79, (byte)0xf4, (byte)0x99, - (byte)0x48, (byte)0x10, (byte)0xe1, (byte)0x71, (byte)0xa5, (byte)0x62, - (byte)0x22, (byte)0xa3, (byte)0x4b, (byte)0x00, (byte)0xe3, (byte)0x5b, - (byte)0x3a, (byte)0xcc, (byte)0x10, (byte)0x83, (byte)0xe0, (byte)0xaf, - (byte)0x61, (byte)0x13, (byte)0x54, (byte)0x6a, (byte)0xa2, (byte)0x6a, - (byte)0x2c, (byte)0x5e, (byte)0xb3, (byte)0xcc, (byte)0xa3, (byte)0x71, - (byte)0x9a, (byte)0xb2, (byte)0x3e, (byte)0x78, (byte)0xec, (byte)0xb5, - (byte)0x0e, (byte)0x6e, (byte)0x31, (byte)0x3b, (byte)0x77, (byte)0x1f, - (byte)0x6e, (byte)0x94, (byte)0x41, (byte)0x60, (byte)0xd5, (byte)0x6e, - (byte)0xd9, (byte)0xc6, (byte)0xf9, (byte)0x29, (byte)0xc3, (byte)0x40, - (byte)0x36, (byte)0x25, (byte)0xdb, (byte)0xea, (byte)0x0b, (byte)0x07, - (byte)0xae, (byte)0x76, (byte)0xfd, (byte)0x99, (byte)0x29, (byte)0xf4, - (byte)0x22, (byte)0xc1, (byte)0x1a, (byte)0x8f, (byte)0x05, (byte)0xfe, - (byte)0x98, (byte)0x09, (byte)0x07, (byte)0x05, (byte)0xc2, (byte)0x0f, - (byte)0x0b, (byte)0x11, (byte)0x83, (byte)0x39, (byte)0xca, (byte)0xc7, - (byte)0x43, (byte)0x63, (byte)0xff, (byte)0x33, (byte)0x80, (byte)0xe7, - (byte)0xc3, (byte)0x78, (byte)0xae, (byte)0xf1, (byte)0x73, (byte)0x52, - (byte)0x98, (byte)0x1d, (byte)0xde, (byte)0x5c, (byte)0x53, (byte)0x6e, - (byte)0x01, (byte)0x73, (byte)0x0d, (byte)0x12, (byte)0x7e, (byte)0x77, - (byte)0x03, (byte)0xf1, (byte)0xef, (byte)0x1b, (byte)0xc8, (byte)0xa8, - (byte)0x0f, (byte)0x97 - }; - - private static final byte PUB_EXP[] = {(byte)0x01, (byte)0x00, (byte)0x01}; - - private static final byte PRIV_EXP[] = { - (byte)0x85, (byte)0x27, (byte)0x47, (byte)0x61, (byte)0x4c, (byte)0xd4, - (byte)0xb5, (byte)0xb2, (byte)0x0e, (byte)0x70, (byte)0x91, (byte)0x8f, - (byte)0x3d, (byte)0x97, (byte)0xf9, (byte)0x5f, (byte)0xcc, (byte)0x09, - (byte)0x65, (byte)0x1c, (byte)0x7c, (byte)0x5b, (byte)0xb3, (byte)0x6d, - (byte)0x63, (byte)0x3f, (byte)0x7b, (byte)0x55, (byte)0x22, (byte)0xbb, - (byte)0x7c, (byte)0x48, (byte)0x77, (byte)0xae, (byte)0x80, (byte)0x56, - (byte)0xc2, (byte)0x10, (byte)0xd5, (byte)0x03, (byte)0xdb, (byte)0x31, - (byte)0xaf, (byte)0x8d, (byte)0x54, (byte)0xd4, (byte)0x48, (byte)0x99, - (byte)0xa8, (byte)0xc4, (byte)0x23, (byte)0x43, (byte)0xb8, (byte)0x48, - (byte)0x0b, (byte)0xc7, (byte)0xbc, (byte)0xf5, (byte)0xcc, (byte)0x64, - (byte)0x72, (byte)0xbf, (byte)0x59, (byte)0x06, (byte)0x04, (byte)0x1c, - (byte)0x32, (byte)0xf5, (byte)0x14, (byte)0x2e, (byte)0x6e, (byte)0xe2, - (byte)0x0f, (byte)0x5c, (byte)0xde, (byte)0x36, (byte)0x3c, (byte)0x6e, - (byte)0x7c, (byte)0x4d, (byte)0xcc, (byte)0xd3, (byte)0x00, (byte)0x6e, - (byte)0xe5, (byte)0x45, (byte)0x46, (byte)0xef, (byte)0x4d, (byte)0x25, - (byte)0x46, (byte)0x6d, (byte)0x7f, (byte)0xed, (byte)0xbb, (byte)0x4f, - (byte)0x4d, (byte)0x9f, (byte)0xda, (byte)0x87, (byte)0x47, (byte)0x8f, - (byte)0x74, (byte)0x44, (byte)0xb7, (byte)0xbe, (byte)0x9d, (byte)0xf5, - (byte)0xdd, (byte)0xd2, (byte)0x4c, (byte)0xa5, (byte)0xab, (byte)0x74, - (byte)0xe5, (byte)0x29, (byte)0xa1, (byte)0xd2, (byte)0x45, (byte)0x3b, - (byte)0x33, (byte)0xde, (byte)0xd5, (byte)0xae, (byte)0xf7, (byte)0x03, - (byte)0x10, (byte)0x21 - }; - - private static final byte PRIME_P[] = { - (byte)0xf9, (byte)0x74, (byte)0x8f, (byte)0x16, (byte)0x02, (byte)0x6b, - (byte)0xa0, (byte)0xee, (byte)0x7f, (byte)0x28, (byte)0x97, (byte)0x91, - (byte)0xdc, (byte)0xec, (byte)0xc0, (byte)0x7c, (byte)0x49, (byte)0xc2, - (byte)0x85, (byte)0x76, (byte)0xee, (byte)0x66, (byte)0x74, (byte)0x2d, - (byte)0x1a, (byte)0xb8, (byte)0xf7, (byte)0x2f, (byte)0x11, (byte)0x5b, - (byte)0x36, (byte)0xd8, (byte)0x46, (byte)0x33, (byte)0x3b, (byte)0xd8, - (byte)0xf3, (byte)0x2d, (byte)0xa1, (byte)0x03, (byte)0x83, (byte)0x2b, - (byte)0xec, (byte)0x35, (byte)0x43, (byte)0x32, (byte)0xff, (byte)0xdd, - (byte)0x81, (byte)0x7c, (byte)0xfd, (byte)0x65, (byte)0x13, (byte)0x04, - (byte)0x7c, (byte)0xfc, (byte)0x03, (byte)0x97, (byte)0xf0, (byte)0xd5, - (byte)0x62, (byte)0xdc, (byte)0x0d, (byte)0xbf - }; - - private static final byte PRIME_Q[] = { - (byte)0xdb, (byte)0x1e, (byte)0xa7, (byte)0x3d, (byte)0xe7, (byte)0xfa, - (byte)0x8b, (byte)0x04, (byte)0x83, (byte)0x48, (byte)0xf3, (byte)0xa5, - (byte)0x31, (byte)0x9d, (byte)0x35, (byte)0x5e, (byte)0x4d, (byte)0x54, - (byte)0x77, (byte)0xcc, (byte)0x84, (byte)0x09, (byte)0xf3, (byte)0x11, - (byte)0x0d, (byte)0x54, (byte)0xed, (byte)0x85, (byte)0x39, (byte)0xa9, - (byte)0xca, (byte)0xa8, (byte)0xea, (byte)0xae, (byte)0x19, (byte)0x9c, - (byte)0x75, (byte)0xdb, (byte)0x88, (byte)0xb8, (byte)0x04, (byte)0x8d, - (byte)0x54, (byte)0xc6, (byte)0xa4, (byte)0x80, (byte)0xf8, (byte)0x93, - (byte)0xf0, (byte)0xdb, (byte)0x19, (byte)0xef, (byte)0xd7, (byte)0x87, - (byte)0x8a, (byte)0x8f, (byte)0x5a, (byte)0x09, (byte)0x2e, (byte)0x54, - (byte)0xf3, (byte)0x45, (byte)0x24, (byte)0x29 - }; - - private static final byte EXP_P[] = { - (byte)0x6a, (byte)0xd1, (byte)0x25, (byte)0x80, (byte)0x18, (byte)0x33, - (byte)0x3c, (byte)0x2b, (byte)0x44, (byte)0x19, (byte)0xfe, (byte)0xa5, - (byte)0x40, (byte)0x03, (byte)0xc4, (byte)0xfc, (byte)0xb3, (byte)0x9c, - (byte)0xef, (byte)0x07, (byte)0x99, (byte)0x58, (byte)0x17, (byte)0xc1, - (byte)0x44, (byte)0xa3, (byte)0x15, (byte)0x7d, (byte)0x7b, (byte)0x22, - (byte)0x22, (byte)0xdf, (byte)0x03, (byte)0x58, (byte)0x66, (byte)0xf5, - (byte)0x24, (byte)0x54, (byte)0x52, (byte)0x91, (byte)0x2d, (byte)0x76, - (byte)0xfe, (byte)0x63, (byte)0x64, (byte)0x4e, (byte)0x0f, (byte)0x50, - (byte)0x2b, (byte)0x65, (byte)0x79, (byte)0x1f, (byte)0xf1, (byte)0xbf, - (byte)0xc7, (byte)0x41, (byte)0x26, (byte)0xcc, (byte)0xc6, (byte)0x1c, - (byte)0xa9, (byte)0x83, (byte)0x6f, (byte)0x03 - }; - - private static final byte EXP_Q[] = { - (byte)0x12, (byte)0x84, (byte)0x1a, (byte)0x99, (byte)0xce, (byte)0x9a, - (byte)0x8b, (byte)0x58, (byte)0xcc, (byte)0x47, (byte)0x43, (byte)0xdf, - (byte)0x77, (byte)0xbb, (byte)0xd3, (byte)0x20, (byte)0xae, (byte)0xe4, - (byte)0x2e, (byte)0x63, (byte)0x67, (byte)0xdc, (byte)0xf7, (byte)0x5f, - (byte)0x3f, (byte)0x83, (byte)0x27, (byte)0xb7, (byte)0x14, (byte)0x52, - (byte)0x56, (byte)0xbf, (byte)0xc3, (byte)0x65, (byte)0x06, (byte)0xe1, - (byte)0x03, (byte)0xcc, (byte)0x93, (byte)0x57, (byte)0x09, (byte)0x7b, - (byte)0x6f, (byte)0xe8, (byte)0x81, (byte)0x4a, (byte)0x2c, (byte)0xb7, - (byte)0x43, (byte)0xa9, (byte)0x20, (byte)0x1d, (byte)0xf6, (byte)0x56, - (byte)0x8b, (byte)0xcc, (byte)0xe5, (byte)0x4c, (byte)0xd5, (byte)0x4f, - (byte)0x74, (byte)0x67, (byte)0x29, (byte)0x51 - }; - - private static final byte CRT_COEFF[] = { - (byte)0x23, (byte)0xab, (byte)0xf4, (byte)0x03, (byte)0x2f, (byte)0x29, - (byte)0x95, (byte)0x74, (byte)0xac, (byte)0x1a, (byte)0x33, (byte)0x96, - (byte)0x62, (byte)0xed, (byte)0xf7, (byte)0xf6, (byte)0xae, (byte)0x07, - (byte)0x2a, (byte)0x2e, (byte)0xe8, (byte)0xab, (byte)0xfb, (byte)0x1e, - (byte)0xb9, (byte)0xb2, (byte)0x88, (byte)0x1e, (byte)0x85, (byte)0x05, - (byte)0x42, (byte)0x64, (byte)0x03, (byte)0xb2, (byte)0x8b, (byte)0xc1, - (byte)0x81, (byte)0x75, (byte)0xd7, (byte)0xba, (byte)0xaa, (byte)0xd4, - (byte)0x31, (byte)0x3c, (byte)0x8a, (byte)0x96, (byte)0x23, (byte)0x9d, - (byte)0x3f, (byte)0x06, (byte)0x3e, (byte)0x44, (byte)0xa9, (byte)0x62, - (byte)0x2f, (byte)0x61, (byte)0x5a, (byte)0x51, (byte)0x82, (byte)0x2c, - (byte)0x04, (byte)0x85, (byte)0x73, (byte)0xd1 - }; - - private static KeyPair genRSAKey(int keyLength) throws Exception { - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); - kpg.initialize(keyLength); - return kpg.generateKeyPair(); - } - - private static KeyPair genPredefinedRSAKeyPair() throws Exception { - KeyFactory kf = KeyFactory.getInstance("RSA"); - BigInteger mod = new BigInteger(MOD); - BigInteger pub = new BigInteger(PUB_EXP); - - PrivateKey privKey = kf.generatePrivate - (new RSAPrivateCrtKeySpec - (mod, pub, new BigInteger(PRIV_EXP), - new BigInteger(PRIME_P), new BigInteger(PRIME_Q), - new BigInteger(EXP_P), new BigInteger(EXP_Q), - new BigInteger(CRT_COEFF))); - PublicKey pubKey = kf.generatePublic(new RSAPublicKeySpec(mod, pub)); - return new KeyPair(pubKey, privKey); - } - - private static final String CIP_ALGOS[] = { - "RSA/ECB/NoPadding", - "RSA/ECB/PKCS1Padding" - }; - private static final int INPUT_SIZE_REDUCTION[] = { - 0, - 11, - }; - private static final String SIG_ALGOS[] = { - "MD5WithRSA", - "SHA1WithRSA", - "SHA256WithRSA", - "SHA384WithRSA", - "SHA512WithRSA" - }; - - private static KeyPair kp[] = null; - - public static void main(String argv[]) throws Exception { - main(new TestRSA(), null); - } - - public void doTest(Provider prov) throws Exception { - // first test w/ predefine KeyPair - KeyPair pkp = genPredefinedRSAKeyPair(); - System.out.println("Test against Predefined RSA Key Pair"); - testCipher(pkp, 128, true, prov); - testSignature(pkp, true, prov); - - for (int i = 0; i < 10; i++) { - // then test w/ various key lengths - int keyLens[] = { 1024, 2048 }; - kp = new KeyPair[keyLens.length]; - - testCipher(keyLens, false, prov); - testSignature(keyLens, false, prov); - } - } - - - private static void testCipher(KeyPair kp, int inputSizeInBytes, - boolean checkInterop, Provider prov) - throws Exception { - Cipher c1, c2; - for (int i = 0; i < CIP_ALGOS.length; i++) { - String algo = CIP_ALGOS[i]; - try { - c1 = Cipher.getInstance(algo, prov); - } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skip unsupported Cipher algo: " + algo); - continue; - } - - if (checkInterop) { - c2 = Cipher.getInstance(algo, "SunJCE"); - } else { - c2 = Cipher.getInstance(algo, prov); - } - byte[] data = Arrays.copyOf - (PLAINTEXT, inputSizeInBytes - INPUT_SIZE_REDUCTION[i]); - - testEncryption(c1, c2, kp, data); - } - } - - private static void testCipher(int keyLens[], boolean checkInterop, - Provider prov) - throws Exception { - // RSA CipherText will always differ due to the random nonce in padding - // so we check whether both - // 1) Java Encrypt/C Decrypt - // 2) C Encrypt/Java Decrypt - // works - Cipher c1, c2; - for (int i = 0; i < CIP_ALGOS.length; i++) { - String algo = CIP_ALGOS[i]; - try { - c1 = Cipher.getInstance(algo, prov); - } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skip unsupported Cipher algo: " + algo); - continue; - } - - if (checkInterop) { - c2 = Cipher.getInstance(algo, "SunJCE"); - } else { - c2 = Cipher.getInstance(algo, prov); - } - - for (int h = 0; h < keyLens.length; h++) { - // Defer key pair generation until now when it'll soon be used. - if (kp[h] == null) { - kp[h] = genRSAKey(keyLens[h]); - } - System.out.println("\tTesting Cipher " + algo + " w/ KeySize " + keyLens[h]); - byte[] data = Arrays.copyOf - (PLAINTEXT, keyLens[h]/8 - INPUT_SIZE_REDUCTION[i]); - testEncryption(c1, c2, kp[h], data); - } - } - } - - private static void testEncryption(Cipher c1, Cipher c2, KeyPair kp, byte[] data) - throws Exception { - // C1 Encrypt + C2 Decrypt - byte[] out1 = null; - byte[] recoveredText = null; - try { - c1.init(Cipher.ENCRYPT_MODE, kp.getPublic()); - out1 = c1.doFinal(data); - c2.init(Cipher.DECRYPT_MODE, kp.getPrivate()); - recoveredText = c2.doFinal(out1); - } catch (Exception ex) { - System.out.println("\tDEC ERROR: unexpected exception"); - ex.printStackTrace(); - throw ex; - } - if(!Arrays.equals(recoveredText, data)) { - throw new RuntimeException("\tDEC ERROR: different PT bytes!"); - } - // C2 Encrypt + C1 Decrypt - byte[] cipherText = null; - try { - c2.init(Cipher.ENCRYPT_MODE, kp.getPublic()); - cipherText = c2.doFinal(data); - c1.init(Cipher.DECRYPT_MODE, kp.getPrivate()); - try { - out1 = c1.doFinal(cipherText); - } catch (Exception ex) { - System.out.println("\tENC ERROR: invalid encrypted output"); - ex.printStackTrace(); - throw ex; - } - } catch (Exception ex) { - System.out.println("\tENC ERROR: unexpected exception"); - ex.printStackTrace(); - throw ex; - } - if (!Arrays.equals(out1, data)) { - throw new RuntimeException("\tENC ERROR: Decrypted result DIFF!"); - } - System.out.println("\t=> PASS"); - } - - private static void testSignature(KeyPair kp, boolean checkInterop, - Provider prov) throws Exception { - byte[] data = PLAINTEXT; - Signature sig1, sig2; - for (int i = 0; i < SIG_ALGOS.length; i++) { - String algo = SIG_ALGOS[i]; - try { - sig1 = Signature.getInstance(algo, prov); - } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skip unsupported Signature algo: " + algo); - continue; - } - - if (checkInterop) { - sig2 = Signature.getInstance(algo, "SunRsaSign"); - } else { - sig2 = Signature.getInstance(algo, prov); - } - testSigning(sig1, sig2, kp, data); - } - } - - private static void testSignature(int keyLens[], boolean checkInterop, - Provider prov) throws Exception { - byte[] data = PLAINTEXT; - Signature sig1, sig2; - for (int i = 0; i < SIG_ALGOS.length; i++) { - String algo = SIG_ALGOS[i]; - try { - sig1 = Signature.getInstance(algo, prov); - } catch (NoSuchAlgorithmException nsae) { - System.out.println("Skip unsupported Signature algo: " + algo); - continue; - } - - if (checkInterop) { - sig2 = Signature.getInstance(algo, "SunRsaSign"); - } else { - sig2 = Signature.getInstance(algo, prov); - } - - for (int h = 0; h < keyLens.length; h++) { - // Defer key pair generation until now when it'll soon be used. - if (kp[h] == null) { - kp[h] = genRSAKey(keyLens[h]); - } - System.out.println("\tTesting Signature " + algo + " w/ KeySize " + keyLens[h]); - - testSigning(sig1, sig2, kp[h], data); - } - } - } - - private static void testSigning(Signature sig1, Signature sig2, KeyPair kp, byte[] data) - throws Exception { - boolean sameSig = false; - byte[] out = null; - try { - sig1.initSign(kp.getPrivate()); - sig1.update(data); - out = sig1.sign(); - } catch (Exception ex) { - System.out.println("\tSIGN ERROR: unexpected exception!"); - ex.printStackTrace(); - } - - sig2.initSign(kp.getPrivate()); - sig2.update(data); - byte[] out2 = sig2.sign(); - if (!Arrays.equals(out2, out)) { - throw new RuntimeException("\tSIGN ERROR: Signature DIFF!"); - } - - boolean verify = false; - try { - System.out.println("\tVERIFY1 using native out"); - sig1.initVerify(kp.getPublic()); - sig1.update(data); - verify = sig1.verify(out); - if (!verify) { - throw new RuntimeException("VERIFY1 FAIL!"); - } - } catch (Exception ex) { - System.out.println("\tVERIFY1 ERROR: unexpected exception!"); - ex.printStackTrace(); - throw ex; - } - System.out.println("\t=> PASS"); - } -} diff --git a/test/com/oracle/security/ucrypto/UcryptoTest.java b/test/com/oracle/security/ucrypto/UcryptoTest.java deleted file mode 100644 index c2343c996..000000000 --- a/test/com/oracle/security/ucrypto/UcryptoTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2012, 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. - */ - - -// common infrastructure for OracleUcrypto provider tests - -import java.io.*; -import java.util.*; -import java.lang.reflect.*; - -import java.security.*; - -public abstract class UcryptoTest { - - protected static final boolean hasUcrypto; - static { - hasUcrypto = (Security.getProvider("OracleUcrypto") != null); - } - - private static Provider getCustomizedUcrypto(String config) throws Exception { - Class clazz = Class.forName("com.oracle.security.ucrypto.OracleUcrypto"); - Constructor cons = clazz.getConstructor(new Class[] {String.class}); - Object obj = cons.newInstance(new Object[] {config}); - return (Provider)obj; - } - - public abstract void doTest(Provider p) throws Exception; - - public static void main(UcryptoTest test, String config) throws Exception { - Provider prov = null; - if (hasUcrypto) { - if (config != null) { - prov = getCustomizedUcrypto(config); - } else { - prov = Security.getProvider("OracleUcrypto"); - } - } - if (prov == null) { - // un-available, skip testing... - System.out.println("No OracleUcrypto provider found, skipping test"); - return; - } - test.doTest(prov); - } -} -- cgit v1.2.3 From 2be8123e7c9f4c5befc4b04b02cd680790e860b0 Mon Sep 17 00:00:00 2001 From: henryjen Date: Wed, 9 Oct 2013 09:41:40 -0700 Subject: 8023524: Mechanism to dump generated lambda classes / log lambda code generation Reviewed-by: plevart, mchung, forax, jjb Contributed-by: brian.goetz@oracle.com, henry.jen@oracle.com --- .../invoke/lambda/LogGeneratedClassesTest.java | 208 +++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 test/java/lang/invoke/lambda/LogGeneratedClassesTest.java (limited to 'test') diff --git a/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java b/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java new file mode 100644 index 000000000..c34e6e4ae --- /dev/null +++ b/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java @@ -0,0 +1,208 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8023524 + * @summary tests logging generated classes for lambda + * @library /java/nio/file + * @run testng LogGeneratedClassesTest + */ +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.nio.file.Files; +import java.nio.file.LinkOption; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.attribute.PosixFileAttributeView; +import java.util.stream.Stream; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import org.testng.SkipException; + +import static java.nio.file.attribute.PosixFilePermissions.*; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; + +public class LogGeneratedClassesTest extends LUtils { + String longFQCN; + + @BeforeClass + public void setup() throws IOException { + final List scratch = new ArrayList<>(); + scratch.clear(); + scratch.add("package com.example;"); + scratch.add("public class TestLambda {"); + scratch.add(" interface I {"); + scratch.add(" int foo();"); + scratch.add(" }"); + scratch.add(" public static void main(String[] args) {"); + scratch.add(" I lam = () -> 10;"); + scratch.add(" Runnable r = () -> {"); + scratch.add(" System.out.println(\"Runnable\");"); + scratch.add(" };"); + scratch.add(" r.run();"); + scratch.add(" System.out.println(\"Finish\");"); + scratch.add(" }"); + scratch.add("}"); + + File test = new File("TestLambda.java"); + createFile(test, scratch); + compile("-d", ".", test.getName()); + + scratch.remove(0); + scratch.remove(0); + scratch.add(0, "public class LongPackageName {"); + StringBuilder sb = new StringBuilder("com.example."); + // longer than 255 which exceed max length of most filesystems + for (int i = 0; i < 30; i++) { + sb.append("nonsense."); + } + sb.append("enough"); + longFQCN = sb.toString() + ".LongPackageName"; + sb.append(";"); + sb.insert(0, "package "); + scratch.add(0, sb.toString()); + test = new File("LongPackageName.java"); + createFile(test, scratch); + compile("-d", ".", test.getName()); + + // create target + Files.createDirectory(Paths.get("dump")); + Files.createDirectories(Paths.get("dumpLong/com/example/nonsense")); + Files.createFile(Paths.get("dumpLong/com/example/nonsense/nonsense")); + Files.createFile(Paths.get("file")); + } + + @AfterClass + public void cleanup() throws IOException { + Files.delete(Paths.get("TestLambda.java")); + Files.delete(Paths.get("LongPackageName.java")); + Files.delete(Paths.get("file")); + TestUtil.removeAll(Paths.get("com")); + TestUtil.removeAll(Paths.get("dump")); + TestUtil.removeAll(Paths.get("dumpLong")); + } + + @Test + public void testNotLogging() { + TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), + "-cp", ".", + "-Djava.security.manager", + "com.example.TestLambda"); + tr.assertZero("Should still return 0"); + } + + @Test + public void testLogging() throws IOException { + assertTrue(Files.exists(Paths.get("dump"))); + TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), + "-cp", ".", + "-Djdk.internal.lambda.dumpProxyClasses=dump", + "-Djava.security.manager", + "com.example.TestLambda"); + // dump/com/example + 2 class files + assertEquals(Files.walk(Paths.get("dump")).count(), 5, "Two lambda captured"); + tr.assertZero("Should still return 0"); + } + + @Test + public void testDumpDirNotExist() throws IOException { + assertFalse(Files.exists(Paths.get("notExist"))); + TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), + "-cp", ".", + "-Djdk.internal.lambda.dumpProxyClasses=notExist", + "-Djava.security.manager", + "com.example.TestLambda"); + assertEquals(tr.testOutput.stream() + .filter(s -> s.startsWith("WARNING")) + .peek(s -> assertTrue(s.contains("does not exist"))) + .count(), + 1, "only show error once"); + tr.assertZero("Should still return 0"); + } + + @Test + public void testDumpDirIsFile() throws IOException { + assertTrue(Files.isRegularFile(Paths.get("file"))); + TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), + "-cp", ".", + "-Djdk.internal.lambda.dumpProxyClasses=file", + "-Djava.security.manager", + "com.example.TestLambda"); + assertEquals(tr.testOutput.stream() + .filter(s -> s.startsWith("WARNING")) + .peek(s -> assertTrue(s.contains("not a directory"))) + .count(), + 1, "only show error once"); + tr.assertZero("Should still return 0"); + } + + @Test + public void testDumpDirNotWritable() throws IOException { + if (! Files.getFileStore(Paths.get(".")) + .supportsFileAttributeView(PosixFileAttributeView.class)) { + // No easy way to setup readonly directory + throw new SkipException("Posix not supported"); + } + + Files.createDirectory(Paths.get("readOnly"), + asFileAttribute(fromString("r-xr-xr-x"))); + + TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), + "-cp", ".", + "-Djdk.internal.lambda.dumpProxyClasses=readOnly", + "-Djava.security.manager", + "com.example.TestLambda"); + assertEquals(tr.testOutput.stream() + .filter(s -> s.startsWith("WARNING")) + .peek(s -> assertTrue(s.contains("not writable"))) + .count(), + 1, "only show error once"); + tr.assertZero("Should still return 0"); + + TestUtil.removeAll(Paths.get("readOnly")); + } + + @Test + public void testLoggingException() throws IOException { + assertTrue(Files.exists(Paths.get("dumpLong"))); + TestResult tr = doExec(JAVA_CMD.getAbsolutePath(), + "-cp", ".", + "-Djdk.internal.lambda.dumpProxyClasses=dumpLong", + "-Djava.security.manager", + longFQCN); + assertEquals(tr.testOutput.stream() + .filter(s -> s.startsWith("WARNING: Exception")) + .count(), + 2, "show error each capture"); + // dumpLong/com/example/nosense/nosense + assertEquals(Files.walk(Paths.get("dumpLong")).count(), 5, "Two lambda captured failed to log"); + tr.assertZero("Should still return 0"); + } +} -- cgit v1.2.3 From 6bae64737364715a2f1e3f4fcef1636dd99d531f Mon Sep 17 00:00:00 2001 From: rriggs Date: Wed, 9 Oct 2013 13:34:37 -0400 Subject: 8024076: Incorrect 2 -> 4 year parsing and resolution in DateTimeFormatter Summary: Add appendValueReduced method based on a ChronoLocalDate to provide context for the value Reviewed-by: sherman Contributed-by: scolebourne@joda.org --- .../time/format/TCKDateTimeFormatterBuilder.java | 65 +++++++++++- .../time/format/TestDateTimeFormatterBuilder.java | 12 +-- .../test/java/time/format/TestReducedParser.java | 111 ++++++++++++++++++++- .../test/java/time/format/TestReducedPrinter.java | 64 ++++++++++-- 4 files changed, 237 insertions(+), 15 deletions(-) (limited to 'test') diff --git a/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java b/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java index cf2c3a1da..59d2ca15b 100644 --- a/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java +++ b/test/java/time/tck/java/time/format/TCKDateTimeFormatterBuilder.java @@ -190,8 +190,69 @@ public class TCKDateTimeFormatterBuilder { //----------------------------------------------------------------------- @Test(expectedExceptions=NullPointerException.class) - public void test_appendValueReduced_null() throws Exception { - builder.appendValueReduced(null, 2, 2000); + public void test_appendValueReduced_int_nullField() throws Exception { + builder.appendValueReduced(null, 2, 2, 2000); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_int_minWidthTooSmall() throws Exception { + builder.appendValueReduced(YEAR, 0, 2, 2000); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_int_minWidthTooBig() throws Exception { + builder.appendValueReduced(YEAR, 11, 2, 2000); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_int_maxWidthTooSmall() throws Exception { + builder.appendValueReduced(YEAR, 2, 0, 2000); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_int_maxWidthTooBig() throws Exception { + builder.appendValueReduced(YEAR, 2, 11, 2000); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_int_maxWidthLessThanMin() throws Exception { + builder.appendValueReduced(YEAR, 2, 1, 2000); + } + + //----------------------------------------------------------------------- + @Test(expectedExceptions=NullPointerException.class) + public void test_appendValueReduced_date_nullField() throws Exception { + builder.appendValueReduced(null, 2, 2, LocalDate.of(2000, 1, 1)); + } + + @Test(expectedExceptions=NullPointerException.class) + public void test_appendValueReduced_date_nullDate() throws Exception { + builder.appendValueReduced(YEAR, 2, 2, null); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_date_minWidthTooSmall() throws Exception { + builder.appendValueReduced(YEAR, 0, 2, LocalDate.of(2000, 1, 1)); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_date_minWidthTooBig() throws Exception { + builder.appendValueReduced(YEAR, 11, 2, LocalDate.of(2000, 1, 1)); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_date_maxWidthTooSmall() throws Exception { + builder.appendValueReduced(YEAR, 2, 0, LocalDate.of(2000, 1, 1)); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_date_maxWidthTooBig() throws Exception { + builder.appendValueReduced(YEAR, 2, 11, LocalDate.of(2000, 1, 1)); + } + + @Test(expectedExceptions=IllegalArgumentException.class) + public void test_appendValueReduced_date_maxWidthLessThanMin() throws Exception { + builder.appendValueReduced(YEAR, 2, 1, LocalDate.of(2000, 1, 1)); } //----------------------------------------------------------------------- diff --git a/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java b/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java index bdaf22be8..16a7d6ed7 100644 --- a/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java +++ b/test/java/time/test/java/time/format/TestDateTimeFormatterBuilder.java @@ -267,12 +267,12 @@ public class TestDateTimeFormatterBuilder { //----------------------------------------------------------------------- @Test(expectedExceptions=NullPointerException.class) public void test_appendValueReduced_null() throws Exception { - builder.appendValueReduced(null, 2, 2000); + builder.appendValueReduced(null, 2, 2, 2000); } @Test public void test_appendValueReduced() throws Exception { - builder.appendValueReduced(YEAR, 2, 2000); + builder.appendValueReduced(YEAR, 2, 2, 2000); DateTimeFormatter f = builder.toFormatter(); assertEquals(f.toString(), "ReducedValue(Year,2,2,2000)"); TemporalAccessor parsed = f.parseUnresolved("12", new ParsePosition(0)); @@ -281,7 +281,7 @@ public class TestDateTimeFormatterBuilder { @Test public void test_appendValueReduced_subsequent_parse() throws Exception { - builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValueReduced(YEAR, 2, 2000); + builder.appendValue(MONTH_OF_YEAR, 1, 2, SignStyle.NORMAL).appendValueReduced(YEAR, 2, 2, 2000); DateTimeFormatter f = builder.toFormatter(); assertEquals(f.toString(), "Value(MonthOfYear,1,2,NORMAL)ReducedValue(Year,2,2,2000)"); ParsePosition ppos = new ParsePosition(0); @@ -654,19 +654,19 @@ public class TestDateTimeFormatterBuilder { {"GGGGG", "Text(Era,NARROW)"}, {"u", "Value(Year)"}, - {"uu", "ReducedValue(Year,2,2,2000)"}, + {"uu", "ReducedValue(Year,2,2,2000-01-01)"}, {"uuu", "Value(Year,3,19,NORMAL)"}, {"uuuu", "Value(Year,4,19,EXCEEDS_PAD)"}, {"uuuuu", "Value(Year,5,19,EXCEEDS_PAD)"}, {"y", "Value(YearOfEra)"}, - {"yy", "ReducedValue(YearOfEra,2,2,2000)"}, + {"yy", "ReducedValue(YearOfEra,2,2,2000-01-01)"}, {"yyy", "Value(YearOfEra,3,19,NORMAL)"}, {"yyyy", "Value(YearOfEra,4,19,EXCEEDS_PAD)"}, {"yyyyy", "Value(YearOfEra,5,19,EXCEEDS_PAD)"}, {"Y", "Localized(WeekBasedYear)"}, - {"YY", "Localized(ReducedValue(WeekBasedYear,2,2000))"}, + {"YY", "Localized(ReducedValue(WeekBasedYear,2,2,2000-01-01))"}, {"YYY", "Localized(WeekBasedYear,3,19,NORMAL)"}, {"YYYY", "Localized(WeekBasedYear,4,19,EXCEEDS_PAD)"}, {"YYYYY", "Localized(WeekBasedYear,5,19,EXCEEDS_PAD)"}, diff --git a/test/java/time/test/java/time/format/TestReducedParser.java b/test/java/time/test/java/time/format/TestReducedParser.java index 237b5b941..ae4ff9814 100644 --- a/test/java/time/test/java/time/format/TestReducedParser.java +++ b/test/java/time/test/java/time/format/TestReducedParser.java @@ -64,11 +64,20 @@ import static java.time.temporal.ChronoField.DAY_OF_YEAR; import static java.time.temporal.ChronoField.MONTH_OF_YEAR; import static java.time.temporal.ChronoField.YEAR; import static java.time.temporal.ChronoField.YEAR_OF_ERA; +import static java.time.temporal.ChronoUnit.YEARS; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertNotNull; import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.chrono.Chronology; +import java.time.chrono.ChronoLocalDate; +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 java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.TemporalAccessor; @@ -86,13 +95,17 @@ public class TestReducedParser extends AbstractTestPrinterParser { private static final boolean LENIENT = false; private DateTimeFormatter getFormatter0(TemporalField field, int width, int baseValue) { - return builder.appendValueReduced(field, width, baseValue).toFormatter(locale).withDecimalStyle(decimalStyle); + return builder.appendValueReduced(field, width, width, baseValue).toFormatter(locale).withDecimalStyle(decimalStyle); } private DateTimeFormatter getFormatter0(TemporalField field, int minWidth, int maxWidth, int baseValue) { return builder.appendValueReduced(field, minWidth, maxWidth, baseValue).toFormatter(locale).withDecimalStyle(decimalStyle); } + private DateTimeFormatter getFormatterBaseDate(TemporalField field, int minWidth, int maxWidth, int baseValue) { + return builder.appendValueReduced(field, minWidth, maxWidth, LocalDate.of(baseValue, 1, 1)).toFormatter(locale).withDecimalStyle(decimalStyle); + } + //----------------------------------------------------------------------- @DataProvider(name="error") Object[][] data_error() { @@ -243,6 +256,10 @@ public class TestReducedParser extends AbstractTestPrinterParser { // Negative baseValue {YEAR, 2, 4, -2005, "123", 0, strict(3, 123), lenient(3, 123)}, + + // Basics + {YEAR, 2, 4, 2010, "10", 0, strict(2, 2010), lenient(2, 2010)}, + {YEAR, 2, 4, 2010, "09", 0, strict(2, 2109), lenient(2, 2109)}, }; } @@ -264,6 +281,21 @@ public class TestReducedParser extends AbstractTestPrinterParser { } } + @Test(dataProvider="ParseLenientSensitive") + public void test_parseStrict_baseDate(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, + Pair strict, Pair lenient) { + ParsePosition ppos = new ParsePosition(pos); + setStrict(true); + TemporalAccessor parsed = getFormatterBaseDate(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); + if (ppos.getErrorIndex() != -1) { + assertEquals(ppos.getErrorIndex(), strict.parseLen, "error case parse position"); + assertEquals(parsed, strict.parseVal, "unexpected parse result"); + } else { + assertEquals(ppos.getIndex(), strict.parseLen, "parse position"); + assertParsed(parsed, YEAR, strict.parseVal != null ? (long) strict.parseVal : null); + } + } + //----------------------------------------------------------------------- // Parsing tests for lenient mode //----------------------------------------------------------------------- @@ -282,6 +314,21 @@ public class TestReducedParser extends AbstractTestPrinterParser { } } + @Test(dataProvider="ParseLenientSensitive") + public void test_parseLenient_baseDate(TemporalField field, int minWidth, int maxWidth, int baseValue, String input, int pos, + Pair strict, Pair lenient) { + ParsePosition ppos = new ParsePosition(pos); + setStrict(false); + TemporalAccessor parsed = getFormatterBaseDate(field, minWidth, maxWidth, baseValue).parseUnresolved(input, ppos); + if (ppos.getErrorIndex() != -1) { + assertEquals(ppos.getErrorIndex(), lenient.parseLen, "error case parse position"); + assertEquals(parsed, lenient.parseVal, "unexpected parse result"); + } else { + assertEquals(ppos.getIndex(), lenient.parseLen, "parse position"); + assertParsed(parsed, YEAR, lenient.parseVal != null ? (long) lenient.parseVal : null); + } + } + private void assertParsed(TemporalAccessor parsed, TemporalField field, Long value) { if (value == null) { assertEquals(parsed, null, "Parsed Value"); @@ -334,6 +381,68 @@ public class TestReducedParser extends AbstractTestPrinterParser { } } + //----------------------------------------------------------------------- + // Cases and values in reduced value parsing mode + //----------------------------------------------------------------------- + @DataProvider(name="ReducedWithChrono") + Object[][] provider_reducedWithChrono() { + LocalDate baseYear = LocalDate.of(2000, 1, 1); + return new Object[][] { + {IsoChronology.INSTANCE.date(baseYear)}, + {IsoChronology.INSTANCE.date(baseYear).plus(1, YEARS)}, + {IsoChronology.INSTANCE.date(baseYear).plus(99, YEARS)}, + {HijrahChronology.INSTANCE.date(baseYear)}, + {HijrahChronology.INSTANCE.date(baseYear).plus(1, YEARS)}, + {HijrahChronology.INSTANCE.date(baseYear).plus(99, YEARS)}, + {JapaneseChronology.INSTANCE.date(baseYear)}, + {JapaneseChronology.INSTANCE.date(baseYear).plus(1, YEARS)}, + {JapaneseChronology.INSTANCE.date(baseYear).plus(99, YEARS)}, + {MinguoChronology.INSTANCE.date(baseYear)}, + {MinguoChronology.INSTANCE.date(baseYear).plus(1, YEARS)}, + {MinguoChronology.INSTANCE.date(baseYear).plus(99, YEARS)}, + {ThaiBuddhistChronology.INSTANCE.date(baseYear)}, + {ThaiBuddhistChronology.INSTANCE.date(baseYear).plus(1, YEARS)}, + {ThaiBuddhistChronology.INSTANCE.date(baseYear).plus(99, YEARS)}, + }; + } + + @Test(dataProvider="ReducedWithChrono") + public void test_reducedWithChronoYear(ChronoLocalDate date) { + Chronology chrono = date.getChronology(); + DateTimeFormatter df + = new DateTimeFormatterBuilder().appendValueReduced(YEAR, 2, 2, LocalDate.of(2000, 1, 1)) + .toFormatter() + .withChronology(chrono); + int expected = date.get(YEAR); + String input = df.format(date); + + ParsePosition pos = new ParsePosition(0); + TemporalAccessor parsed = df.parseUnresolved(input, pos); + int actual = parsed.get(YEAR); + assertEquals(actual, expected, + String.format("Wrong date parsed, chrono: %s, input: %s", + chrono, input)); + + } + @Test(dataProvider="ReducedWithChrono") + public void test_reducedWithChronoYearOfEra(ChronoLocalDate date) { + Chronology chrono = date.getChronology(); + DateTimeFormatter df + = new DateTimeFormatterBuilder().appendValueReduced(YEAR_OF_ERA, 2, 2, LocalDate.of(2000, 1, 1)) + .toFormatter() + .withChronology(chrono); + int expected = date.get(YEAR_OF_ERA); + String input = df.format(date); + + ParsePosition pos = new ParsePosition(0); + TemporalAccessor parsed = df.parseUnresolved(input, pos); + int actual = parsed.get(YEAR_OF_ERA); + assertEquals(actual, expected, + String.format("Wrong date parsed, chrono: %s, input: %s", + chrono, input)); + + } + //----------------------------------------------------------------------- // Class to structure the test data //----------------------------------------------------------------------- diff --git a/test/java/time/test/java/time/format/TestReducedPrinter.java b/test/java/time/test/java/time/format/TestReducedPrinter.java index c23cff273..c4b6cf4dc 100644 --- a/test/java/time/test/java/time/format/TestReducedPrinter.java +++ b/test/java/time/test/java/time/format/TestReducedPrinter.java @@ -59,19 +59,15 @@ */ package test.java.time.format; -import java.text.ParsePosition; import static java.time.temporal.ChronoField.YEAR; import static org.testng.Assert.assertEquals; import static org.testng.Assert.fail; import java.time.DateTimeException; import java.time.LocalDate; +import java.time.chrono.MinguoDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; -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_OF_ERA; -import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; import org.testng.annotations.DataProvider; @@ -85,13 +81,17 @@ import test.java.time.temporal.MockFieldValue; public class TestReducedPrinter extends AbstractTestPrinterParser { private DateTimeFormatter getFormatter0(TemporalField field, int width, int baseValue) { - return builder.appendValueReduced(field, width, baseValue).toFormatter(locale).withDecimalStyle(decimalStyle); + return builder.appendValueReduced(field, width, width, baseValue).toFormatter(locale).withDecimalStyle(decimalStyle); } private DateTimeFormatter getFormatter0(TemporalField field, int minWidth, int maxWidth, int baseValue) { return builder.appendValueReduced(field, minWidth, maxWidth, baseValue).toFormatter(locale).withDecimalStyle(decimalStyle); } + private DateTimeFormatter getFormatterBaseDate(TemporalField field, int minWidth, int maxWidth, int baseValue) { + return builder.appendValueReduced(field, minWidth, maxWidth, LocalDate.of(baseValue, 1, 1)).toFormatter(locale).withDecimalStyle(decimalStyle); + } + //----------------------------------------------------------------------- @Test(expectedExceptions=DateTimeException.class) public void test_print_emptyCalendrical() throws Exception { @@ -192,6 +192,58 @@ public class TestReducedPrinter extends AbstractTestPrinterParser { } } + @Test(dataProvider="Pivot") + public void test_pivot_baseDate(int minWidth, int maxWidth, int baseValue, int value, String result) throws Exception { + try { + getFormatterBaseDate(YEAR, minWidth, maxWidth, baseValue).formatTo(new MockFieldValue(YEAR, value), buf); + if (result == null) { + fail("Expected exception"); + } + assertEquals(buf.toString(), result); + } catch (DateTimeException ex) { + if (result == null || value < 0) { + assertEquals(ex.getMessage().contains(YEAR.toString()), true); + } else { + throw ex; + } + } + } + + //----------------------------------------------------------------------- + public void test_minguoChrono_fixedWidth() throws Exception { + // ISO 2021 is Minguo 110 + DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 2, 2021); + MinguoDate date = MinguoDate.of(109, 6, 30); + assertEquals(f.format(date), "09"); + date = MinguoDate.of(110, 6, 30); + assertEquals(f.format(date), "10"); + date = MinguoDate.of(199, 6, 30); + assertEquals(f.format(date), "99"); + date = MinguoDate.of(200, 6, 30); + assertEquals(f.format(date), "00"); + date = MinguoDate.of(209, 6, 30); + assertEquals(f.format(date), "09"); + date = MinguoDate.of(210, 6, 30); + assertEquals(f.format(date), "10"); + } + + public void test_minguoChrono_extendedWidth() throws Exception { + // ISO 2021 is Minguo 110 + DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 4, 2021); + MinguoDate date = MinguoDate.of(109, 6, 30); + assertEquals(f.format(date), "109"); + date = MinguoDate.of(110, 6, 30); + assertEquals(f.format(date), "10"); + date = MinguoDate.of(199, 6, 30); + assertEquals(f.format(date), "99"); + date = MinguoDate.of(200, 6, 30); + assertEquals(f.format(date), "00"); + date = MinguoDate.of(209, 6, 30); + assertEquals(f.format(date), "09"); + date = MinguoDate.of(210, 6, 30); + assertEquals(f.format(date), "210"); + } + //----------------------------------------------------------------------- public void test_toString() throws Exception { assertEquals(getFormatter0(YEAR, 2, 2, 2005).toString(), "ReducedValue(Year,2,2,2005)"); -- cgit v1.2.3 From edbe66121be5745fd7f637106535fcdf786ed942 Mon Sep 17 00:00:00 2001 From: bpb Date: Wed, 9 Oct 2013 11:47:48 -0700 Subject: 8016252: More defensive HashSet.readObject Summary: Add data validation checks in readObject(). Reviewed-by: alanb, mduigou, chegar Contributed-by: Brian Burkhalter --- test/java/util/HashSet/Serialization.java | 111 ++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 test/java/util/HashSet/Serialization.java (limited to 'test') diff --git a/test/java/util/HashSet/Serialization.java b/test/java/util/HashSet/Serialization.java new file mode 100644 index 000000000..7597ae1a5 --- /dev/null +++ b/test/java/util/HashSet/Serialization.java @@ -0,0 +1,111 @@ +/* + * 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. + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.HashSet; +import java.util.Random; +import java.util.concurrent.ThreadLocalRandom; + +/* + * @test + * @bug 8016252 + * @summary Verify that a serialized HashSet may successfully be deserialized. + */ +public class Serialization { + + private static final int NUM_SETS = 43; + private static final int MAX_CAPACITY = 257; + private static final float MAX_LOAD_FACTOR = 100.0F; + + private static final Random rnd = ThreadLocalRandom.current(); + + private static HashSet createHashSet() { + int capacity = rnd.nextInt(MAX_CAPACITY); + float loadFactor = Float.MIN_VALUE + rnd.nextFloat()*MAX_LOAD_FACTOR; + HashSet hashSet = new HashSet(capacity, loadFactor); + float multiplier = 2*rnd.nextFloat(); // range [0,2] + int size = (int)(capacity*loadFactor*multiplier); + for (int i = 0; i < size; i++) { + hashSet.add(rnd.nextInt()); + } + return hashSet; + } + + private static HashSet serDeser(HashSet hashSet) throws IOException, ClassNotFoundException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(hashSet); + oos.flush(); + + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + ObjectInputStream ois = new ObjectInputStream(bais); + HashSet result = (HashSet)ois.readObject(); + + oos.close(); + ois.close(); + + return result; + } + + private static void printHashSet(HashSet hashSet) { + System.err.println("Size: "+hashSet.size()); + for (Object o : hashSet) { + System.err.println(o); + } + } + + public static void main(String[] args) { + int failures = 0; + + for (int i = 0; i < NUM_SETS; i++) { + HashSet hashSet = createHashSet(); + + HashSet result = null; + try { + result = serDeser(hashSet); + } catch (IOException ioe) { + System.err.println(ioe); + failures++; + } catch (ClassNotFoundException cnfe) { + System.err.println(cnfe); + failures++; + } + + if (!hashSet.equals(result)) { + System.err.println("Unequal HashSets!"); + printHashSet(hashSet); + System.err.println(); + failures++; + } + } + + if (failures != 0) { + throw new RuntimeException("HashSet/Serialzation failed with "+ + failures+" failures!"); + } + } +} -- cgit v1.2.3 From 2cd4ca146f6abad071a3a8f3e82b7d8320557164 Mon Sep 17 00:00:00 2001 From: bchristi Date: Wed, 9 Oct 2013 12:13:31 -0700 Subject: 8024709: TreeMap.DescendingKeyIterator 'remove' confuses iterator position Summary: Override remove() method in DescendingKeyIterator Reviewed-by: alanb, mduigou, psandoz --- test/java/util/Collection/MOAT.java | 122 +++++++++++++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/java/util/Collection/MOAT.java b/test/java/util/Collection/MOAT.java index 945335a7f..ea53e5ee2 100644 --- a/test/java/util/Collection/MOAT.java +++ b/test/java/util/Collection/MOAT.java @@ -26,7 +26,7 @@ * @bug 6207984 6272521 6192552 6269713 6197726 6260652 5073546 4137464 * 4155650 4216399 4294891 6282555 6318622 6355327 6383475 6420753 * 6431845 4802633 6570566 6570575 6570631 6570924 6691185 6691215 - * 4802647 7123424 + * 4802647 7123424 8024709 * @summary Run many tests on many Collection and Map implementations * @author Martin Buchholz * @run main MOAT @@ -1171,8 +1171,45 @@ public class MOAT { THROWS(NoSuchElementException.class, new Fun(){void f(){it.next();}}); } - } + prepMapForDescItrTests(m); + checkDescItrRmFirst(m.keySet(), m.navigableKeySet().descendingIterator()); + prepMapForDescItrTests(m); + checkDescItrRmMid(m.keySet(), m.navigableKeySet().descendingIterator()); + prepMapForDescItrTests(m); + checkDescItrRmLast(m.keySet(), m.navigableKeySet().descendingIterator()); + + prepMapForDescItrTests(m); + checkDescItrRmFirst(m.keySet(), m.descendingMap().keySet().iterator()); + prepMapForDescItrTests(m); + checkDescItrRmMid(m.keySet(), m.descendingMap().keySet().iterator()); + prepMapForDescItrTests(m); + checkDescItrRmLast(m.keySet(), m.descendingMap().keySet().iterator()); + + prepMapForDescItrTests(m); + checkDescItrRmFirst(m.keySet(), m.descendingKeySet().iterator()); + prepMapForDescItrTests(m); + checkDescItrRmMid(m.keySet(), m.descendingKeySet().iterator()); + prepMapForDescItrTests(m); + checkDescItrRmLast(m.keySet(), m.descendingKeySet().iterator()); + + prepMapForDescItrTests(m); + checkDescItrRmFirst(m.values(), m.descendingMap().values().iterator()); + prepMapForDescItrTests(m); + checkDescItrRmMid(m.values(), m.descendingMap().values().iterator()); + prepMapForDescItrTests(m); + checkDescItrRmLast(m.values(), m.descendingMap().values().iterator()); + + prepMapForDescItrTests(m); + checkDescItrRmFirst((Collection)m.entrySet(), + m.descendingMap().entrySet().iterator()); + prepMapForDescItrTests(m); + checkDescItrRmMid((Collection)m.entrySet(), + m.descendingMap().entrySet().iterator()); + prepMapForDescItrTests(m); + checkDescItrRmLast((Collection)m.entrySet(), + m.descendingMap().entrySet().iterator()); + } private static void testNavigableSet(NavigableSet s) { clear(s); @@ -1205,6 +1242,87 @@ public class MOAT { THROWS(NoSuchElementException.class, new Fun(){void f(){it.next();}}); } + + prepSetForDescItrTests(s); + checkDescItrRmFirst(s, s.descendingIterator()); + prepSetForDescItrTests(s); + checkDescItrRmMid(s, s.descendingIterator()); + prepSetForDescItrTests(s); + checkDescItrRmLast(s, s.descendingIterator()); + + prepSetForDescItrTests(s); + checkDescItrRmFirst(s, s.descendingSet().iterator()); + prepSetForDescItrTests(s); + checkDescItrRmMid(s, s.descendingSet().iterator()); + prepSetForDescItrTests(s); + checkDescItrRmLast(s, s.descendingSet().iterator()); + } + + private static void prepSetForDescItrTests(Set s) { + clear(s); + check(s.add(1)); + check(s.add(3)); + check(s.add(5)); + } + + private static void prepMapForDescItrTests(Map m) { + clear(m); + equal(m.put(1, 2), null); + equal(m.put(3, 4), null); + equal(m.put(5, 9), null); + } + + //-------------------------------------------------------------------- + // Check behavior of descending iterator when first element is removed + //-------------------------------------------------------------------- + private static void checkDescItrRmFirst(Collection ascColl, + Iterator descItr) { + T[] expected = (T[]) ascColl.toArray(); + int idx = expected.length -1; + + equalNext(descItr, expected[idx--]); + descItr.remove(); + while(idx >= 0 && descItr.hasNext()) { + equalNext(descItr, expected[idx--]); + } + equal(descItr.hasNext(), false); + equal(idx, -1); + } + + //----------------------------------------------------------------------- + // Check behavior of descending iterator when a middle element is removed + //----------------------------------------------------------------------- + private static void checkDescItrRmMid(Collection ascColl, + Iterator descItr) { + T[] expected = (T[]) ascColl.toArray(); + int idx = expected.length -1; + + while (idx >= expected.length / 2) { + equalNext(descItr, expected[idx--]); + } + descItr.remove(); + while (idx >= 0 && descItr.hasNext()) { + equalNext(descItr, expected[idx--]); + } + equal(descItr.hasNext(), false); + equal(idx, -1); + } + + //----------------------------------------------------------------------- + // Check behavior of descending iterator when the last element is removed + //----------------------------------------------------------------------- + private static void checkDescItrRmLast(Collection ascColl, + Iterator descItr) { + T[] expected = (T[]) ascColl.toArray(); + int idx = expected.length -1; + + while (idx >= 0 && descItr.hasNext()) { + equalNext(descItr, expected[idx--]); + } + equal(idx, -1); + equal(descItr.hasNext(), false); + descItr.remove(); + equal(ascColl.contains(expected[0]), false); } //--------------------- Infrastructure --------------------------- -- cgit v1.2.3 From 9c841fe17e95ef95148250c3724f0f01aef9e471 Mon Sep 17 00:00:00 2001 From: sjiang Date: Thu, 10 Oct 2013 08:37:48 +0200 Subject: 8025207: Intermittent test failure: javax/management/monitor/CounterMonitorThresholdTest.java Reviewed-by: dfuchs, dholmes --- .../monitor/CounterMonitorThresholdTest.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/javax/management/monitor/CounterMonitorThresholdTest.java b/test/javax/management/monitor/CounterMonitorThresholdTest.java index a1f93d8c4..b56d314af 100644 --- a/test/javax/management/monitor/CounterMonitorThresholdTest.java +++ b/test/javax/management/monitor/CounterMonitorThresholdTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 6229368 + * @bug 6229368 8025207 * @summary Wrong threshold value in CounterMonitor with offset and modulus. * @author Luis-Miguel Alventosa * @run clean CounterMonitorThresholdTest @@ -144,16 +144,14 @@ public class CounterMonitorThresholdTest { for (int i = 0; i < counter.length; i++) { mbean.setCounter(counter[i]); System.out.println("\nCounter = " + mbean.getCounter()); - Thread.sleep(300); - Integer derivedGaugeValue = (Integer) cm.getDerivedGauge(name); - System.out.println("Derived Gauge = " + derivedGaugeValue); - if (derivedGaugeValue.intValue() != derivedGauge[i]) { - System.out.println("Wrong derived gauge! Current value = " + - derivedGaugeValue + " Expected value = " + derivedGauge[i]); - System.out.println("\nStop monitoring..."); - cm.stop(); - throw new IllegalArgumentException("wrong derived gauge"); - } + Integer derivedGaugeValue; + // either pass or test timeout (killed by test harness) + // see 8025207 + do { + Thread.sleep(150); + derivedGaugeValue = (Integer) cm.getDerivedGauge(name); + } while (derivedGaugeValue.intValue() != derivedGauge[i]); + Number thresholdValue = cm.getThreshold(name); System.out.println("Threshold = " + thresholdValue); if (thresholdValue.intValue() != threshold[i]) { @@ -163,7 +161,6 @@ public class CounterMonitorThresholdTest { cm.stop(); throw new IllegalArgumentException("wrong threshold"); } - Thread.sleep(300); } // Stop the monitor -- cgit v1.2.3 From 8f3bee673150f2a00c108b76d66800c4672f4021 Mon Sep 17 00:00:00 2001 From: sjiang Date: Thu, 10 Oct 2013 08:49:12 +0200 Subject: 8025206: Intermittent test failure: javax/management/monitor/NullAttributeValueTest.java Reviewed-by: dholmes, dfuchs, jbachorik --- .../management/monitor/NullAttributeValueTest.java | 68 +++++++--------------- 1 file changed, 21 insertions(+), 47 deletions(-) (limited to 'test') diff --git a/test/javax/management/monitor/NullAttributeValueTest.java b/test/javax/management/monitor/NullAttributeValueTest.java index e1661186a..01ab275fa 100644 --- a/test/javax/management/monitor/NullAttributeValueTest.java +++ b/test/javax/management/monitor/NullAttributeValueTest.java @@ -23,11 +23,12 @@ /* * @test - * @bug 6200031 + * @bug 6200031 8025206 * @summary Test that the counter/gauge/string monitors emit a * jmx.monitor.error.type notification when the attribute * being monitored returns a null value. * @author Luis-Miguel Alventosa + * @author Shanliang JIANG * @run clean NullAttributeValueTest * @run build NullAttributeValueTest * @run main NullAttributeValueTest @@ -39,7 +40,7 @@ import javax.management.monitor.*; public class NullAttributeValueTest implements NotificationListener { // Flag to notify that a message has been received - private boolean messageReceived = false; + private volatile boolean messageReceived = false; // MBean class public class ObservedObject implements ObservedObjectMBean { @@ -83,7 +84,6 @@ public class NullAttributeValueTest implements NotificationListener { * Update the counter and check for notifications */ public int counterMonitorNotification() throws Exception { - CounterMonitor counterMonitor = null; try { MBeanServer server = MBeanServerFactory.newMBeanServer(); @@ -134,31 +134,17 @@ public class NullAttributeValueTest implements NotificationListener { echo(">>> START the CounterMonitor"); counterMonitor.start(); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); - - // Check if notification was received - // - if (messageReceived) { - echo("\tOK: CounterMonitor notification received"); - } else { - echo("\tKO: CounterMonitor notification missed or not emitted"); - return 1; - } + return checkReceived(granularityperiod, "CounterMonitor"); } finally { if (counterMonitor != null) counterMonitor.stop(); } - - return 0; } /** * Update the gauge and check for notifications */ public int gaugeMonitorNotification() throws Exception { - GaugeMonitor gaugeMonitor = null; try { MBeanServer server = MBeanServerFactory.newMBeanServer(); @@ -212,31 +198,17 @@ public class NullAttributeValueTest implements NotificationListener { echo(">>> START the GaugeMonitor"); gaugeMonitor.start(); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); - - // Check if notification was received - // - if (messageReceived) { - echo("\tOK: GaugeMonitor notification received"); - } else { - echo("\tKO: GaugeMonitor notification missed or not emitted"); - return 1; - } + return checkReceived(granularityperiod, "GaugeMonitor"); } finally { if (gaugeMonitor != null) gaugeMonitor.stop(); } - - return 0; } /** * Update the string and check for notifications */ public int stringMonitorNotification() throws Exception { - StringMonitor stringMonitor = null; try { MBeanServer server = MBeanServerFactory.newMBeanServer(); @@ -289,24 +261,11 @@ public class NullAttributeValueTest implements NotificationListener { echo(">>> START the StringMonitor"); stringMonitor.start(); - // Wait for granularity period (multiplied by 2 for sure) - // - Thread.sleep(granularityperiod * 2); - - // Check if notification was received - // - if (messageReceived) { - echo("\tOK: StringMonitor notification received"); - } else { - echo("\tKO: StringMonitor notification missed or not emitted"); - return 1; - } + return checkReceived(granularityperiod, "StringMonitor"); } finally { if (stringMonitor != null) stringMonitor.stop(); } - - return 0; } /** @@ -326,6 +285,21 @@ public class NullAttributeValueTest implements NotificationListener { return error; } + private int checkReceived(long granularityperiod, String caller) throws InterruptedException { + int i = 100; + do { + Thread.sleep(granularityperiod); + } while (!messageReceived && i-- > 0); + + if (messageReceived) { + echo("\tOK: " + caller + " notification received"); + } else { + echo("\tKO: " + caller + " notification missed or not emitted"); + } + + return messageReceived ? 0 : 1; + } + /* * Print message */ -- cgit v1.2.3 From 98465f7445e3ae32bf81346ace6552431c512031 Mon Sep 17 00:00:00 2001 From: sjiang Date: Thu, 10 Oct 2013 09:01:19 +0200 Subject: 8025205: Intermittent test failure: javax/management/remote/mandatory/connection/BrokenConnectionTest.java Reviewed-by: dholmes, dfuchs, jbachorik --- .../mandatory/connection/BrokenConnectionTest.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'test') diff --git a/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java b/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java index 1ada5fb3b..42bed8570 100644 --- a/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java +++ b/test/javax/management/remote/mandatory/connection/BrokenConnectionTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4940957 + * @bug 4940957 8025205 * @summary Tests behaviour when connections break * @author Eamonn McManus * @run clean BrokenConnectionTest @@ -485,14 +485,13 @@ public class BrokenConnectionTest { } if (thisok) { System.out.println("Waiting for failure notif"); - long deadline = System.currentTimeMillis() + 5000; - while (failureListener.count < 1 - && System.currentTimeMillis() < deadline) - Thread.sleep(500); - if (failureListener.count < 1) { - System.out.println("Did not get failure notif!"); - thisok = false; - } else if (failureListener.count > 1) { + // pass or test timeout. see 8025205 + do { + Thread.sleep(100); + } while (failureListener.count < 1); + + Thread.sleep(1000); // if more notif coming ... + if (failureListener.count > 1) { System.out.println("Got too many failure notifs: " + failureListener.count); thisok = false; -- cgit v1.2.3 From 00ab35c57d91ef7a9479424552973a5510b78dc5 Mon Sep 17 00:00:00 2001 From: weijun Date: Thu, 10 Oct 2013 15:24:41 +0800 Subject: 8026235: keytool NSS test should use 64 bit lib on Solaris Reviewed-by: vinnie --- test/sun/security/tools/keytool/autotest.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/sun/security/tools/keytool/autotest.sh b/test/sun/security/tools/keytool/autotest.sh index 9c797dd21..f2b590cff 100644 --- a/test/sun/security/tools/keytool/autotest.sh +++ b/test/sun/security/tools/keytool/autotest.sh @@ -53,18 +53,27 @@ find_one() { done } +FS="/" +${TESTJAVA}${FS}bin${FS}java -XshowSettings:properties -version 2> allprop +cat allprop | grep sun.arch.data.model | grep 32 +if [ "$?" != "0" ]; then + B32=false +else + B32=true +fi + # set platform-dependent variables OS=`uname -s` case "$OS" in SunOS ) - FS="/" - LIBNAME="/usr/lib/mps/libsoftokn3.so" + if [ $B32 = true ]; then + LIBNAME="/usr/lib/mps/libsoftokn3.so" + else + LIBNAME="/usr/lib/mps/64/libsoftokn3.so" + fi ;; Linux ) - FS="/" - ${TESTJAVA}${FS}bin${FS}java -XshowSettings:properties -version 2> allprop - cat allprop | grep os.arch | grep 64 - if [ "$?" != "0" ]; then + if [ $B32 = true ]; then LIBNAME=`find_one \ "/usr/lib/libsoftokn3.so" \ "/usr/lib/i386-linux-gnu/nss/libsoftokn3.so"` @@ -82,7 +91,7 @@ esac if [ "$LIBNAME" = "" ]; then echo "Cannot find libsoftokn3.so" - exit 1 + exit 0 fi ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . -XDignore.symbol.file \ -- cgit v1.2.3 From dd51a701fde6cc9495ca141b835f4683cf22a0a0 Mon Sep 17 00:00:00 2001 From: sla Date: Thu, 10 Oct 2013 09:38:06 +0200 Subject: 8025427: jstat tests fails on 32-bit platforms Reviewed-by: ehelin, dsamersoff, dholmes, sspitsyn --- test/ProblemList.txt | 12 ------------ test/sun/tools/jstat/gcCauseOutput1.awk | 2 +- test/sun/tools/jstat/lineCounts1.awk | 2 +- test/sun/tools/jstat/lineCounts2.awk | 2 +- test/sun/tools/jstat/lineCounts3.awk | 2 +- test/sun/tools/jstat/lineCounts4.awk | 2 +- test/sun/tools/jstat/timeStamp1.awk | 2 +- test/sun/tools/jstatd/jstatGcutilOutput1.awk | 2 +- 8 files changed, 7 insertions(+), 19 deletions(-) (limited to 'test') diff --git a/test/ProblemList.txt b/test/ProblemList.txt index 484fbc700..441fe6732 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -322,18 +322,6 @@ tools/pack200/Pack200Test.java solaris-all, mac # 8007410 tools/launcher/FXLauncherTest.java linux-all -# 8025427 -sun/tools/jstat/jstatLineCounts1.sh generic-all -sun/tools/jstat/jstatLineCounts2.sh generic-all -sun/tools/jstat/jstatLineCounts3.sh generic-all -sun/tools/jstat/jstatTimeStamp1.sh generic-all -sun/tools/jstat/jstatGcCauseOutput1.sh generic-all -sun/tools/jstat/jstatLineCounts4.sh generic-all -sun/tools/jstatd/jstatdDefaults.sh generic-all -sun/tools/jstatd/jstatdExternalRegistry.sh generic-all -sun/tools/jstatd/jstatdPort.sh generic-all -sun/tools/jstatd/jstatdServerName.sh generic-all - ############################################################################ # jdk_jdi diff --git a/test/sun/tools/jstat/gcCauseOutput1.awk b/test/sun/tools/jstat/gcCauseOutput1.awk index f6127e415..3041291ac 100644 --- a/test/sun/tools/jstat/gcCauseOutput1.awk +++ b/test/sun/tools/jstat/gcCauseOutput1.awk @@ -23,7 +23,7 @@ BEGIN { # or more letters and spaces. It also provides for the ".", "(", and ")" # characters to allow for the string "System.gc()". # -/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[a-zA-Z]+[a-zA-Z \.\(\)]*[ ]*[a-zA-Z]+[a-zA-Z \.\(\)]*$/ { +/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+)|-[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[a-zA-Z]+[a-zA-Z \.\(\)]*[ ]*[a-zA-Z]+[a-zA-Z \.\(\)]*$/ { datalines++; } diff --git a/test/sun/tools/jstat/lineCounts1.awk b/test/sun/tools/jstat/lineCounts1.awk index b5cb1cdd0..dd6d5f8fb 100644 --- a/test/sun/tools/jstat/lineCounts1.awk +++ b/test/sun/tools/jstat/lineCounts1.awk @@ -18,7 +18,7 @@ BEGIN { headerlines++; } -/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { +/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+)|-[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { datalines++; } diff --git a/test/sun/tools/jstat/lineCounts2.awk b/test/sun/tools/jstat/lineCounts2.awk index 1309d04f8..adecd0a05 100644 --- a/test/sun/tools/jstat/lineCounts2.awk +++ b/test/sun/tools/jstat/lineCounts2.awk @@ -14,7 +14,7 @@ BEGIN { headerlines++; } -/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { +/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+)|-[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { datalines++; } diff --git a/test/sun/tools/jstat/lineCounts3.awk b/test/sun/tools/jstat/lineCounts3.awk index 2d8d4bf13..24788b429 100644 --- a/test/sun/tools/jstat/lineCounts3.awk +++ b/test/sun/tools/jstat/lineCounts3.awk @@ -23,7 +23,7 @@ BEGIN { headerlines++; } -/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { +/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+)|-[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { datalines++; } diff --git a/test/sun/tools/jstat/lineCounts4.awk b/test/sun/tools/jstat/lineCounts4.awk index 5ec4ac7e9..c4ea918fd 100644 --- a/test/sun/tools/jstat/lineCounts4.awk +++ b/test/sun/tools/jstat/lineCounts4.awk @@ -26,7 +26,7 @@ BEGIN { headerlines++; } -/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { +/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+)|-[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { if (headerlines == 2) { datalines2++; } diff --git a/test/sun/tools/jstat/timeStamp1.awk b/test/sun/tools/jstat/timeStamp1.awk index 1d90a18f7..cce381ce4 100644 --- a/test/sun/tools/jstat/timeStamp1.awk +++ b/test/sun/tools/jstat/timeStamp1.awk @@ -14,7 +14,7 @@ BEGIN { headerlines++; } -/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { +/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+)|-[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { datalines++; } diff --git a/test/sun/tools/jstatd/jstatGcutilOutput1.awk b/test/sun/tools/jstatd/jstatGcutilOutput1.awk index 76b355e67..9456f1909 100644 --- a/test/sun/tools/jstatd/jstatGcutilOutput1.awk +++ b/test/sun/tools/jstatd/jstatGcutilOutput1.awk @@ -18,7 +18,7 @@ BEGIN { headerlines++; } -/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { +/^[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*([0-9]+\.[0-9]+)|-[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+[ ]*[0-9]+\.[0-9]+[ ]*[0-9]+\.[0-9]+$/ { datalines++; } -- cgit v1.2.3 From aa5da91316cf9bee45ee151d4debc81663e57905 Mon Sep 17 00:00:00 2001 From: allwin Date: Thu, 10 Oct 2013 10:14:54 +0200 Subject: 8014446: JT_JDK: Wrong detection of test result for test com/sun/jdi/NoLaunchOptionTest.java Reviewed-by: sla, mgronlun, dholmes, jbachorik, chegar --- test/com/sun/jdi/NoLaunchOptionTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/com/sun/jdi/NoLaunchOptionTest.java b/test/com/sun/jdi/NoLaunchOptionTest.java index 6213b5fed..f5b1865d6 100644 --- a/test/com/sun/jdi/NoLaunchOptionTest.java +++ b/test/com/sun/jdi/NoLaunchOptionTest.java @@ -142,7 +142,7 @@ public class NoLaunchOptionTest extends Object { NoLaunchOptionTest myTest = new NoLaunchOptionTest(); String results [] = myTest.run(VMConnection.insertDebuggeeVMOptions(cmds)); if ((results[RETSTAT].equals("1")) && - (results[STDERR].startsWith("ERROR:"))) { + (results[STDERR].contains("ERROR:"))) { System.out.println("Test passed: status = 1 with warning messages " + "is expected and normal for this test"); } else { -- cgit v1.2.3 From 64d3b01f1d83ea85fa1eff7c89aca636ecd5bb54 Mon Sep 17 00:00:00 2001 From: sjiang Date: Thu, 10 Oct 2013 17:47:15 +0200 Subject: 8025204: Intermittent test failure: javax/management/remote/mandatory/connection/IdleTimeoutTest.java Reviewed-by: dholmes, jbachorik --- .../remote/mandatory/connection/IdleTimeoutTest.java | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java b/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java index 854a211a7..9bd9a741c 100644 --- a/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java +++ b/test/javax/management/remote/mandatory/connection/IdleTimeoutTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4886838 4886830 + * @bug 4886838 4886830 8025204 * @summary Tests that idle timeouts happen at appropriate times * @author Eamonn McManus * @run clean IdleTimeoutTest @@ -278,19 +278,11 @@ public class IdleTimeoutTest { } System.out.println("Waiting for id list to drop ours"); - deadline = System.currentTimeMillis() + timeout*2 + 10000; - while (true) { - ids = Arrays.asList(server.getConnectionIds()); - if (!ids.contains(connId) - || System.currentTimeMillis() >= deadline) - break; - Thread.sleep(500); - } - if (ids.contains(connId)) { - System.out.println("Client id still in list after " + - "deadline: " + ids); - return false; - } + // pass or timed out by test harness - see 8025204 + do { + Thread.sleep(100); + ids = Arrays.asList(server.getConnectionIds()); + } while (ids.contains(connId)); conn.getDefaultDomain(); if (connId.equals(client.getConnectionId())) { -- cgit v1.2.3 From cb8f7aab0fd53319371b084066398e695f6321c7 Mon Sep 17 00:00:00 2001 From: jfranck Date: Thu, 10 Oct 2013 18:11:53 +0200 Subject: 7044282: (reflect) Class.forName and Array.newInstance are inconsistent regarding multidimensional arrays Reviewed-by: darcy, psandoz --- .../java/lang/Class/forName/arrayClass/Class1.java | 24 ++++ .../java/lang/Class/forName/arrayClass/Class2.java | 24 ++++ .../java/lang/Class/forName/arrayClass/Class3.java | 24 ++++ .../java/lang/Class/forName/arrayClass/Class4.java | 24 ++++ .../Class/forName/arrayClass/ExceedMaxDim.java | 129 +++++++++++++++++++++ test/java/lang/reflect/Array/ExceedMaxDim.java | 2 +- 6 files changed, 226 insertions(+), 1 deletion(-) create mode 100644 test/java/lang/Class/forName/arrayClass/Class1.java create mode 100644 test/java/lang/Class/forName/arrayClass/Class2.java create mode 100644 test/java/lang/Class/forName/arrayClass/Class3.java create mode 100644 test/java/lang/Class/forName/arrayClass/Class4.java create mode 100644 test/java/lang/Class/forName/arrayClass/ExceedMaxDim.java (limited to 'test') diff --git a/test/java/lang/Class/forName/arrayClass/Class1.java b/test/java/lang/Class/forName/arrayClass/Class1.java new file mode 100644 index 000000000..c78bb6577 --- /dev/null +++ b/test/java/lang/Class/forName/arrayClass/Class1.java @@ -0,0 +1,24 @@ +/* + * 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. + */ + +public class Class1 {} diff --git a/test/java/lang/Class/forName/arrayClass/Class2.java b/test/java/lang/Class/forName/arrayClass/Class2.java new file mode 100644 index 000000000..d2bd477b4 --- /dev/null +++ b/test/java/lang/Class/forName/arrayClass/Class2.java @@ -0,0 +1,24 @@ +/* + * 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. + */ + +public class Class2 {} diff --git a/test/java/lang/Class/forName/arrayClass/Class3.java b/test/java/lang/Class/forName/arrayClass/Class3.java new file mode 100644 index 000000000..d66a7dedb --- /dev/null +++ b/test/java/lang/Class/forName/arrayClass/Class3.java @@ -0,0 +1,24 @@ +/* + * 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. + */ + +public class Class3 {} diff --git a/test/java/lang/Class/forName/arrayClass/Class4.java b/test/java/lang/Class/forName/arrayClass/Class4.java new file mode 100644 index 000000000..72b98d651 --- /dev/null +++ b/test/java/lang/Class/forName/arrayClass/Class4.java @@ -0,0 +1,24 @@ +/* + * 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. + */ + +public class Class4 {} diff --git a/test/java/lang/Class/forName/arrayClass/ExceedMaxDim.java b/test/java/lang/Class/forName/arrayClass/ExceedMaxDim.java new file mode 100644 index 000000000..258ee3121 --- /dev/null +++ b/test/java/lang/Class/forName/arrayClass/ExceedMaxDim.java @@ -0,0 +1,129 @@ +/* + * 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. + */ + +/* @test + * @bug 7044282 + * @build Class1 Class2 Class3 Class4 + * @run main ExceedMaxDim + * @summary Make sure you can't get an array class of dimension > 255. + */ + +// Class1, Class2, Class3 and Class4 should not have been loaded prior to the +// calls to forName + +public class ExceedMaxDim { + //0123456789012345678901234567890123456789 + private String brackets = "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[" + + "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[" + + "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[" + + "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[" + + "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[" + + "[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[" + + "[[[[[[[[[[[[[["; + private String name254 = brackets + "Ljava.lang.String;"; + private String name255 = "[" + name254; + private String name256 = "[" + name255; + private String name1 = "[Ljava.lang.String;"; + private String bigName; + private int error = 0; + + private static final ClassLoader IMPLICIT_LOADER = null; + + public ExceedMaxDim() { + super(); + + StringBuilder sb = new StringBuilder(Short.MAX_VALUE + 50); + for (int i = 0; i < Short.MAX_VALUE + 20; i++) + sb.append('['); + sb.append("Ljava.lang.String;"); + bigName = sb.toString(); + + if (name256.lastIndexOf('[') != 255) // 256:th [ + throw new RuntimeException("Test broken"); + } + + public static void main(String[] args) throws Exception { + ExceedMaxDim test = new ExceedMaxDim(); + test.testImplicitLoader(); + test.testOtherLoader(); + + if (test.error != 0) + throw new RuntimeException("Test failed, was able to create array with dim > 255." + + " See log for details."); + } + + private void testImplicitLoader() throws Exception { + // These four should succeed + assertSucceedForName(name1, IMPLICIT_LOADER); + assertSucceedForName(name254, IMPLICIT_LOADER); + assertSucceedForName(name255, IMPLICIT_LOADER); + assertSucceedForName(brackets + "[LClass1;", IMPLICIT_LOADER); + + // The following three should fail + assertFailForName(name256, IMPLICIT_LOADER); + assertFailForName(bigName, IMPLICIT_LOADER); + assertFailForName(brackets + "[[LClass2;", IMPLICIT_LOADER); + } + + private void testOtherLoader() throws Exception { + ClassLoader cl = ExceedMaxDim.class.getClassLoader(); + + // These four should succeed + assertSucceedForName(name1, cl); + assertSucceedForName(name254,cl); + assertSucceedForName(name255, cl); + assertSucceedForName(brackets + "[LClass3;", cl); + + // The following three should fail + assertFailForName(name256, cl); + assertFailForName(bigName, cl); + assertFailForName(brackets + "[[Class4;", cl); + } + + private void assertFailForName(String name, ClassLoader cl) { + Class c; + try { + if (cl == null) + c = Class.forName(name); + else + c = Class.forName(name, true, cl); + error++; + System.err.println("ERROR: could create " + c); + } catch (ClassNotFoundException e) { + ;// ok + } + } + + private void assertSucceedForName(String name, ClassLoader cl) { + Class c; + try { + if (cl == null) + c = Class.forName(name); + else + c = Class.forName(name, true, cl); + } catch (ClassNotFoundException e) { + error++; + System.err.println("ERROR: could not create " + name); + } + } +} diff --git a/test/java/lang/reflect/Array/ExceedMaxDim.java b/test/java/lang/reflect/Array/ExceedMaxDim.java index 3b1e8c1e7..67434b9f5 100644 --- a/test/java/lang/reflect/Array/ExceedMaxDim.java +++ b/test/java/lang/reflect/Array/ExceedMaxDim.java @@ -22,7 +22,7 @@ */ /* @test - * @bug 4100814 + * @bug 4100814 7044282 * @summary Make sure you can't create an array of dimension > 256. */ -- cgit v1.2.3 From 00591bb3081a46614f0e512fd06c3fd7ac3ef04a Mon Sep 17 00:00:00 2001 From: mullan Date: Fri, 11 Oct 2013 08:43:07 -0400 Subject: 8007292: Add JavaFX internal packages to package.access Summary: build hooks to allow closed restricted packages to be added to java.security file Reviewed-by: erikj, dholmes, tbell --- test/java/lang/SecurityManager/CheckPackageAccess.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/java/lang/SecurityManager/CheckPackageAccess.java b/test/java/lang/SecurityManager/CheckPackageAccess.java index c6b9a1e59..10752b94b 100644 --- a/test/java/lang/SecurityManager/CheckPackageAccess.java +++ b/test/java/lang/SecurityManager/CheckPackageAccess.java @@ -29,6 +29,9 @@ * @run main/othervm CheckPackageAccess */ +import java.io.File; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.security.Security; import java.util.Collections; import java.util.Arrays; @@ -96,6 +99,16 @@ public class CheckPackageAccess { List jspkgs = getPackages(Security.getProperty("package.access")); + // get closed restricted packages + File f = new File(System.getProperty("test.src"), + "../../../../src/closed/share/lib/security/restricted.pkgs"); + if (f.exists()) { + List ipkgs = Files.readAllLines(f.toPath(), + StandardCharsets.UTF_8); + // Remove any closed packages from list before comparing + jspkgs.removeAll(ipkgs); + } + // Sort to ensure lists are comparable Collections.sort(pkgs); Collections.sort(jspkgs); -- cgit v1.2.3 From f1d74547ef614c5b06659a3b3416bb5ff20d0814 Mon Sep 17 00:00:00 2001 From: alanb Date: Fri, 11 Oct 2013 20:47:15 +0100 Subject: 8019526: (fs) Files.lines, etc without Charset parameter Reviewed-by: psandoz, henryjen --- test/java/nio/file/Files/BytesAndLines.java | 484 ++++++++++++++++------------ test/java/nio/file/Files/StreamTest.java | 83 +++-- 2 files changed, 324 insertions(+), 243 deletions(-) (limited to 'test') diff --git a/test/java/nio/file/Files/BytesAndLines.java b/test/java/nio/file/Files/BytesAndLines.java index 6c36c121a..c3a1db74c 100644 --- a/test/java/nio/file/Files/BytesAndLines.java +++ b/test/java/nio/file/Files/BytesAndLines.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -22,262 +22,318 @@ */ /* @test - * @bug 7006126 8020669 8024788 + * @bug 7006126 8020669 8024788 8019526 * @build BytesAndLines PassThroughFileSystem - * @run main BytesAndLines + * @run testng BytesAndLines * @summary Unit test for methods for Files readAllBytes, readAllLines and * and write methods. */ -import java.nio.file.*; -import static java.nio.file.Files.*; -import java.io.*; -import java.util.*; -import java.nio.charset.*; - +import java.nio.ByteBuffer; +import java.nio.CharBuffer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.nio.file.OpenOption; +import static java.nio.file.StandardOpenOption.*; +import java.nio.charset.Charset; +import java.nio.charset.CharacterCodingException; +import java.nio.charset.MalformedInputException; +import java.nio.charset.UnmappableCharacterException; +import static java.nio.charset.StandardCharsets.*; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Random; +import java.util.concurrent.Callable; +import java.io.IOException; + +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import static org.testng.Assert.*; + +@Test(groups = "unit") public class BytesAndLines { - static final Random rand = new Random(); - static final Charset US_ASCII = Charset.forName("US-ASCII"); + // data for text files + private static final String EN_STRING = "The quick brown fox jumps over the lazy dog"; + private static final String JA_STRING = "\u65e5\u672c\u8a9e\u6587\u5b57\u5217"; + + // used for random byte content + private static Random RAND = new Random(); + + // file used by most tests + private Path tmpfile; + + @BeforeClass + void setup() throws IOException { + tmpfile = Files.createTempFile("blah", null); + } - public static void main(String[] args) throws IOException { - testReadAndWriteBytes(); - testReadLines(); - testWriteLines(); + @AfterClass + void cleanup() throws IOException { + Files.deleteIfExists(tmpfile); } /** - * Test readAllBytes(Path) and write(Path, byte[], OpenOption...) + * Returns a byte[] of the given size with random content */ - static void testReadAndWriteBytes() throws IOException { - // exercise methods with various sizes - testReadAndWriteBytes(0); - for (int i=0; i<100; i++) { - testReadAndWriteBytes(rand.nextInt(32000)); - } + private byte[] genBytes(int size) { + byte[] arr = new byte[size]; + RAND.nextBytes(arr); + return arr; + } - // NullPointerException + /** + * Exercise NullPointerException + */ + public void testNulls() { Path file = Paths.get("foo"); + byte[] bytes = new byte[100]; List lines = Collections.emptyList(); + + checkNullPointerException(() -> Files.readAllBytes(null)); + + checkNullPointerException(() -> Files.write(null, bytes)); + checkNullPointerException(() -> Files.write(file, (byte[])null)); + checkNullPointerException(() -> Files.write(file, bytes, (OpenOption[])null)); + checkNullPointerException(() -> Files.write(file, bytes, new OpenOption[] { null } )); + + checkNullPointerException(() -> Files.readAllLines(null)); + checkNullPointerException(() -> Files.readAllLines(file, (Charset)null)); + checkNullPointerException(() -> Files.readAllLines(null, Charset.defaultCharset())); + + checkNullPointerException(() -> Files.write(null, lines)); + checkNullPointerException(() -> Files.write(file, (List)null)); + checkNullPointerException(() -> Files.write(file, lines, (OpenOption[])null)); + checkNullPointerException(() -> Files.write(file, lines, new OpenOption[] { null } )); + checkNullPointerException(() -> Files.write(null, lines, Charset.defaultCharset())); + checkNullPointerException(() -> Files.write(file, null, Charset.defaultCharset())); + checkNullPointerException(() -> Files.write(file, lines, (Charset)null)); + checkNullPointerException(() -> Files.write(file, lines, Charset.defaultCharset(), (OpenOption[])null)); + checkNullPointerException(() -> Files.write(file, lines, Charset.defaultCharset(), new OpenOption[] { null } )); + } + + private void checkNullPointerException(Callable c) { try { - readAllBytes(null); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - write(null, lines, Charset.defaultCharset()); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - write(file, null, Charset.defaultCharset()); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - write(file, lines, null); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - write(file, lines, Charset.defaultCharset(), (OpenOption[])null); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - OpenOption[] opts = { null }; - write(file, lines, Charset.defaultCharset(), opts); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } + c.call(); + fail("NullPointerException expected"); + } catch (NullPointerException ignore) { + } catch (Exception e) { + fail(e + " not expected"); + } + } + + /** + * Exercise Files.readAllBytes(Path) on varied file sizes + */ + public void testReadAllBytes() throws IOException { + int size = 0; + while (size <= 16*1024) { + testReadAllBytes(size); + size += 512; + } + } + private void testReadAllBytes(int size) throws IOException { + // write bytes to file (random content) + byte[] expected = genBytes(size); + Files.write(tmpfile, expected); + + // check expected bytes are read + byte[] read = Files.readAllBytes(tmpfile); + assertTrue(Arrays.equals(read, expected), "Bytes read not the same as written"); + } + + /** + * Linux specific test to exercise Files.readAllBytes on /proc. This is + * special because file sizes are reported as 0 even though the file + * has content. + */ + public void testReadAllBytesOnProcFS() throws IOException { // read from procfs if (System.getProperty("os.name").equals("Linux")) { - // Refer to the Linux proc(5) man page for details about /proc/self/stat file - // procfs reports it to be zero sized, even though data can be read from it - String statFile = "/proc/self/stat"; - Path pathStat = Paths.get(statFile); - byte[] data = Files.readAllBytes(pathStat); + Path statFile = Paths.get("/proc/self/stat"); + byte[] data = Files.readAllBytes(statFile); assertTrue(data.length > 0, "Files.readAllBytes('" + statFile + "') failed to read"); } - - // test readAllBytes on custom file system - Path myfile = PassThroughFileSystem.create().getPath(file.toString()); - for (int size=0; size<=1024; size+=512) { - byte[] b1 = new byte[size]; - rand.nextBytes(b1); - Files.write(myfile, b1); - byte[] b2 = Files.readAllBytes(myfile); - assertTrue(Arrays.equals(b1, b2), "bytes not equal"); - } } - - static void testReadAndWriteBytes(int size) throws IOException { - Path path = createTempFile("blah", null); + /** + * Exercise Files.readAllBytes(Path) on custom file system. This is special + * because readAllBytes was originally implemented to use FileChannel + * and so may not be supported by custom file system providers. + */ + public void testReadAllBytesOnCustomFS() throws IOException { + Path myfile = PassThroughFileSystem.create().getPath("myfile"); try { - boolean append = rand.nextBoolean(); - - byte[] b1 = new byte[size]; - rand.nextBytes(b1); - - byte[] b2 = (append) ? new byte[size] : new byte[0]; - rand.nextBytes(b2); - - // write method should create file if it doesn't exist - if (rand.nextBoolean()) - delete(path); - - // write bytes to file - Path target = write(path, b1); - assertTrue(target==path, "Unexpected path"); - assertTrue(size(path) == b1.length, "Unexpected file size"); - - // append bytes to file (might be 0 bytes) - write(path, b2, StandardOpenOption.APPEND); - assertTrue(size(path) == b1.length + b2.length, "Unexpected file size"); - - // read entire file - byte[] read = readAllBytes(path); - - // check bytes are correct - byte[] expected; - if (append) { - expected = new byte[b1.length + b2.length]; - System.arraycopy(b1, 0, expected, 0, b1.length); - System.arraycopy(b2, 0, expected, b1.length, b2.length); - } else { - expected = b1; + int size = 0; + while (size <= 1024) { + byte[] b1 = genBytes(size); + Files.write(myfile, b1); + byte[] b2 = Files.readAllBytes(myfile); + assertTrue(Arrays.equals(b1, b2), "bytes not equal"); + size += 512; } - assertTrue(Arrays.equals(read, expected), - "Bytes read not the same as bytes written"); } finally { - deleteIfExists(path); + Files.deleteIfExists(myfile); } } /** - * Test readAllLines(Path,Charset) + * Exercise Files.write(Path, byte[], OpenOption...) on various sizes */ - static void testReadLines() throws IOException { - Path tmpfile = createTempFile("blah", "txt"); - try { - List lines; + public void testWriteBytes() throws IOException { + int size = 0; + while (size < 16*1024) { + testWriteBytes(size, false); + testWriteBytes(size, true); + size += 512; + } + } + + private void testWriteBytes(int size, boolean append) throws IOException { + byte[] bytes = genBytes(size); + Path result = Files.write(tmpfile, bytes); + assertTrue(result == tmpfile); + if (append) { + Files.write(tmpfile, bytes, APPEND); + assertTrue(Files.size(tmpfile) == size*2); + } + + byte[] expected; + if (append) { + expected = new byte[size << 1]; + System.arraycopy(bytes, 0, expected, 0, bytes.length); + System.arraycopy(bytes, 0, expected, bytes.length, bytes.length); + } else { + expected = bytes; + } + + byte[] read = Files.readAllBytes(tmpfile); + assertTrue(Arrays.equals(read, expected), "Bytes read not the same as written"); + } - // zero lines - assertTrue(size(tmpfile) == 0, "File should be empty"); - lines = readAllLines(tmpfile, US_ASCII); + /** + * Exercise Files.readAllLines(Path, Charset) + */ + public void testReadAllLines() throws IOException { + // zero lines + Files.write(tmpfile, new byte[0]); + List lines = Files.readAllLines(tmpfile, US_ASCII); assertTrue(lines.isEmpty(), "No line expected"); - // one line - byte[] hi = { (byte)'h', (byte)'i' }; - write(tmpfile, hi); - lines = readAllLines(tmpfile, US_ASCII); - assertTrue(lines.size() == 1, "One line expected"); - assertTrue(lines.get(0).equals("hi"), "'Hi' expected"); - - // two lines using platform's line separator - List expected = Arrays.asList("hi", "there"); - write(tmpfile, expected, US_ASCII); - assertTrue(size(tmpfile) > 0, "File is empty"); - lines = readAllLines(tmpfile, US_ASCII); - assertTrue(lines.equals(expected), "Unexpected lines"); - - // MalformedInputException - byte[] bad = { (byte)0xff, (byte)0xff }; - write(tmpfile, bad); - try { - readAllLines(tmpfile, US_ASCII); - throw new RuntimeException("MalformedInputException expected"); - } catch (MalformedInputException ignore) { } - - - // NullPointerException - try { - readAllLines(null, US_ASCII); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - readAllLines(tmpfile, null); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - - // read from procfs - if (System.getProperty("os.name").equals("Linux")) { - // Refer to the Linux proc(5) man page for details about /proc/self/status file - // procfs reports this file to be zero sized, even though data can be read from it - String statusFile = "/proc/self/status"; - Path pathStatus = Paths.get(statusFile); - lines = Files.readAllLines(pathStatus, US_ASCII); - assertTrue(lines.size() > 0, "Files.readAllLines('" + pathStatus + "') failed to read"); - } + // one line + byte[] hi = { (byte)'h', (byte)'i' }; + Files.write(tmpfile, hi); + lines = Files.readAllLines(tmpfile, US_ASCII); + assertTrue(lines.size() == 1, "One line expected"); + assertTrue(lines.get(0).equals("hi"), "'Hi' expected"); + + // two lines using platform's line separator + List expected = Arrays.asList("hi", "there"); + Files.write(tmpfile, expected, US_ASCII); + assertTrue(Files.size(tmpfile) > 0, "File is empty"); + lines = Files.readAllLines(tmpfile, US_ASCII); + assertTrue(lines.equals(expected), "Unexpected lines"); + + // MalformedInputException + byte[] bad = { (byte)0xff, (byte)0xff }; + Files.write(tmpfile, bad); + try { + Files.readAllLines(tmpfile, US_ASCII); + fail("MalformedInputException expected"); + } catch (MalformedInputException ignore) { } + } - } finally { - delete(tmpfile); + /** + * Linux specific test to exercise Files.readAllLines(Path) on /proc. This + * is special because file sizes are reported as 0 even though the file + * has content. + */ + public void testReadAllLinesOnProcFS() throws IOException { + if (System.getProperty("os.name").equals("Linux")) { + Path statFile = Paths.get("/proc/self/stat"); + List lines = Files.readAllLines(statFile); + assertTrue(lines.size() > 0, "Files.readAllLines('" + statFile + "') failed to read"); } } /** - * Test write(Path,Iterable,Charset,OpenOption...) + * Exercise Files.readAllLines(Path) */ - static void testWriteLines() throws IOException { - Path tmpfile = createTempFile("blah", "txt"); + public void testReadAllLinesUTF8() throws IOException { + Files.write(tmpfile, encodeAsUTF8(EN_STRING + "\n" + JA_STRING)); + + List lines = Files.readAllLines(tmpfile); + assertTrue(lines.size() == 2, "Read " + lines.size() + " lines instead of 2"); + assertTrue(lines.get(0).equals(EN_STRING)); + assertTrue(lines.get(1).equals(JA_STRING)); + + // a sample of malformed sequences + testReadAllLinesMalformedUTF8((byte)0xFF); // one-byte sequence + testReadAllLinesMalformedUTF8((byte)0xC0, (byte)0x80); // invalid first byte + testReadAllLinesMalformedUTF8((byte)0xC2, (byte)0x00); // invalid second byte + } + + private byte[] encodeAsUTF8(String s) throws CharacterCodingException { + // not using s.getBytes here so as to catch unmappable characters + ByteBuffer bb = UTF_8.newEncoder().encode(CharBuffer.wrap(s)); + byte[] result = new byte[bb.limit()]; + bb.get(result); + assertTrue(bb.remaining() == 0); + return result; + } + + private void testReadAllLinesMalformedUTF8(byte... bytes) throws IOException { + Files.write(tmpfile, bytes); try { - // write method should create file if it doesn't exist - if (rand.nextBoolean()) - delete(tmpfile); - - // zero lines - Path result = write(tmpfile, Collections.emptyList(), US_ASCII); - assert(size(tmpfile) == 0); - assert(result == tmpfile); - - // two lines - List lines = Arrays.asList("hi", "there"); - write(tmpfile, lines, US_ASCII); - List actual = readAllLines(tmpfile, US_ASCII); - assertTrue(actual.equals(lines), "Unexpected lines"); - - // append two lines - write(tmpfile, lines, US_ASCII, StandardOpenOption.APPEND); - List expected = new ArrayList(); - expected.addAll(lines); - expected.addAll(lines); - assertTrue(expected.size() == 4, "List should have 4 elements"); - actual = readAllLines(tmpfile, US_ASCII); - assertTrue(actual.equals(expected), "Unexpected lines"); - - // UnmappableCharacterException - try { - String s = "\u00A0\u00A1"; - write(tmpfile, Arrays.asList(s), US_ASCII); - throw new RuntimeException("UnmappableCharacterException expected"); - } catch (UnmappableCharacterException ignore) { } - - // NullPointerException - try { - write(null, lines, US_ASCII); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - write(tmpfile, null, US_ASCII); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - write(tmpfile, lines, null); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - write(tmpfile, lines, US_ASCII, (OpenOption[])null); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - OpenOption[] opts = { (OpenOption)null }; - write(tmpfile, lines, US_ASCII, opts); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } + Files.readAllLines(tmpfile); + fail("MalformedInputException expected"); + } catch (MalformedInputException ignore) { } + } - } finally { - delete(tmpfile); - } + /** + * Exercise Files.write(Path, Iterable, Charset, OpenOption...) + */ + public void testWriteLines() throws IOException { + // zero lines + Path result = Files.write(tmpfile, Collections.emptyList(), US_ASCII); + assert(Files.size(tmpfile) == 0); + assert(result == tmpfile); + + // two lines + List lines = Arrays.asList("hi", "there"); + Files.write(tmpfile, lines, US_ASCII); + List actual = Files.readAllLines(tmpfile, US_ASCII); + assertTrue(actual.equals(lines), "Unexpected lines"); + + // append two lines + Files.write(tmpfile, lines, US_ASCII, APPEND); + List expected = new ArrayList<>(); + expected.addAll(lines); + expected.addAll(lines); + assertTrue(expected.size() == 4, "List should have 4 elements"); + actual = Files.readAllLines(tmpfile, US_ASCII); + assertTrue(actual.equals(expected), "Unexpected lines"); + + // UnmappableCharacterException + try { + String s = "\u00A0\u00A1"; + Files.write(tmpfile, Arrays.asList(s), US_ASCII); + fail("UnmappableCharacterException expected"); + } catch (UnmappableCharacterException ignore) { } } - static void assertTrue(boolean expr, String errmsg) { - if (!expr) - throw new RuntimeException(errmsg); + /** + * Exercise Files.write(Path, Iterable, OpenOption...) + */ + public void testWriteLinesUTF8() throws IOException { + List lines = Arrays.asList(EN_STRING, JA_STRING); + Files.write(tmpfile, lines); + List actual = Files.readAllLines(tmpfile, UTF_8); + assertTrue(actual.equals(lines), "Unexpected lines"); } } diff --git a/test/java/nio/file/Files/StreamTest.java b/test/java/nio/file/Files/StreamTest.java index 5304492f1..839b11f9c 100644 --- a/test/java/nio/file/Files/StreamTest.java +++ b/test/java/nio/file/Files/StreamTest.java @@ -22,11 +22,10 @@ */ /* @test - * @bug 8006884 - * @summary Unit test for java.nio.file.Files - * @library .. + * @bug 8006884 8019526 * @build PassThroughFileSystem FaultyFileSystem * @run testng StreamTest + * @summary Unit test for java.nio.file.Files methods that return a Stream */ import java.io.IOException; @@ -43,11 +42,13 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.Set; import java.util.TreeSet; +import java.util.concurrent.Callable; import java.util.function.BiPredicate; import java.util.stream.Stream; import java.util.stream.Collectors; @@ -316,56 +317,80 @@ public class StreamTest { try { // zero lines assertTrue(Files.size(tmpfile) == 0, "File should be empty"); + try (Stream s = Files.lines(tmpfile)) { + checkLines(s, Collections.emptyList()); + } try (Stream s = Files.lines(tmpfile, US_ASCII)) { - assertEquals(s.mapToInt(l -> 1).reduce(0, Integer::sum), 0, "No line expected"); + checkLines(s, Collections.emptyList()); } // one line - byte[] hi = { (byte)'h', (byte)'i' }; - Files.write(tmpfile, hi); + List oneLine = Arrays.asList("hi"); + Files.write(tmpfile, oneLine, US_ASCII); + try (Stream s = Files.lines(tmpfile)) { + checkLines(s, oneLine); + } try (Stream s = Files.lines(tmpfile, US_ASCII)) { - List lines = s.collect(Collectors.toList()); - assertTrue(lines.size() == 1, "One line expected"); - assertTrue(lines.get(0).equals("hi"), "'Hi' expected"); + checkLines(s, oneLine); } // two lines using platform's line separator - List expected = Arrays.asList("hi", "there"); - Files.write(tmpfile, expected, US_ASCII); - assertTrue(Files.size(tmpfile) > 0, "File is empty"); + List twoLines = Arrays.asList("hi", "there"); + Files.write(tmpfile, twoLines, US_ASCII); + try (Stream s = Files.lines(tmpfile)) { + checkLines(s, twoLines); + } try (Stream s = Files.lines(tmpfile, US_ASCII)) { - List lines = s.collect(Collectors.toList()); - assertTrue(lines.equals(expected), "Unexpected lines"); + checkLines(s, twoLines); } // MalformedInputException byte[] bad = { (byte)0xff, (byte)0xff }; Files.write(tmpfile, bad); + try (Stream s = Files.lines(tmpfile)) { + checkMalformedInputException(s); + } try (Stream s = Files.lines(tmpfile, US_ASCII)) { - try { - List lines = s.collect(Collectors.toList()); - throw new RuntimeException("UncheckedIOException expected"); - } catch (UncheckedIOException ex) { - assertTrue(ex.getCause() instanceof MalformedInputException, - "MalformedInputException expected"); - } + checkMalformedInputException(s); } // NullPointerException - try { - Files.lines(null, US_ASCII); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } - try { - Files.lines(tmpfile, null); - throw new RuntimeException("NullPointerException expected"); - } catch (NullPointerException ignore) { } + checkNullPointerException(() -> Files.lines(null)); + checkNullPointerException(() -> Files.lines(null, US_ASCII)); + checkNullPointerException(() -> Files.lines(tmpfile, null)); } finally { Files.delete(tmpfile); } } + private void checkLines(Stream s, List expected) { + List lines = s.collect(Collectors.toList()); + assertTrue(lines.size() == expected.size(), "Unexpected number of lines"); + assertTrue(lines.equals(expected), "Unexpected content"); + } + + private void checkMalformedInputException(Stream s) { + try { + List lines = s.collect(Collectors.toList()); + fail("UncheckedIOException expected"); + } catch (UncheckedIOException ex) { + IOException cause = ex.getCause(); + assertTrue(cause instanceof MalformedInputException, + "MalformedInputException expected"); + } + } + + private void checkNullPointerException(Callable c) { + try { + c.call(); + fail("NullPointerException expected"); + } catch (NullPointerException ignore) { + } catch (Exception e) { + fail(e + " not expected"); + } + } + public void testDirectoryIteratorException() throws IOException { Path dir = testFolder.resolve("dir2"); Path trigger = dir.resolve("DirectoryIteratorException"); -- cgit v1.2.3 From da330df4077006e10c72f9dd5ecb2a641e64cce2 Mon Sep 17 00:00:00 2001 From: rfield Date: Fri, 11 Oct 2013 15:21:23 -0700 Subject: 8026213: Reflection support for private interface methods Reviewed-by: forax, psandoz, dholmes, jfranck Contributed-by: karen.kinnear@oracle.com --- .../invoke/TestPrivateInterfaceMethodReflect.java | 122 +++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 test/java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java (limited to 'test') diff --git a/test/java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java b/test/java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java new file mode 100644 index 000000000..83ead89fe --- /dev/null +++ b/test/java/lang/reflect/Method/invoke/TestPrivateInterfaceMethodReflect.java @@ -0,0 +1,122 @@ +/* + * 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. + */ + +/* + * @test + * @bug 8026213 + * @summary Reflection support for private methods in interfaces + * @author Robert Field + * @run main TestPrivateInterfaceMethodReflect + */ + +import java.lang.reflect.*; + +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; +import jdk.internal.org.objectweb.asm.Opcodes; + +public class TestPrivateInterfaceMethodReflect { + + static final String INTERFACE_NAME = "PrivateInterfaceMethodReflectTest_Interface"; + static final String CLASS_NAME = "PrivateInterfaceMethodReflectTest_Class"; + static final int EXPECTED = 1234; + + static class TestClassLoader extends ClassLoader implements Opcodes { + + @Override + public Class findClass(String name) throws ClassNotFoundException { + byte[] b; + try { + b = loadClassData(name); + } catch (Throwable th) { + // th.printStackTrace(); + throw new ClassNotFoundException("Loading error", th); + } + return defineClass(name, b, 0, b.length); + } + + private byte[] loadClassData(String name) throws Exception { + ClassWriter cw = new ClassWriter(0); + MethodVisitor mv; + switch (name) { + case INTERFACE_NAME: + cw.visit(V1_8, ACC_ABSTRACT | ACC_INTERFACE | ACC_PUBLIC, INTERFACE_NAME, null, "java/lang/Object", null); + { + mv = cw.visitMethod(ACC_PRIVATE, "privInstance", "()I", null, null); + mv.visitCode(); + mv.visitLdcInsn(EXPECTED); + mv.visitInsn(IRETURN); + mv.visitMaxs(1, 1); + mv.visitEnd(); + } + break; + case CLASS_NAME: + cw.visit(52, ACC_SUPER | ACC_PUBLIC, CLASS_NAME, null, "java/lang/Object", new String[]{INTERFACE_NAME}); + { + mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V"); + mv.visitInsn(RETURN); + mv.visitMaxs(1, 1); + mv.visitEnd(); + } + break; + default: + break; + } + cw.visitEnd(); + + return cw.toByteArray(); + } + } + + public static void main(String[] args) throws Exception { + TestClassLoader tcl = new TestClassLoader(); + Class itf = tcl.loadClass(INTERFACE_NAME); + Class k = tcl.loadClass(CLASS_NAME); + Object inst = k.newInstance(); + Method[] meths = itf.getDeclaredMethods(); + if (meths.length != 1) { + throw new Exception("Expected one method in " + INTERFACE_NAME + " instead " + meths.length); + } + + Method m = meths[0]; + int mod = m.getModifiers(); + if ((mod & Modifier.PRIVATE) == 0) { + throw new Exception("Expected " + m + " to be private"); + } + if ((mod & Modifier.STATIC) != 0) { + throw new Exception("Expected " + m + " to be instance method"); + } + + m.setAccessible(true); + for (int i = 1; i < 200; i++) { + if (!m.invoke(inst).equals(EXPECTED)) { + throw new Exception("Expected " + EXPECTED + " from " + m); + } + } + + System.out.println("Passed."); + } +} -- cgit v1.2.3 From f6e877c6a5e53b9109cdc8d15daf33c2f40099bf Mon Sep 17 00:00:00 2001 From: xuelei Date: Sun, 13 Oct 2013 21:10:33 -0700 Subject: 8026119: Regression test DHEKeySizing.java failing intermittently Reviewed-by: weijun --- .../net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java index 3c61f7637..ec61b303b 100644 --- a/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java +++ b/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/DHKeyExchange/DHEKeySizing.java @@ -111,7 +111,15 @@ import java.util.Base64; public class DHEKeySizing { - private static boolean debug = true; + private final static boolean debug = true; + + // key length bias because of the stripping of leading zero bytes of + // negotiated DH keys. + // + // This is an effort to mimum intermittent failure when we cannot + // estimate what's the exact number of leading zero bytes of + // negotiated DH keys. + private final static int KEY_LEN_BIAS = 6; private SSLContext sslc; private SSLEngine ssle1; // client @@ -269,7 +277,8 @@ public class DHEKeySizing { twoToOne.flip(); log("Message length of ServerHello series: " + twoToOne.remaining()); - if (lenServerKeyEx != twoToOne.remaining()) { + if (twoToOne.remaining() < (lenServerKeyEx - KEY_LEN_BIAS) || + twoToOne.remaining() > lenServerKeyEx) { throw new Exception( "Expected to generate ServerHello series messages of " + lenServerKeyEx + " bytes, but not " + twoToOne.remaining()); @@ -289,7 +298,8 @@ public class DHEKeySizing { oneToTwo.flip(); log("Message length of ClientKeyExchange: " + oneToTwo.remaining()); - if (lenClientKeyEx != oneToTwo.remaining()) { + if (oneToTwo.remaining() < (lenClientKeyEx - KEY_LEN_BIAS) || + oneToTwo.remaining() > lenClientKeyEx) { throw new Exception( "Expected to generate ClientKeyExchange message of " + lenClientKeyEx + " bytes, but not " + oneToTwo.remaining()); -- cgit v1.2.3 From ddae14edca40eea32cef22dbff9c9ce525a46e16 Mon Sep 17 00:00:00 2001 From: tyan Date: Mon, 14 Oct 2013 11:47:54 +0100 Subject: 8023555: test/java/net/Socks/SocksProxyVersion.java fails when machine name is localhost Reviewed-by: chegar, alanb --- test/java/net/Socks/SocksProxyVersion.java | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test') diff --git a/test/java/net/Socks/SocksProxyVersion.java b/test/java/net/Socks/SocksProxyVersion.java index bc46c423a..27bd1872d 100644 --- a/test/java/net/Socks/SocksProxyVersion.java +++ b/test/java/net/Socks/SocksProxyVersion.java @@ -41,6 +41,10 @@ public class SocksProxyVersion implements Runnable { volatile boolean failed; public static void main(String[] args) throws Exception { + if (InetAddress.getLocalHost().isLoopbackAddress()) { + System.out.println("Test cannot run. getLocalHost returns a loopback address"); + return; + } new SocksProxyVersion(); } -- cgit v1.2.3 From 9bbfb3191d4606aefd83b2668cf92e56b876b8c1 Mon Sep 17 00:00:00 2001 From: stefank Date: Mon, 14 Oct 2013 14:28:50 +0200 Subject: 7196801: NPG: Fix java/lang/management/MemoryMXBean/LowMemoryTest2 Reviewed-by: coleenp, sla Contributed-by: stefan.karlsson@oracle.com, coleen.phillimore@oracle.com --- .../management/MemoryMXBean/LowMemoryTest2.java | 25 ++++++++++++++++------ .../lang/management/MemoryMXBean/LowMemoryTest2.sh | 15 +++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) (limited to 'test') diff --git a/test/java/lang/management/MemoryMXBean/LowMemoryTest2.java b/test/java/lang/management/MemoryMXBean/LowMemoryTest2.java index 059e45d40..d0f9e9aa4 100644 --- a/test/java/lang/management/MemoryMXBean/LowMemoryTest2.java +++ b/test/java/lang/management/MemoryMXBean/LowMemoryTest2.java @@ -26,7 +26,7 @@ * * The test set a listener to be notified when any of the non-heap pools * exceed 80%. It then starts a thread that continuously loads classes. - * In the HotSpot implementation this causes perm space to be consumed. + * In the HotSpot implementation this causes metaspace to be consumed. * Test completes when we the notification is received or an OutOfMemory * is generated. */ @@ -100,7 +100,14 @@ public class LowMemoryTest2 { // TestNNNNNN - String name = "Test" + Integer.toString(count++); + int load_count = count++; + if (load_count > 999999) { + // The test will create a corrupt class file if the count + // exceeds 999999. Fix the test if this exception is thrown. + throw new RuntimeException("Load count exceeded"); + } + + String name = "Test" + Integer.toString(load_count); byte value[]; try { @@ -133,8 +140,9 @@ public class LowMemoryTest2 { * Note: Once the usage threshold has been exceeded the low memory * detector thread will attempt to deliver its notification - this can * potentially create a race condition with this thread contining to - * fill up perm space. To avoid the low memory detector getting an OutOfMemory - * we throttle this thread once the threshold has been exceeded. + * fill up metaspace. To avoid the low memory detector getting an + * OutOfMemory we throttle this thread once the threshold has been + * exceeded. */ public void run() { List pools = ManagementFactory.getMemoryPoolMXBeans(); @@ -180,7 +188,7 @@ public class LowMemoryTest2 { // Set threshold of 80% of all NON_HEAP memory pools // In the Hotspot implementation this means we should get a notification - // if the CodeCache or perm generation fills up. + // if the CodeCache or metaspace fills up. while (iter.hasNext()) { MemoryPoolMXBean p = (MemoryPoolMXBean) iter.next(); @@ -188,7 +196,12 @@ public class LowMemoryTest2 { // set threshold MemoryUsage mu = p.getUsage(); - long threshold = (mu.getMax() * 80) / 100; + long max = mu.getMax(); + if (max < 0) { + throw new RuntimeException("There is no maximum set for " + + p.getName() + " memory pool so the test is invalid"); + } + long threshold = (max * 80) / 100; p.setUsageThreshold(threshold); diff --git a/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh b/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh index 44b757214..3d97270fb 100644 --- a/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh +++ b/test/java/lang/management/MemoryMXBean/LowMemoryTest2.sh @@ -51,14 +51,17 @@ go() { # Run test with each GC configuration # -# Notes: To ensure that perm gen fills up we disable class unloading. -# Also we set the max perm space to 8MB - otherwise the test takes too +# Notes: To ensure that metaspace fills up we disable class unloading. +# Also we set the max metaspace to 8MB - otherwise the test takes too # long to run. -go -noclassgc -XX:PermSize=8m -XX:MaxPermSize=8m -XX:+UseSerialGC LowMemoryTest2 -go -noclassgc -XX:PermSize=8m -XX:MaxPermSize=8m -XX:+UseParallelGC LowMemoryTest2 -go -noclassgc -XX:PermSize=8m -XX:MaxPermSize=8m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC \ - LowMemoryTest2 +go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseSerialGC LowMemoryTest2 +go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseParallelGC LowMemoryTest2 +go -noclassgc -XX:MaxMetaspaceSize=16m -XX:+UseParNewGC -XX:+UseConcMarkSweepGC LowMemoryTest2 + +# Test class metaspace - might hit MaxMetaspaceSize instead if +# UseCompressedClassPointers is off or if 32 bit. +go -noclassgc -XX:MaxMetaspaceSize=16m -XX:CompressedClassSpaceSize=4m LowMemoryTest2 echo '' if [ $failures -gt 0 ]; -- cgit v1.2.3 From 2bcb49d015ec6feb1f305d85f84de498e256d459 Mon Sep 17 00:00:00 2001 From: michaelm Date: Mon, 14 Oct 2013 22:09:15 +0100 Subject: 8014719: HttpClient/ProxyTest.java failing with IAE HttpURLPermission.parseURI Reviewed-by: alanb, chegar --HG-- rename : src/share/classes/java/net/HttpURLPermission.java => src/share/classes/java/net/URLPermission.java rename : test/java/net/HttpURLPermission/HttpURLPermissionTest.java => test/java/net/URLPermission/URLPermissionTest.java rename : test/java/net/HttpURLPermission/URLTest.java => test/java/net/URLPermission/URLTest.java rename : test/java/net/HttpURLPermission/policy.1 => test/java/net/URLPermission/policy.1 rename : test/java/net/HttpURLPermission/policy.2 => test/java/net/URLPermission/policy.2 rename : test/java/net/HttpURLPermission/policy.3 => test/java/net/URLPermission/policy.3 --- .../HttpURLPermission/HttpURLPermissionTest.java | 204 ----------- test/java/net/HttpURLPermission/URLTest.java | 240 ------------- test/java/net/HttpURLPermission/policy.1 | 48 --- test/java/net/HttpURLPermission/policy.2 | 46 --- test/java/net/HttpURLPermission/policy.3 | 48 --- test/java/net/URLPermission/URLPermissionTest.java | 388 +++++++++++++++++++++ test/java/net/URLPermission/URLTest.java | 240 +++++++++++++ test/java/net/URLPermission/policy.1 | 48 +++ test/java/net/URLPermission/policy.2 | 46 +++ test/java/net/URLPermission/policy.3 | 48 +++ 10 files changed, 770 insertions(+), 586 deletions(-) delete mode 100644 test/java/net/HttpURLPermission/HttpURLPermissionTest.java delete mode 100644 test/java/net/HttpURLPermission/URLTest.java delete mode 100644 test/java/net/HttpURLPermission/policy.1 delete mode 100644 test/java/net/HttpURLPermission/policy.2 delete mode 100644 test/java/net/HttpURLPermission/policy.3 create mode 100644 test/java/net/URLPermission/URLPermissionTest.java create mode 100644 test/java/net/URLPermission/URLTest.java create mode 100644 test/java/net/URLPermission/policy.1 create mode 100644 test/java/net/URLPermission/policy.2 create mode 100644 test/java/net/URLPermission/policy.3 (limited to 'test') diff --git a/test/java/net/HttpURLPermission/HttpURLPermissionTest.java b/test/java/net/HttpURLPermission/HttpURLPermissionTest.java deleted file mode 100644 index 4f4ea85d4..000000000 --- a/test/java/net/HttpURLPermission/HttpURLPermissionTest.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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. - */ - -import java.net.HttpURLPermission; -import java.io.*; - -/** - * @test - * @bug 8010464 - */ - -public class HttpURLPermissionTest { - - // super class for all test types - abstract static class Test { - boolean expected; - abstract boolean execute(); - }; - - // Tests URL part of implies() method. This is the main test. - static class URLImpliesTest extends Test { - String arg1, arg2; - - URLImpliesTest(String arg1, String arg2, boolean expected) { - this.arg1 = arg1; - this.arg2 = arg2; - this.expected = expected; - } - - boolean execute() { - HttpURLPermission p1 = new HttpURLPermission (arg1, "GET:*"); - HttpURLPermission p2 = new HttpURLPermission (arg2, "GET:*"); - boolean result = p1.implies(p2); - return result == expected; - } - }; - - static URLImpliesTest imtest(String arg1, String arg2, boolean expected) { - return new URLImpliesTest(arg1, arg2, expected); - } - - static class ActionImpliesTest extends Test { - String arg1, arg2; - - ActionImpliesTest(String arg1, String arg2, boolean expected) { - this.arg1 = arg1; - this.arg2 = arg2; - this.expected = expected; - } - - boolean execute() { - String url1 = "http://www.foo.com/-"; - String url2 = "http://www.foo.com/a/b"; - HttpURLPermission p1 = new HttpURLPermission(url1, arg1); - HttpURLPermission p2 = new HttpURLPermission(url2, arg2); - boolean result = p1.implies(p2); - return result == expected; - } - } - - static ActionImpliesTest actest(String arg1, String arg2, boolean expected) { - return new ActionImpliesTest(arg1, arg2, expected); - } - - static Test[] pathImplies = { - // single - imtest("http://www.foo.com/", "http://www.foo.com/", true), - imtest("http://www.bar.com/", "http://www.foo.com/", false), - imtest("http://www.foo.com/a/b", "http://www.foo.com/", false), - imtest("http://www.foo.com/a/b", "http://www.foo.com/a/b/c", false), - // wildcard - imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c", true), - imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/*", true), - imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c#frag", true), - imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c#frag?foo=foo", true), - imtest("http://www.foo.com/a/b/*", "http://www.foo.com/b/b/c", false), - imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c.html", true), - imtest("http://www.foo.com/a/b/*", "http://www.foo.com/a/b/c.html", true), - imtest("http://www.foo.com/a/b/*", "https://www.foo.com/a/b/c", false), - // recursive - imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/-", true), - imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c", true), - imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c#frag", true), - imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c#frag?foo=foo", true), - imtest("http://www.foo.com/a/b/-", "http://www.foo.com/b/b/c", false), - imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c.html", true), - imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c.html", true), - imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c/d/e.html", true), - imtest("https://www.foo.com/a/b/-", "http://www.foo.com/a/b/c/d/e.html", false), - imtest("http://www.foo.com/a/b/-", "http://www.foo.com/a/b/c/d/e#frag", true), - imtest("http://www.foo.com/a/b/-", "https://www.foo.com/a/b/c", false), - // special cases - imtest("http:*", "https://www.foo.com/a/b/c", false), - imtest("http:*", "http://www.foo.com/a/b/c", true), - imtest("http:*", "http://foo/bar", true), - imtest("http://foo/bar", "https://foo/bar", false) - }; - - static Test[] actionImplies = { - actest("GET", "GET", true), - actest("GET", "POST", false), - actest("GET:", "PUT", false), - actest("GET:", "GET", true), - actest("GET,POST", "GET", true), - actest("GET,POST:", "GET", true), - actest("GET:X-Foo", "GET:x-foo", true), - actest("GET:X-Foo,X-bar", "GET:x-foo", true), - actest("GET:X-Foo", "GET:x-boo", false), - actest("GET:X-Foo,X-Bar", "GET:x-bar,x-foo", true), - actest("GET:X-Bar,X-Foo,X-Bar,Y-Foo", "GET:x-bar,x-foo", true), - actest("GET:*", "GET:x-bar,x-foo", true), - actest("*:*", "GET:x-bar,x-foo", true) - }; - - static boolean failed = false; - - public static void main(String args[]) throws Exception { - for (int i=0; i Date: Mon, 14 Oct 2013 17:27:20 -0700 Subject: 8026362: java/lang/invoke/lambda/LogGeneratedClassesTest.java failed on windows, jtreg report Fail to org.testng.SkipException Reviewed-by: chegar --- test/java/lang/invoke/lambda/LogGeneratedClassesTest.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java b/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java index c34e6e4ae..dc34bba24 100644 --- a/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java +++ b/test/java/lang/invoke/lambda/LogGeneratedClassesTest.java @@ -167,8 +167,12 @@ public class LogGeneratedClassesTest extends LUtils { public void testDumpDirNotWritable() throws IOException { if (! Files.getFileStore(Paths.get(".")) .supportsFileAttributeView(PosixFileAttributeView.class)) { - // No easy way to setup readonly directory - throw new SkipException("Posix not supported"); + // No easy way to setup readonly directory without POSIX + // We would like to skip the test with a cause with + // throw new SkipException("Posix not supported"); + // but jtreg will report failure so we just pass the test + // which we can look at if jtreg changed its behavior + return; } Files.createDirectory(Paths.get("readOnly"), -- cgit v1.2.3 From ce38d3a43f18f944c7cd0e32a84bbaa10bbc8880 Mon Sep 17 00:00:00 2001 From: joehw Date: Mon, 14 Oct 2013 22:24:49 -0700 Subject: 8015092: SchemaFactory cannot parse schema if whitespace added within patterns in Selector XPath expression Reviewed-by: lancea, alanb --- .../validation/8015092/XPathWhiteSpaceTest.java | 60 ++++++++++++++++++++++ test/javax/xml/jaxp/validation/8015092/idIxpns.xsd | 12 +++++ .../javax/xml/jaxp/validation/8015092/idIxpns1.xsd | 12 +++++ test/javax/xml/jaxp/validation/8015092/idJ029.xsd | 21 ++++++++ test/javax/xml/jaxp/validation/8015092/idJimp.xsd | 11 ++++ 5 files changed, 116 insertions(+) create mode 100644 test/javax/xml/jaxp/validation/8015092/XPathWhiteSpaceTest.java create mode 100644 test/javax/xml/jaxp/validation/8015092/idIxpns.xsd create mode 100644 test/javax/xml/jaxp/validation/8015092/idIxpns1.xsd create mode 100644 test/javax/xml/jaxp/validation/8015092/idJ029.xsd create mode 100644 test/javax/xml/jaxp/validation/8015092/idJimp.xsd (limited to 'test') diff --git a/test/javax/xml/jaxp/validation/8015092/XPathWhiteSpaceTest.java b/test/javax/xml/jaxp/validation/8015092/XPathWhiteSpaceTest.java new file mode 100644 index 000000000..c4c4fa2ae --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/XPathWhiteSpaceTest.java @@ -0,0 +1,60 @@ +/* + * 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. + */ + + +/** + * @test + * @bug 8015092 + * @summary whitespace within patterns in Selector XPath expression is accepted + * @run main/othervm XPathWhiteSpaceTest + */ + +import java.io.*; +import javax.xml.XMLConstants; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import org.xml.sax.SAXException; + +/** + * http://www.w3.org/TR/xmlschema-1/#coss-identity-constraint + * For readability, whitespace may be used in selector XPath expressions even though + * not explicitly allowed by the grammar: + * whitespace may be freely added within patterns before or after any token. + * + * @author huizhe.wang@oracle.com + */ +public class XPathWhiteSpaceTest { + static final String XSDFILE = "idJ029.xsd"; + + public static void main(String[] args) throws Exception { + try{ + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Schema schema = schemaFactory.newSchema(new File(System.getProperty("test.src", "."), XSDFILE)); + } catch (SAXException e) { + throw new RuntimeException(e.getMessage()); + } + + + } + +} diff --git a/test/javax/xml/jaxp/validation/8015092/idIxpns.xsd b/test/javax/xml/jaxp/validation/8015092/idIxpns.xsd new file mode 100644 index 000000000..941695faf --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/idIxpns.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/test/javax/xml/jaxp/validation/8015092/idIxpns1.xsd b/test/javax/xml/jaxp/validation/8015092/idIxpns1.xsd new file mode 100644 index 000000000..d0ff89a78 --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/idIxpns1.xsd @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/test/javax/xml/jaxp/validation/8015092/idJ029.xsd b/test/javax/xml/jaxp/validation/8015092/idJ029.xsd new file mode 100644 index 000000000..9b83e2958 --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/idJ029.xsd @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/test/javax/xml/jaxp/validation/8015092/idJimp.xsd b/test/javax/xml/jaxp/validation/8015092/idJimp.xsd new file mode 100644 index 000000000..c2b966af9 --- /dev/null +++ b/test/javax/xml/jaxp/validation/8015092/idJimp.xsd @@ -0,0 +1,11 @@ + + + + + + + + + + + -- cgit v1.2.3 From 2ca64fb5bd276ebce5bd6e773ddd6baba7772726 Mon Sep 17 00:00:00 2001 From: jbachorik Date: Tue, 15 Oct 2013 10:26:34 +0200 Subject: 6804470: JvmstatCountersTest.java test times out on slower machines Summary: Increasing the default timeout to cater for the slower machines Reviewed-by: alanb --HG-- extra : rebase_source : f62cc9f90545040a8811bc12b0650ba2869d2731 --- test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java b/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java index 07c9bcc33..442f2b4c5 100644 --- a/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java +++ b/test/sun/management/jmxremote/bootstrap/JvmstatCountersTest.java @@ -29,10 +29,10 @@ * @author Luis-Miguel Alventosa * @run clean JvmstatCountersTest * @run build JvmstatCountersTest - * @run main/othervm JvmstatCountersTest 1 - * @run main/othervm -Dcom.sun.management.jmxremote JvmstatCountersTest 2 - * @run main/othervm -Dcom.sun.management.jmxremote.port=0 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false JvmstatCountersTest 3 - * @run main/othervm JvmstatCountersTest 4 + * @run main/othervm/timeout=600 JvmstatCountersTest 1 + * @run main/othervm/timeout=600 -Dcom.sun.management.jmxremote JvmstatCountersTest 2 + * @run main/othervm/timeout=600 -Dcom.sun.management.jmxremote.port=0 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false JvmstatCountersTest 3 + * @run main/othervm/timeout=600 JvmstatCountersTest 4 */ import java.io.*; -- cgit v1.2.3 From 1693f5680c5f1d34b941fdda605cb28b69e8a749 Mon Sep 17 00:00:00 2001 From: dfuchs Date: Tue, 15 Oct 2013 13:01:28 +0200 Subject: 8026404: Logging in Applet can trigger ACE: access denied ("java.lang.RuntimePermission" "modifyThreadGroup") Summary: The test 'threadGroup.getParent() == null' can sometimes throw ACE and needs to be wrapped in doPrivileged. Reviewed-by: alanb, mchung, dholmes --- test/TEST.groups | 1 + test/java/util/logging/TestMainAppContext.java | 85 ++++++++++++++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 test/java/util/logging/TestMainAppContext.java (limited to 'test') diff --git a/test/TEST.groups b/test/TEST.groups index 23c9a8332..aa305fd72 100644 --- a/test/TEST.groups +++ b/test/TEST.groups @@ -360,6 +360,7 @@ needs_jre = \ java/security/Security/ClassLoaderDeadlock/Deadlock.sh \ java/util/logging/Listeners.java \ java/util/logging/ListenersWithSM.java \ + java/util/logging/TestMainAppContext.java \ java/util/ResourceBundle/Control/Bug6530694.java \ java/text/Bidi/BidiConformance.java \ java/text/Bidi/BidiEmbeddingTest.java \ diff --git a/test/java/util/logging/TestMainAppContext.java b/test/java/util/logging/TestMainAppContext.java new file mode 100644 index 000000000..28c3fc142 --- /dev/null +++ b/test/java/util/logging/TestMainAppContext.java @@ -0,0 +1,85 @@ +/* + * 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. + */ +import java.util.logging.Logger; +import sun.awt.AppContext; +import sun.awt.SunToolkit; + + +/** + * @test + * @bug 8026404 + * @summary checks that calling getLogger() from a Thread whose ThreadGroup is + * a child of the main root group doesn't throw an exception. + * @build TestMainAppContext + * @run main/othervm TestMainAppContext + * @author danielfuchs + */ +public class TestMainAppContext { + + static volatile Throwable thrown = null; + + public static void main(String... args) throws Exception { + ThreadGroup rootTG = Thread.currentThread().getThreadGroup(); + while (rootTG.getParent() != null) { + rootTG = rootTG.getParent(); + } + + ThreadGroup tg = new ThreadGroup(rootTG, "FakeApplet"); + final Thread t1 = new Thread(tg, "createNewAppContext") { + @Override + public void run() { + try { + AppContext context = SunToolkit.createNewAppContext(); + } catch(Throwable t) { + thrown = t; + } + } + }; + t1.start(); + t1.join(); + if (thrown != null) { + throw new RuntimeException("Unexpected exception: " + thrown, thrown); + } + Thread t2 = new Thread(tg, "BugDetector") { + + @Override + public void run() { + try { + Logger.getLogger("foo").info("Done"); + } catch (Throwable x) { + thrown = x; + } + } + + }; + + System.setSecurityManager(new SecurityManager()); + t2.start(); + t2.join(); + if (thrown != null) { + throw new RuntimeException("Test failed: " + thrown, thrown); + } + + } + +} -- cgit v1.2.3 From 29012c6384dc4cb4f5c55ea4e4bc32fb2c4b0c18 Mon Sep 17 00:00:00 2001 From: rriggs Date: Tue, 15 Oct 2013 13:14:03 -0400 Subject: 8025722: TemporalAdjusters and TemporalQueries Summary: Move static from interfaces methods to supporting classes Reviewed-by: sherman --- test/java/time/tck/java/time/TCKDayOfWeek.java | 15 ++-- test/java/time/tck/java/time/TCKInstant.java | 15 ++-- test/java/time/tck/java/time/TCKLocalDate.java | 15 ++-- test/java/time/tck/java/time/TCKLocalDateTime.java | 15 ++-- test/java/time/tck/java/time/TCKLocalTime.java | 17 +++-- test/java/time/tck/java/time/TCKMonth.java | 15 ++-- test/java/time/tck/java/time/TCKMonthDay.java | 15 ++-- .../java/time/tck/java/time/TCKOffsetDateTime.java | 15 ++-- test/java/time/tck/java/time/TCKOffsetTime.java | 15 ++-- test/java/time/tck/java/time/TCKYear.java | 19 ++--- test/java/time/tck/java/time/TCKYearMonth.java | 23 +++--- test/java/time/tck/java/time/TCKZoneId.java | 3 +- test/java/time/tck/java/time/TCKZoneOffset.java | 15 ++-- test/java/time/tck/java/time/TCKZonedDateTime.java | 25 +++--- .../java/time/tck/java/time/TestIsoChronology.java | 6 +- .../java/time/tck/java/time/chrono/CopticDate.java | 2 +- .../java/time/chrono/TCKChronoLocalDateTime.java | 2 +- .../java/time/chrono/TCKChronoZonedDateTime.java | 2 +- .../tck/java/time/chrono/TCKIsoChronology.java | 18 +++-- .../java/time/chrono/TCKJapaneseChronology.java | 13 ++-- .../tck/java/time/chrono/TCKMinguoChronology.java | 8 +- .../time/chrono/TCKThaiBuddhistChronology.java | 6 +- .../java/time/format/TCKChronoPrinterParser.java | 5 +- .../java/time/format/TCKDateTimeFormatters.java | 7 +- .../java/time/format/TCKDateTimeParseResolver.java | 86 ++++++++++----------- .../time/format/TCKLocalizedPrinterParser.java | 8 +- .../java/time/format/TCKZoneIdPrinterParser.java | 34 ++++----- .../java/time/temporal/TCKTemporalAdjusters.java | 89 +++++++++++----------- .../java/time/chrono/TestUmmAlQuraChronology.java | 16 ++-- .../java/time/format/TestCharLiteralParser.java | 6 +- .../test/java/time/format/TestNonIsoFormatter.java | 4 +- .../test/java/time/format/TestNumberParser.java | 26 +++---- .../java/time/format/TestStringLiteralParser.java | 6 +- .../time/format/TestZoneTextPrinterParser.java | 6 +- test/java/time/test/java/util/TestFormatter.java | 4 +- 35 files changed, 297 insertions(+), 279 deletions(-) (limited to 'test') diff --git a/test/java/time/tck/java/time/TCKDayOfWeek.java b/test/java/time/tck/java/time/TCKDayOfWeek.java index 3bf782ba9..e3f0e719c 100644 --- a/test/java/time/tck/java/time/TCKDayOfWeek.java +++ b/test/java/time/tck/java/time/TCKDayOfWeek.java @@ -77,6 +77,7 @@ import java.time.temporal.JulianFields; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.util.ArrayList; import java.util.Arrays; @@ -215,13 +216,13 @@ public class TCKDayOfWeek extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {DayOfWeek.FRIDAY, TemporalQuery.chronology(), null}, - {DayOfWeek.FRIDAY, TemporalQuery.zoneId(), null}, - {DayOfWeek.FRIDAY, TemporalQuery.precision(), ChronoUnit.DAYS}, - {DayOfWeek.FRIDAY, TemporalQuery.zone(), null}, - {DayOfWeek.FRIDAY, TemporalQuery.offset(), null}, - {DayOfWeek.FRIDAY, TemporalQuery.localDate(), null}, - {DayOfWeek.FRIDAY, TemporalQuery.localTime(), null}, + {DayOfWeek.FRIDAY, TemporalQueries.chronology(), null}, + {DayOfWeek.FRIDAY, TemporalQueries.zoneId(), null}, + {DayOfWeek.FRIDAY, TemporalQueries.precision(), ChronoUnit.DAYS}, + {DayOfWeek.FRIDAY, TemporalQueries.zone(), null}, + {DayOfWeek.FRIDAY, TemporalQueries.offset(), null}, + {DayOfWeek.FRIDAY, TemporalQueries.localDate(), null}, + {DayOfWeek.FRIDAY, TemporalQueries.localTime(), null}, }; } diff --git a/test/java/time/tck/java/time/TCKInstant.java b/test/java/time/tck/java/time/TCKInstant.java index bf6ac9e70..ee3898e1b 100644 --- a/test/java/time/tck/java/time/TCKInstant.java +++ b/test/java/time/tck/java/time/TCKInstant.java @@ -97,6 +97,7 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.time.temporal.UnsupportedTemporalTypeException; @@ -401,13 +402,13 @@ public class TCKInstant extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_12345_123456789, TemporalQuery.chronology(), null}, - {TEST_12345_123456789, TemporalQuery.zoneId(), null}, - {TEST_12345_123456789, TemporalQuery.precision(), NANOS}, - {TEST_12345_123456789, TemporalQuery.zone(), null}, - {TEST_12345_123456789, TemporalQuery.offset(), null}, - {TEST_12345_123456789, TemporalQuery.localDate(), null}, - {TEST_12345_123456789, TemporalQuery.localTime(), null}, + {TEST_12345_123456789, TemporalQueries.chronology(), null}, + {TEST_12345_123456789, TemporalQueries.zoneId(), null}, + {TEST_12345_123456789, TemporalQueries.precision(), NANOS}, + {TEST_12345_123456789, TemporalQueries.zone(), null}, + {TEST_12345_123456789, TemporalQueries.offset(), null}, + {TEST_12345_123456789, TemporalQueries.localDate(), null}, + {TEST_12345_123456789, TemporalQueries.localTime(), null}, }; } diff --git a/test/java/time/tck/java/time/TCKLocalDate.java b/test/java/time/tck/java/time/TCKLocalDate.java index cb41a7079..02e2f0789 100644 --- a/test/java/time/tck/java/time/TCKLocalDate.java +++ b/test/java/time/tck/java/time/TCKLocalDate.java @@ -113,6 +113,7 @@ import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.time.temporal.UnsupportedTemporalTypeException; @@ -693,13 +694,13 @@ public class TCKLocalDate extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2007_07_15, TemporalQuery.chronology(), IsoChronology.INSTANCE}, - {TEST_2007_07_15, TemporalQuery.zoneId(), null}, - {TEST_2007_07_15, TemporalQuery.precision(), ChronoUnit.DAYS}, - {TEST_2007_07_15, TemporalQuery.zone(), null}, - {TEST_2007_07_15, TemporalQuery.offset(), null}, - {TEST_2007_07_15, TemporalQuery.localDate(), TEST_2007_07_15}, - {TEST_2007_07_15, TemporalQuery.localTime(), null}, + {TEST_2007_07_15, TemporalQueries.chronology(), IsoChronology.INSTANCE}, + {TEST_2007_07_15, TemporalQueries.zoneId(), null}, + {TEST_2007_07_15, TemporalQueries.precision(), ChronoUnit.DAYS}, + {TEST_2007_07_15, TemporalQueries.zone(), null}, + {TEST_2007_07_15, TemporalQueries.offset(), null}, + {TEST_2007_07_15, TemporalQueries.localDate(), TEST_2007_07_15}, + {TEST_2007_07_15, TemporalQueries.localTime(), null}, }; } diff --git a/test/java/time/tck/java/time/TCKLocalDateTime.java b/test/java/time/tck/java/time/TCKLocalDateTime.java index 62b53b3b8..6303f5acd 100644 --- a/test/java/time/tck/java/time/TCKLocalDateTime.java +++ b/test/java/time/tck/java/time/TCKLocalDateTime.java @@ -134,6 +134,7 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.util.ArrayList; @@ -1017,13 +1018,13 @@ public class TCKLocalDateTime extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.chronology(), IsoChronology.INSTANCE}, - {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.zoneId(), null}, - {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.precision(), ChronoUnit.NANOS}, - {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.zone(), null}, - {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.offset(), null}, - {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.localDate(), LocalDate.of(2007, 7, 15)}, - {TEST_2007_07_15_12_30_40_987654321, TemporalQuery.localTime(), LocalTime.of(12, 30, 40, 987654321)}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQueries.chronology(), IsoChronology.INSTANCE}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQueries.zoneId(), null}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQueries.precision(), ChronoUnit.NANOS}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQueries.zone(), null}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQueries.offset(), null}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQueries.localDate(), LocalDate.of(2007, 7, 15)}, + {TEST_2007_07_15_12_30_40_987654321, TemporalQueries.localTime(), LocalTime.of(12, 30, 40, 987654321)}, }; } diff --git a/test/java/time/tck/java/time/TCKLocalTime.java b/test/java/time/tck/java/time/TCKLocalTime.java index bac3f8587..704533afc 100644 --- a/test/java/time/tck/java/time/TCKLocalTime.java +++ b/test/java/time/tck/java/time/TCKLocalTime.java @@ -116,6 +116,7 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.time.temporal.UnsupportedTemporalTypeException; @@ -143,7 +144,7 @@ public class TCKLocalTime extends AbstractDateTimeTest { private static final TemporalUnit[] INVALID_UNITS; static { EnumSet set = EnumSet.range(DAYS, FOREVER); - INVALID_UNITS = (TemporalUnit[]) set.toArray(new TemporalUnit[set.size()]); + INVALID_UNITS = set.toArray(new TemporalUnit[set.size()]); } @BeforeMethod @@ -654,13 +655,13 @@ public class TCKLocalTime extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_12_30_40_987654321, TemporalQuery.chronology(), null}, - {TEST_12_30_40_987654321, TemporalQuery.zoneId(), null}, - {TEST_12_30_40_987654321, TemporalQuery.precision(), ChronoUnit.NANOS}, - {TEST_12_30_40_987654321, TemporalQuery.zone(), null}, - {TEST_12_30_40_987654321, TemporalQuery.offset(), null}, - {TEST_12_30_40_987654321, TemporalQuery.localDate(), null}, - {TEST_12_30_40_987654321, TemporalQuery.localTime(), TEST_12_30_40_987654321}, + {TEST_12_30_40_987654321, TemporalQueries.chronology(), null}, + {TEST_12_30_40_987654321, TemporalQueries.zoneId(), null}, + {TEST_12_30_40_987654321, TemporalQueries.precision(), ChronoUnit.NANOS}, + {TEST_12_30_40_987654321, TemporalQueries.zone(), null}, + {TEST_12_30_40_987654321, TemporalQueries.offset(), null}, + {TEST_12_30_40_987654321, TemporalQueries.localDate(), null}, + {TEST_12_30_40_987654321, TemporalQueries.localTime(), TEST_12_30_40_987654321}, }; } diff --git a/test/java/time/tck/java/time/TCKMonth.java b/test/java/time/tck/java/time/TCKMonth.java index 3bff8c9be..df879e7d1 100644 --- a/test/java/time/tck/java/time/TCKMonth.java +++ b/test/java/time/tck/java/time/TCKMonth.java @@ -73,6 +73,7 @@ import java.time.temporal.ChronoUnit; import java.time.temporal.JulianFields; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.util.ArrayList; import java.util.Arrays; @@ -207,13 +208,13 @@ public class TCKMonth extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {Month.JUNE, TemporalQuery.chronology(), IsoChronology.INSTANCE}, - {Month.JUNE, TemporalQuery.zoneId(), null}, - {Month.JUNE, TemporalQuery.precision(), ChronoUnit.MONTHS}, - {Month.JUNE, TemporalQuery.zone(), null}, - {Month.JUNE, TemporalQuery.offset(), null}, - {Month.JUNE, TemporalQuery.localDate(), null}, - {Month.JUNE, TemporalQuery.localTime(), null}, + {Month.JUNE, TemporalQueries.chronology(), IsoChronology.INSTANCE}, + {Month.JUNE, TemporalQueries.zoneId(), null}, + {Month.JUNE, TemporalQueries.precision(), ChronoUnit.MONTHS}, + {Month.JUNE, TemporalQueries.zone(), null}, + {Month.JUNE, TemporalQueries.offset(), null}, + {Month.JUNE, TemporalQueries.localDate(), null}, + {Month.JUNE, TemporalQueries.localTime(), null}, }; } diff --git a/test/java/time/tck/java/time/TCKMonthDay.java b/test/java/time/tck/java/time/TCKMonthDay.java index e9b1730cb..99a711666 100644 --- a/test/java/time/tck/java/time/TCKMonthDay.java +++ b/test/java/time/tck/java/time/TCKMonthDay.java @@ -86,6 +86,7 @@ import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.util.ArrayList; import java.util.Arrays; @@ -428,13 +429,13 @@ public class TCKMonthDay extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_07_15, TemporalQuery.chronology(), IsoChronology.INSTANCE}, - {TEST_07_15, TemporalQuery.zoneId(), null}, - {TEST_07_15, TemporalQuery.precision(), null}, - {TEST_07_15, TemporalQuery.zone(), null}, - {TEST_07_15, TemporalQuery.offset(), null}, - {TEST_07_15, TemporalQuery.localDate(), null}, - {TEST_07_15, TemporalQuery.localTime(), null}, + {TEST_07_15, TemporalQueries.chronology(), IsoChronology.INSTANCE}, + {TEST_07_15, TemporalQueries.zoneId(), null}, + {TEST_07_15, TemporalQueries.precision(), null}, + {TEST_07_15, TemporalQueries.zone(), null}, + {TEST_07_15, TemporalQueries.offset(), null}, + {TEST_07_15, TemporalQueries.localDate(), null}, + {TEST_07_15, TemporalQueries.localTime(), null}, }; } diff --git a/test/java/time/tck/java/time/TCKOffsetDateTime.java b/test/java/time/tck/java/time/TCKOffsetDateTime.java index 0ced814d0..b77b7a8ba 100644 --- a/test/java/time/tck/java/time/TCKOffsetDateTime.java +++ b/test/java/time/tck/java/time/TCKOffsetDateTime.java @@ -132,6 +132,7 @@ import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.util.ArrayList; @@ -635,13 +636,13 @@ public class TCKOffsetDateTime extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.chronology(), IsoChronology.INSTANCE}, - {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.zoneId(), null}, - {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.precision(), ChronoUnit.NANOS}, - {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.zone(), OFFSET_PONE}, - {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.offset(), OFFSET_PONE}, - {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.localDate(), LocalDate.of(2008, 6, 30)}, - {TEST_2008_6_30_11_30_59_000000500, TemporalQuery.localTime(), LocalTime.of(11, 30, 59, 500)}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.chronology(), IsoChronology.INSTANCE}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.zoneId(), null}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.precision(), ChronoUnit.NANOS}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.zone(), OFFSET_PONE}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.offset(), OFFSET_PONE}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.localDate(), LocalDate.of(2008, 6, 30)}, + {TEST_2008_6_30_11_30_59_000000500, TemporalQueries.localTime(), LocalTime.of(11, 30, 59, 500)}, }; } diff --git a/test/java/time/tck/java/time/TCKOffsetTime.java b/test/java/time/tck/java/time/TCKOffsetTime.java index 5bc2312ea..d373be443 100644 --- a/test/java/time/tck/java/time/TCKOffsetTime.java +++ b/test/java/time/tck/java/time/TCKOffsetTime.java @@ -115,6 +115,7 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.util.ArrayList; @@ -605,13 +606,13 @@ public class TCKOffsetTime extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_11_30_59_500_PONE, TemporalQuery.chronology(), null}, - {TEST_11_30_59_500_PONE, TemporalQuery.zoneId(), null}, - {TEST_11_30_59_500_PONE, TemporalQuery.precision(), ChronoUnit.NANOS}, - {TEST_11_30_59_500_PONE, TemporalQuery.zone(), OFFSET_PONE}, - {TEST_11_30_59_500_PONE, TemporalQuery.offset(), OFFSET_PONE}, - {TEST_11_30_59_500_PONE, TemporalQuery.localDate(), null}, - {TEST_11_30_59_500_PONE, TemporalQuery.localTime(), LocalTime.of(11, 30, 59, 500)}, + {TEST_11_30_59_500_PONE, TemporalQueries.chronology(), null}, + {TEST_11_30_59_500_PONE, TemporalQueries.zoneId(), null}, + {TEST_11_30_59_500_PONE, TemporalQueries.precision(), ChronoUnit.NANOS}, + {TEST_11_30_59_500_PONE, TemporalQueries.zone(), OFFSET_PONE}, + {TEST_11_30_59_500_PONE, TemporalQueries.offset(), OFFSET_PONE}, + {TEST_11_30_59_500_PONE, TemporalQueries.localDate(), null}, + {TEST_11_30_59_500_PONE, TemporalQueries.localTime(), LocalTime.of(11, 30, 59, 500)}, }; } diff --git a/test/java/time/tck/java/time/TCKYear.java b/test/java/time/tck/java/time/TCKYear.java index 59d464a53..75ed80e13 100644 --- a/test/java/time/tck/java/time/TCKYear.java +++ b/test/java/time/tck/java/time/TCKYear.java @@ -99,6 +99,7 @@ import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.time.temporal.UnsupportedTemporalTypeException; @@ -411,13 +412,13 @@ public class TCKYear extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2008, TemporalQuery.chronology(), IsoChronology.INSTANCE}, - {TEST_2008, TemporalQuery.zoneId(), null}, - {TEST_2008, TemporalQuery.precision(), ChronoUnit.YEARS}, - {TEST_2008, TemporalQuery.zone(), null}, - {TEST_2008, TemporalQuery.offset(), null}, - {TEST_2008, TemporalQuery.localDate(), null}, - {TEST_2008, TemporalQuery.localTime(), null}, + {TEST_2008, TemporalQueries.chronology(), IsoChronology.INSTANCE}, + {TEST_2008, TemporalQueries.zoneId(), null}, + {TEST_2008, TemporalQueries.precision(), ChronoUnit.YEARS}, + {TEST_2008, TemporalQueries.zone(), null}, + {TEST_2008, TemporalQueries.offset(), null}, + {TEST_2008, TemporalQueries.localDate(), null}, + {TEST_2008, TemporalQueries.localTime(), null}, }; } @@ -596,7 +597,7 @@ public class TCKYear extends AbstractDateTimeTest { } @Test(dataProvider="plus_long_TemporalUnit") - public void test_plus_long_TemporalUnit(Year base, long amount, TemporalUnit unit, Year expectedYear, Class expectedEx) { + public void test_plus_long_TemporalUnit(Year base, long amount, TemporalUnit unit, Year expectedYear, Class expectedEx) { if (expectedEx == null) { assertEquals(base.plus(amount, unit), expectedYear); } else { @@ -728,7 +729,7 @@ public class TCKYear extends AbstractDateTimeTest { } @Test(dataProvider="minus_long_TemporalUnit") - public void test_minus_long_TemporalUnit(Year base, long amount, TemporalUnit unit, Year expectedYear, Class expectedEx) { + public void test_minus_long_TemporalUnit(Year base, long amount, TemporalUnit unit, Year expectedYear, Class expectedEx) { if (expectedEx == null) { assertEquals(base.minus(amount, unit), expectedYear); } else { diff --git a/test/java/time/tck/java/time/TCKYearMonth.java b/test/java/time/tck/java/time/TCKYearMonth.java index bb16839bd..e922f7232 100644 --- a/test/java/time/tck/java/time/TCKYearMonth.java +++ b/test/java/time/tck/java/time/TCKYearMonth.java @@ -100,6 +100,7 @@ import java.time.temporal.JulianFields; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.time.temporal.UnsupportedTemporalTypeException; @@ -476,13 +477,13 @@ public class TCKYearMonth extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {TEST_2008_06, TemporalQuery.chronology(), IsoChronology.INSTANCE}, - {TEST_2008_06, TemporalQuery.zoneId(), null}, - {TEST_2008_06, TemporalQuery.precision(), ChronoUnit.MONTHS}, - {TEST_2008_06, TemporalQuery.zone(), null}, - {TEST_2008_06, TemporalQuery.offset(), null}, - {TEST_2008_06, TemporalQuery.localDate(), null}, - {TEST_2008_06, TemporalQuery.localTime(), null}, + {TEST_2008_06, TemporalQueries.chronology(), IsoChronology.INSTANCE}, + {TEST_2008_06, TemporalQueries.zoneId(), null}, + {TEST_2008_06, TemporalQueries.precision(), ChronoUnit.MONTHS}, + {TEST_2008_06, TemporalQueries.zone(), null}, + {TEST_2008_06, TemporalQueries.offset(), null}, + {TEST_2008_06, TemporalQueries.localDate(), null}, + {TEST_2008_06, TemporalQueries.localTime(), null}, }; } @@ -768,7 +769,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { } @Test(dataProvider="plus_long_TemporalUnit") - public void test_plus_long_TemporalUnit(YearMonth base, long amount, TemporalUnit unit, YearMonth expectedYearMonth, Class expectedEx) { + public void test_plus_long_TemporalUnit(YearMonth base, long amount, TemporalUnit unit, YearMonth expectedYearMonth, Class expectedEx) { if (expectedEx == null) { assertEquals(base.plus(amount, unit), expectedYearMonth); } else { @@ -820,7 +821,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { } @Test(dataProvider="plus_TemporalAmount") - public void test_plus_TemporalAmount(YearMonth base, TemporalAmount temporalAmount, YearMonth expectedYearMonth, Class expectedEx) { + public void test_plus_TemporalAmount(YearMonth base, TemporalAmount temporalAmount, YearMonth expectedYearMonth, Class expectedEx) { if (expectedEx == null) { assertEquals(base.plus(temporalAmount), expectedYearMonth); } else { @@ -983,7 +984,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { } @Test(dataProvider="minus_long_TemporalUnit") - public void test_minus_long_TemporalUnit(YearMonth base, long amount, TemporalUnit unit, YearMonth expectedYearMonth, Class expectedEx) { + public void test_minus_long_TemporalUnit(YearMonth base, long amount, TemporalUnit unit, YearMonth expectedYearMonth, Class expectedEx) { if (expectedEx == null) { assertEquals(base.minus(amount, unit), expectedYearMonth); } else { @@ -1035,7 +1036,7 @@ public class TCKYearMonth extends AbstractDateTimeTest { } @Test(dataProvider="minus_TemporalAmount") - public void test_minus_TemporalAmount(YearMonth base, TemporalAmount temporalAmount, YearMonth expectedYearMonth, Class expectedEx) { + public void test_minus_TemporalAmount(YearMonth base, TemporalAmount temporalAmount, YearMonth expectedYearMonth, Class expectedEx) { if (expectedEx == null) { assertEquals(base.minus(temporalAmount), expectedYearMonth); } else { diff --git a/test/java/time/tck/java/time/TCKZoneId.java b/test/java/time/tck/java/time/TCKZoneId.java index 0d47403db..c036deeb7 100644 --- a/test/java/time/tck/java/time/TCKZoneId.java +++ b/test/java/time/tck/java/time/TCKZoneId.java @@ -76,6 +76,7 @@ import java.time.ZoneOffset; import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.zone.ZoneRulesException; import java.util.HashMap; @@ -559,7 +560,7 @@ public class TCKZoneId extends AbstractTCKTest { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == TemporalQuery.zoneId()) { + if (query == TemporalQueries.zoneId()) { return (R) ZoneId.of("Europe/Paris"); } return TemporalAccessor.super.query(query); diff --git a/test/java/time/tck/java/time/TCKZoneOffset.java b/test/java/time/tck/java/time/TCKZoneOffset.java index cf9098a18..c121079da 100644 --- a/test/java/time/tck/java/time/TCKZoneOffset.java +++ b/test/java/time/tck/java/time/TCKZoneOffset.java @@ -81,6 +81,7 @@ import java.time.temporal.ChronoField; import java.time.temporal.JulianFields; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.util.ArrayList; import java.util.Arrays; @@ -523,13 +524,13 @@ public class TCKZoneOffset extends AbstractDateTimeTest { @DataProvider(name="query") Object[][] data_query() { return new Object[][] { - {ZoneOffset.UTC, TemporalQuery.chronology(), null}, - {ZoneOffset.UTC, TemporalQuery.zoneId(), null}, - {ZoneOffset.UTC, TemporalQuery.precision(), null}, - {ZoneOffset.UTC, TemporalQuery.zone(), ZoneOffset.UTC}, - {ZoneOffset.UTC, TemporalQuery.offset(), ZoneOffset.UTC}, - {ZoneOffset.UTC, TemporalQuery.localDate(), null}, - {ZoneOffset.UTC, TemporalQuery.localTime(), null}, + {ZoneOffset.UTC, TemporalQueries.chronology(), null}, + {ZoneOffset.UTC, TemporalQueries.zoneId(), null}, + {ZoneOffset.UTC, TemporalQueries.precision(), null}, + {ZoneOffset.UTC, TemporalQueries.zone(), ZoneOffset.UTC}, + {ZoneOffset.UTC, TemporalQueries.offset(), ZoneOffset.UTC}, + {ZoneOffset.UTC, TemporalQueries.localDate(), null}, + {ZoneOffset.UTC, TemporalQueries.localTime(), null}, }; } diff --git a/test/java/time/tck/java/time/TCKZonedDateTime.java b/test/java/time/tck/java/time/TCKZonedDateTime.java index 4c5319d48..fb743e87b 100644 --- a/test/java/time/tck/java/time/TCKZonedDateTime.java +++ b/test/java/time/tck/java/time/TCKZonedDateTime.java @@ -126,6 +126,7 @@ import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalAdjuster; import java.time.temporal.TemporalAmount; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.time.temporal.TemporalUnit; import java.util.ArrayList; @@ -685,7 +686,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == TemporalQuery.zoneId()) { + if (query == TemporalQueries.zoneId()) { return (R) TEST_DATE_TIME_PARIS.getZone(); } return TemporalAccessor.super.query(query); @@ -709,7 +710,7 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == TemporalQuery.zoneId()) { + if (query == TemporalQueries.zoneId()) { return (R) TEST_DATE_TIME_PARIS.getZone(); } return TemporalAccessor.super.query(query); @@ -964,32 +965,32 @@ public class TCKZonedDateTime extends AbstractDateTimeTest { //----------------------------------------------------------------------- @Test public void test_query_chrono() { - assertEquals(TEST_DATE_TIME.query(TemporalQuery.chronology()), IsoChronology.INSTANCE); - assertEquals(TemporalQuery.chronology().queryFrom(TEST_DATE_TIME), IsoChronology.INSTANCE); + assertEquals(TEST_DATE_TIME.query(TemporalQueries.chronology()), IsoChronology.INSTANCE); + assertEquals(TemporalQueries.chronology().queryFrom(TEST_DATE_TIME), IsoChronology.INSTANCE); } @Test public void test_query_zoneId() { - assertEquals(TEST_DATE_TIME.query(TemporalQuery.zoneId()), TEST_DATE_TIME.getZone()); - assertEquals(TemporalQuery.zoneId().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); + assertEquals(TEST_DATE_TIME.query(TemporalQueries.zoneId()), TEST_DATE_TIME.getZone()); + assertEquals(TemporalQueries.zoneId().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); } @Test public void test_query_precision() { - assertEquals(TEST_DATE_TIME.query(TemporalQuery.precision()), NANOS); - assertEquals(TemporalQuery.precision().queryFrom(TEST_DATE_TIME), NANOS); + assertEquals(TEST_DATE_TIME.query(TemporalQueries.precision()), NANOS); + assertEquals(TemporalQueries.precision().queryFrom(TEST_DATE_TIME), NANOS); } @Test public void test_query_offset() { - assertEquals(TEST_DATE_TIME.query(TemporalQuery.offset()), TEST_DATE_TIME.getOffset()); - assertEquals(TemporalQuery.offset().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getOffset()); + assertEquals(TEST_DATE_TIME.query(TemporalQueries.offset()), TEST_DATE_TIME.getOffset()); + assertEquals(TemporalQueries.offset().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getOffset()); } @Test public void test_query_zone() { - assertEquals(TEST_DATE_TIME.query(TemporalQuery.zone()), TEST_DATE_TIME.getZone()); - assertEquals(TemporalQuery.zone().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); + assertEquals(TEST_DATE_TIME.query(TemporalQueries.zone()), TEST_DATE_TIME.getZone()); + assertEquals(TemporalQueries.zone().queryFrom(TEST_DATE_TIME), TEST_DATE_TIME.getZone()); } @Test(expectedExceptions=NullPointerException.class) diff --git a/test/java/time/tck/java/time/TestIsoChronology.java b/test/java/time/tck/java/time/TestIsoChronology.java index c99ec2a3a..5b1a5c67c 100644 --- a/test/java/time/tck/java/time/TestIsoChronology.java +++ b/test/java/time/tck/java/time/TestIsoChronology.java @@ -80,7 +80,7 @@ import java.time.chrono.HijrahEra; import java.time.chrono.IsoChronology; import java.time.chrono.IsoEra; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAdjusters; import org.testng.Assert; import org.testng.annotations.DataProvider; @@ -208,14 +208,14 @@ public class TestIsoChronology { @Test public void test_adjust1() { LocalDate base = IsoChronology.INSTANCE.date(1728, 10, 28); - LocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + LocalDate test = base.with(TemporalAdjusters.lastDayOfMonth()); assertEquals(test, IsoChronology.INSTANCE.date(1728, 10, 31)); } @Test public void test_adjust2() { LocalDate base = IsoChronology.INSTANCE.date(1728, 12, 2); - LocalDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + LocalDate test = base.with(TemporalAdjusters.lastDayOfMonth()); assertEquals(test, IsoChronology.INSTANCE.date(1728, 12, 31)); } diff --git a/test/java/time/tck/java/time/chrono/CopticDate.java b/test/java/time/tck/java/time/chrono/CopticDate.java index c0da69756..a296c5940 100644 --- a/test/java/time/tck/java/time/chrono/CopticDate.java +++ b/test/java/time/tck/java/time/chrono/CopticDate.java @@ -308,7 +308,7 @@ public final class CopticDate @Override public Period until(ChronoLocalDate endDate) { // TODO: untested - CopticDate end = (CopticDate) getChronology().date(endDate); + CopticDate end = getChronology().date(endDate); long totalMonths = (end.prolepticYear - this.prolepticYear) * 13 + (end.month - this.month); // safe int days = end.day - this.day; if (totalMonths > 0 && days < 0) { diff --git a/test/java/time/tck/java/time/chrono/TCKChronoLocalDateTime.java b/test/java/time/tck/java/time/chrono/TCKChronoLocalDateTime.java index 51b68bb7c..9f9de499d 100644 --- a/test/java/time/tck/java/time/chrono/TCKChronoLocalDateTime.java +++ b/test/java/time/tck/java/time/chrono/TCKChronoLocalDateTime.java @@ -346,7 +346,7 @@ public class TCKChronoLocalDateTime { //----------------------------------------------------------------------- @Test(dataProvider="calendars") public void test_getChronology(Chronology chrono) { - ChronoLocalDateTime test = chrono.localDateTime(LocalDateTime.of(2010, 6, 30, 11, 30)); + ChronoLocalDateTime test = chrono.localDateTime(LocalDateTime.of(2010, 6, 30, 11, 30)); assertEquals(test.getChronology(), chrono); } diff --git a/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java b/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java index 0cabccab0..c3a1d2dcb 100644 --- a/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java +++ b/test/java/time/tck/java/time/chrono/TCKChronoZonedDateTime.java @@ -347,7 +347,7 @@ public class TCKChronoZonedDateTime { //----------------------------------------------------------------------- @Test(dataProvider="calendars") public void test_getChronology(Chronology chrono) { - ChronoZonedDateTime test = chrono.zonedDateTime(ZonedDateTime.of(2010, 6, 30, 11, 30, 0, 0, ZoneOffset.UTC)); + ChronoZonedDateTime test = chrono.zonedDateTime(ZonedDateTime.of(2010, 6, 30, 11, 30, 0, 0, ZoneOffset.UTC)); assertEquals(test.getChronology(), chrono); } diff --git a/test/java/time/tck/java/time/chrono/TCKIsoChronology.java b/test/java/time/tck/java/time/chrono/TCKIsoChronology.java index a69f556b5..0cd8eed5f 100644 --- a/test/java/time/tck/java/time/chrono/TCKIsoChronology.java +++ b/test/java/time/tck/java/time/chrono/TCKIsoChronology.java @@ -70,7 +70,9 @@ import java.time.chrono.IsoChronology; import java.time.format.ResolverStyle; import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.util.HashMap; import java.util.Map; @@ -107,7 +109,7 @@ public class TCKIsoChronology { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == TemporalQuery.chronology()) { + if (query == TemporalQueries.chronology()) { return (R) IsoChronology.INSTANCE; } throw new UnsupportedOperationException(); @@ -130,7 +132,7 @@ public class TCKIsoChronology { @Override public R query(TemporalQuery query) { - if (query == TemporalQuery.chronology()) { + if (query == TemporalQueries.chronology()) { return null; } throw new UnsupportedOperationException(); @@ -166,7 +168,7 @@ public class TCKIsoChronology { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == TemporalQuery.localDate()) { + if (query == TemporalQueries.localDate()) { return (R) LocalDate.of(2012, 6, 30); } throw new UnsupportedOperationException(); @@ -205,10 +207,10 @@ public class TCKIsoChronology { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == TemporalQuery.localDate()) { + if (query == TemporalQueries.localDate()) { return (R) LocalDate.of(2012, 6, 30); } - if (query == TemporalQuery.localTime()) { + if (query == TemporalQueries.localTime()) { return (R) LocalTime.of(12, 30, 40); } throw new UnsupportedOperationException(); @@ -254,13 +256,13 @@ public class TCKIsoChronology { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == TemporalQuery.localDate()) { + if (query == TemporalQueries.localDate()) { return (R) LocalDate.of(2012, 6, 30); } - if (query == TemporalQuery.localTime()) { + if (query == TemporalQueries.localTime()) { return (R) LocalTime.of(12, 30, 40); } - if (query == TemporalQuery.zoneId() || query == TemporalQuery.zone()) { + if (query == TemporalQueries.zoneId() || query == TemporalQueries.zone()) { return (R) ZoneId.of("Europe/London"); } throw new UnsupportedOperationException(); diff --git a/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java b/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java index fd53b0f0b..2bc1f4c8c 100644 --- a/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java +++ b/test/java/time/tck/java/time/chrono/TCKJapaneseChronology.java @@ -92,10 +92,9 @@ import java.time.chrono.ThaiBuddhistChronology; import java.time.format.ResolverStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.Temporal; -import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalField; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalQueries; import java.time.temporal.ValueRange; import java.util.HashMap; @@ -229,7 +228,7 @@ public class TCKJapaneseChronology { @Test(dataProvider="createByEra") public void test_createByEra_query(JapaneseEra era, int yoe, int moy, int dom, int doy, LocalDate iso) { JapaneseDate test = JapaneseDate.of(era, yoe, moy, dom); - assertEquals(test.query(TemporalQuery.localDate()), iso); + assertEquals(test.query(TemporalQueries.localDate()), iso); } @Test(dataProvider="createByEra") @@ -297,7 +296,7 @@ public class TCKJapaneseChronology { @Test(dataProvider="createByProleptic") public void test_createByProleptic_query(int y, int moy, int dom, int doy, LocalDate iso) { JapaneseDate test = JapaneseDate.of(y, moy, dom); - assertEquals(test.query(TemporalQuery.localDate()), iso); + assertEquals(test.query(TemporalQueries.localDate()), iso); } @Test(dataProvider="createByProleptic") @@ -495,14 +494,14 @@ public class TCKJapaneseChronology { @Test public void test_adjust1() { JapaneseDate base = JapaneseChronology.INSTANCE.date(1928, 10, 29); - JapaneseDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + JapaneseDate test = base.with(TemporalAdjusters.lastDayOfMonth()); assertEquals(test, JapaneseChronology.INSTANCE.date(1928, 10, 31)); } @Test public void test_adjust2() { JapaneseDate base = JapaneseChronology.INSTANCE.date(1928, 12, 2); - JapaneseDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + JapaneseDate test = base.with(TemporalAdjusters.lastDayOfMonth()); assertEquals(test, JapaneseChronology.INSTANCE.date(1928, 12, 31)); } diff --git a/test/java/time/tck/java/time/chrono/TCKMinguoChronology.java b/test/java/time/tck/java/time/chrono/TCKMinguoChronology.java index ad98e9119..53089a6ee 100644 --- a/test/java/time/tck/java/time/chrono/TCKMinguoChronology.java +++ b/test/java/time/tck/java/time/chrono/TCKMinguoChronology.java @@ -82,15 +82,15 @@ import java.time.chrono.Era; import java.time.chrono.IsoChronology; import java.time.chrono.JapaneseDate; import java.time.chrono.MinguoChronology; -import java.time.chrono.MinguoDate; import java.time.chrono.MinguoEra; +import java.time.chrono.MinguoDate; import java.time.chrono.ThaiBuddhistChronology; import java.time.chrono.ThaiBuddhistDate; import java.time.format.ResolverStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalField; import java.util.HashMap; import java.util.List; @@ -360,14 +360,14 @@ public class TCKMinguoChronology { @Test public void test_adjust1() { MinguoDate base = MinguoChronology.INSTANCE.date(2012, 10, 29); - MinguoDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + MinguoDate test = base.with(TemporalAdjusters.lastDayOfMonth()); assertEquals(test, MinguoChronology.INSTANCE.date(2012, 10, 31)); } @Test public void test_adjust2() { MinguoDate base = MinguoChronology.INSTANCE.date(1728, 12, 2); - MinguoDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + MinguoDate test = base.with(TemporalAdjusters.lastDayOfMonth()); assertEquals(test, MinguoChronology.INSTANCE.date(1728, 12, 31)); } diff --git a/test/java/time/tck/java/time/chrono/TCKThaiBuddhistChronology.java b/test/java/time/tck/java/time/chrono/TCKThaiBuddhistChronology.java index 555764173..955fdeaef 100644 --- a/test/java/time/tck/java/time/chrono/TCKThaiBuddhistChronology.java +++ b/test/java/time/tck/java/time/chrono/TCKThaiBuddhistChronology.java @@ -88,7 +88,7 @@ import java.time.chrono.ThaiBuddhistEra; import java.time.format.ResolverStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; -import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAdjusters; import java.time.temporal.TemporalField; import java.time.temporal.ValueRange; import java.util.HashMap; @@ -366,14 +366,14 @@ public class TCKThaiBuddhistChronology { @Test public void test_adjust1() { ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 10, 29); - ThaiBuddhistDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + ThaiBuddhistDate test = base.with(TemporalAdjusters.lastDayOfMonth()); assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 10, 31)); } @Test public void test_adjust2() { ThaiBuddhistDate base = ThaiBuddhistChronology.INSTANCE.date(1728, 12, 2); - ThaiBuddhistDate test = base.with(TemporalAdjuster.lastDayOfMonth()); + ThaiBuddhistDate test = base.with(TemporalAdjusters.lastDayOfMonth()); assertEquals(test, ThaiBuddhistChronology.INSTANCE.date(1728, 12, 31)); } diff --git a/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java b/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java index de3b91c7f..882bf9ccd 100644 --- a/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java +++ b/test/java/time/tck/java/time/format/TCKChronoPrinterParser.java @@ -68,6 +68,7 @@ import java.time.chrono.JapaneseChronology; import java.time.chrono.ThaiBuddhistChronology; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.TemporalAccessor; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.util.Locale; @@ -122,7 +123,7 @@ public class TCKChronoPrinterParser { TemporalAccessor parsed = builder.toFormatter().parseUnresolved(text, pos); assertEquals(pos.getIndex(), expected.getId().length()); assertEquals(pos.getErrorIndex(), -1); - assertEquals(parsed.query(TemporalQuery.chronology()), expected); + assertEquals(parsed.query(TemporalQueries.chronology()), expected); } @Test(dataProvider="parseValid") @@ -140,7 +141,7 @@ public class TCKChronoPrinterParser { TemporalAccessor parsed = builder.toFormatter().parseUnresolved(text.toLowerCase(Locale.ENGLISH), pos); assertEquals(pos.getIndex(), expected.getId().length()); assertEquals(pos.getErrorIndex(), -1); - assertEquals(parsed.query(TemporalQuery.chronology()), expected); + assertEquals(parsed.query(TemporalQueries.chronology()), expected); } //----------------------------------------------------------------------- diff --git a/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java b/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java index d431fa4ac..e370521b7 100644 --- a/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java +++ b/test/java/time/tck/java/time/format/TCKDateTimeFormatters.java @@ -94,6 +94,7 @@ import java.time.format.TextStyle; import java.time.temporal.IsoFields; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalQuery; import java.util.HashMap; import java.util.Iterator; @@ -1405,8 +1406,8 @@ public class TCKDateTimeFormatters { assertEquals(parsed.isSupported(field), true); parsed.getLong(field); } - assertEquals(parsed.query(TemporalQuery.chronology()), expected.chrono); - assertEquals(parsed.query(TemporalQuery.zoneId()), expected.zone); + assertEquals(parsed.query(TemporalQueries.chronology()), expected.chrono); + assertEquals(parsed.query(TemporalQueries.zoneId()), expected.zone); } //------------------------------------------------------------------------- @@ -1471,7 +1472,7 @@ public class TCKDateTimeFormatters { @SuppressWarnings("unchecked") @Override public R query(TemporalQuery query) { - if (query == TemporalQuery.zoneId()) { + if (query == TemporalQueries.zoneId()) { return (R) zoneId; } return TemporalAccessor.super.query(query); diff --git a/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java b/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java index b99d9bb47..2efd8cd46 100644 --- a/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java +++ b/test/java/time/tck/java/time/format/TCKDateTimeParseResolver.java @@ -113,7 +113,7 @@ import java.time.temporal.IsoFields; import java.time.temporal.Temporal; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalUnit; import java.time.temporal.ValueRange; import java.util.Map; @@ -147,8 +147,8 @@ public class TCKDateTimeParseResolver { DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), null); assertEquals(accessor.isSupported(field1), true); assertEquals(accessor.getLong(field1), value1); } @@ -186,8 +186,8 @@ public class TCKDateTimeParseResolver { .appendValue(field2).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), null); assertEquals(accessor.isSupported(field1), true); assertEquals(accessor.isSupported(field2), true); assertEquals(accessor.getLong(field1), value1); @@ -218,8 +218,8 @@ public class TCKDateTimeParseResolver { .appendValue(field3).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), null); assertEquals(accessor.isSupported(field1), true); assertEquals(accessor.isSupported(field2), true); assertEquals(accessor.isSupported(field3), true); @@ -252,8 +252,8 @@ public class TCKDateTimeParseResolver { DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), null); if (expectedField1 != null) { assertEquals(accessor.isSupported(expectedField1), true); assertEquals(accessor.getLong(expectedField1), expectedValue1.longValue()); @@ -278,8 +278,8 @@ public class TCKDateTimeParseResolver { DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQueries.localTime()), null); } //----------------------------------------------------------------------- @@ -303,8 +303,8 @@ public class TCKDateTimeParseResolver { DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), expectedTime); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), expectedTime); } //----------------------------------------------------------------------- @@ -334,8 +334,8 @@ public class TCKDateTimeParseResolver { .appendValue(field2).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), null); if (expectedField1 != null) { assertEquals(accessor.isSupported(expectedField1), true); assertEquals(accessor.getLong(expectedField1), expectedValue1.longValue()); @@ -382,8 +382,8 @@ public class TCKDateTimeParseResolver { .appendValue(field2).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQueries.localTime()), null); } //----------------------------------------------------------------------- @@ -469,8 +469,8 @@ public class TCKDateTimeParseResolver { .appendValue(field2).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), expectedTime); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), expectedTime); } //----------------------------------------------------------------------- @@ -502,8 +502,8 @@ public class TCKDateTimeParseResolver { .appendValue(field3).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQueries.localTime()), null); } //----------------------------------------------------------------------- @@ -535,8 +535,8 @@ public class TCKDateTimeParseResolver { .appendValue(field4).toFormatter(); TemporalAccessor accessor = f.parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), expectedDate); + assertEquals(accessor.query(TemporalQueries.localTime()), null); } //----------------------------------------------------------------------- @@ -603,8 +603,8 @@ public class TCKDateTimeParseResolver { for (ResolverStyle s : styles) { if (expectedTime != null) { TemporalAccessor accessor = f.withResolverStyle(s).parse(""); - assertEquals(accessor.query(TemporalQuery.localDate()), null, "ResolverStyle: " + s); - assertEquals(accessor.query(TemporalQuery.localTime()), expectedTime, "ResolverStyle: " + s); + assertEquals(accessor.query(TemporalQueries.localDate()), null, "ResolverStyle: " + s); + assertEquals(accessor.query(TemporalQueries.localTime()), expectedTime, "ResolverStyle: " + s); assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), excessPeriod, "ResolverStyle: " + s); } else { try { @@ -629,8 +629,8 @@ public class TCKDateTimeParseResolver { for (ResolverStyle s : styles) { if (expectedTime != null) { TemporalAccessor accessor = f.withResolverStyle(s).parse(""); - assertEquals(accessor.query(TemporalQuery.localDate()), null, "ResolverStyle: " + s); - assertEquals(accessor.query(TemporalQuery.localTime()), expectedTime.minusNanos(nano), "ResolverStyle: " + s); + assertEquals(accessor.query(TemporalQueries.localDate()), null, "ResolverStyle: " + s); + assertEquals(accessor.query(TemporalQueries.localTime()), expectedTime.minusNanos(nano), "ResolverStyle: " + s); assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), excessPeriod, "ResolverStyle: " + s); } else { try { @@ -658,8 +658,8 @@ public class TCKDateTimeParseResolver { LocalDate expectedDate = LocalDate.of(2012, 6, 30).plus(excessPeriod); for (ResolverStyle s : styles) { TemporalAccessor accessor = f.withResolverStyle(s).parse(""); - assertEquals(accessor.query(TemporalQuery.localDate()), expectedDate, "ResolverStyle: " + s); - assertEquals(accessor.query(TemporalQuery.localTime()), expectedTime, "ResolverStyle: " + s); + assertEquals(accessor.query(TemporalQueries.localDate()), expectedDate, "ResolverStyle: " + s); + assertEquals(accessor.query(TemporalQueries.localTime()), expectedTime, "ResolverStyle: " + s); assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), Period.ZERO, "ResolverStyle: " + s); } } @@ -696,8 +696,8 @@ public class TCKDateTimeParseResolver { if (expectedSecond != null) { TemporalAccessor accessor = f.withResolverStyle(style).parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), LocalTime.ofSecondOfDay(expectedSecond)); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.ofSecondOfDay(expectedSecond)); assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), Period.ofDays(expectedDays)); } else { try { @@ -740,8 +740,8 @@ public class TCKDateTimeParseResolver { if (expectedMinute != null) { TemporalAccessor accessor = f.withResolverStyle(style).parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), LocalTime.ofSecondOfDay(expectedMinute * 60)); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.ofSecondOfDay(expectedMinute * 60)); assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), Period.ofDays(expectedDays)); } else { try { @@ -784,8 +784,8 @@ public class TCKDateTimeParseResolver { if (expectedHour != null) { TemporalAccessor accessor = f.withResolverStyle(style).parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), LocalTime.of(expectedHour, 0)); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(expectedHour, 0)); assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), Period.ofDays(expectedDays)); } else { try { @@ -828,8 +828,8 @@ public class TCKDateTimeParseResolver { if (expectedValue != null) { TemporalAccessor accessor = f.withResolverStyle(style).parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), null); assertEquals(accessor.isSupported(CLOCK_HOUR_OF_AMPM), false); assertEquals(accessor.isSupported(HOUR_OF_AMPM), true); assertEquals(accessor.getLong(HOUR_OF_AMPM), expectedValue.longValue()); @@ -871,8 +871,8 @@ public class TCKDateTimeParseResolver { if (expectedValue != null) { TemporalAccessor accessor = f.withResolverStyle(style).parse(str); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), null); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), null); assertEquals(accessor.isSupported(AMPM_OF_DAY), true); assertEquals(accessor.getLong(AMPM_OF_DAY), expectedValue.longValue()); } else { @@ -933,8 +933,8 @@ public class TCKDateTimeParseResolver { }; DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter(); TemporalAccessor accessor = f.parse("1234567890"); - assertEquals(accessor.query(TemporalQuery.localDate()), null); - assertEquals(accessor.query(TemporalQuery.localTime()), LocalTime.of(0, 0, 1, 234_567_890)); + assertEquals(accessor.query(TemporalQueries.localDate()), null); + assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(0, 0, 1, 234_567_890)); } @Test @@ -985,8 +985,8 @@ public class TCKDateTimeParseResolver { }; DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field).toFormatter(); TemporalAccessor accessor = f.parse("1234567890"); - assertEquals(accessor.query(TemporalQuery.localDate()), LocalDate.of(2010, 6, 30)); - assertEquals(accessor.query(TemporalQuery.localTime()), LocalTime.of(12, 30)); + assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30)); + assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(12, 30)); } @Test(expectedExceptions = DateTimeParseException.class) diff --git a/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java b/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java index 075d862e7..27c057599 100644 --- a/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java +++ b/test/java/time/tck/java/time/format/TCKLocalizedPrinterParser.java @@ -123,7 +123,7 @@ public class TCKLocalizedPrinterParser { }; } - @SuppressWarnings("deprecated") + @SuppressWarnings("deprecation") @Test(dataProvider="date") public void test_date_print(LocalDate date, FormatStyle dateStyle, int dateStyleOld, Locale locale) { DateFormat old = DateFormat.getDateInstance(dateStyleOld, locale); @@ -135,7 +135,7 @@ public class TCKLocalizedPrinterParser { assertEquals(formatted, text); } - @SuppressWarnings("deprecated") + @SuppressWarnings("deprecation") @Test(dataProvider="date") public void test_date_parse(LocalDate date, FormatStyle dateStyle, int dateStyleOld, Locale locale) { DateFormat old = DateFormat.getDateInstance(dateStyleOld, locale); @@ -176,7 +176,7 @@ public class TCKLocalizedPrinterParser { }; } - @SuppressWarnings("deprecated") + @SuppressWarnings("deprecation") @Test(dataProvider="time") public void test_time_print(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) { DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale); @@ -188,7 +188,7 @@ public class TCKLocalizedPrinterParser { assertEquals(formatted, text); } - @SuppressWarnings("deprecated") + @SuppressWarnings("deprecation") @Test(dataProvider="time") public void test_time_parse(LocalTime time, FormatStyle timeStyle, int timeStyleOld, Locale locale) { DateFormat old = DateFormat.getTimeInstance(timeStyleOld, locale); diff --git a/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java b/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java index 414d390c6..122da8608 100644 --- a/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java +++ b/test/java/time/tck/java/time/format/TCKZoneIdPrinterParser.java @@ -71,7 +71,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalQueries; import java.util.Locale; import java.util.Objects; @@ -214,9 +214,9 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getErrorIndex(), expectedErrorIndex, "Incorrect error index parsing: " + text); assertEquals(pos.getIndex(), expectedIndex, "Incorrect index parsing: " + text); if (expected != null) { - assertEquals(parsed.query(TemporalQuery.zoneId()), expected, "Incorrect zoneId parsing: " + text); - assertEquals(parsed.query(TemporalQuery.offset()), null, "Incorrect offset parsing: " + text); - assertEquals(parsed.query(TemporalQuery.zone()), expected, "Incorrect zone parsing: " + text); + assertEquals(parsed.query(TemporalQueries.zoneId()), expected, "Incorrect zoneId parsing: " + text); + assertEquals(parsed.query(TemporalQueries.offset()), null, "Incorrect offset parsing: " + text); + assertEquals(parsed.query(TemporalQueries.zone()), expected, "Incorrect zone parsing: " + text); } else { assertEquals(parsed, null); } @@ -231,9 +231,9 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getErrorIndex(), expectedErrorIndex >= 0 ? expectedErrorIndex + 3 : expectedErrorIndex, "Incorrect error index parsing: " + prefixText); assertEquals(pos.getIndex(), expectedIndex + 3, "Incorrect index parsing: " + prefixText); if (expected != null) { - assertEquals(parsed.query(TemporalQuery.zoneId()), expected, "Incorrect zoneId parsing: " + prefixText); - assertEquals(parsed.query(TemporalQuery.offset()), null, "Incorrect offset parsing: " + prefixText); - assertEquals(parsed.query(TemporalQuery.zone()), expected, "Incorrect zone parsing: " + prefixText); + assertEquals(parsed.query(TemporalQueries.zoneId()), expected, "Incorrect zoneId parsing: " + prefixText); + assertEquals(parsed.query(TemporalQueries.offset()), null, "Incorrect offset parsing: " + prefixText); + assertEquals(parsed.query(TemporalQueries.zone()), expected, "Incorrect zone parsing: " + prefixText); } else { assertEquals(parsed, null); } @@ -247,9 +247,9 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getErrorIndex(), expectedErrorIndex, "Incorrect error index parsing: " + suffixText); assertEquals(pos.getIndex(), expectedIndex, "Incorrect index parsing: " + suffixText); if (expected != null) { - assertEquals(parsed.query(TemporalQuery.zoneId()), expected, "Incorrect zoneId parsing: " + suffixText); - assertEquals(parsed.query(TemporalQuery.offset()), null, "Incorrect offset parsing: " + suffixText); - assertEquals(parsed.query(TemporalQuery.zone()), expected, "Incorrect zone parsing: " + suffixText); + assertEquals(parsed.query(TemporalQueries.zoneId()), expected, "Incorrect zoneId parsing: " + suffixText); + assertEquals(parsed.query(TemporalQueries.offset()), null, "Incorrect offset parsing: " + suffixText); + assertEquals(parsed.query(TemporalQueries.zone()), expected, "Incorrect zone parsing: " + suffixText); } else { assertEquals(parsed, null); } @@ -269,9 +269,9 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getIndex(), expectedIndex, "Incorrect index parsing: " + lcText); assertEquals(pos.getErrorIndex(), expectedErrorIndex, "Incorrect error index parsing: " + lcText); if (expected != null) { - assertEquals(parsed.query(TemporalQuery.zoneId()), expected); - assertEquals(parsed.query(TemporalQuery.offset()), null); - assertEquals(parsed.query(TemporalQuery.zone()), expected); + assertEquals(parsed.query(TemporalQueries.zoneId()), expected); + assertEquals(parsed.query(TemporalQueries.offset()), null); + assertEquals(parsed.query(TemporalQueries.zone()), expected); } else { assertEquals(parsed, null); } @@ -286,10 +286,10 @@ public class TCKZoneIdPrinterParser { assertEquals(pos.getErrorIndex(), expectedErrorIndex, "Incorrect error index parsing: " + lcText); assertEquals(pos.getIndex(), expectedIndex, "Incorrect index parsing: " + lcText); if (expected != null) { - ZoneId zid = parsed.query(TemporalQuery.zoneId()); - assertEquals(parsed.query(TemporalQuery.zoneId()), expected, "Incorrect zoneId parsing: " + lcText); - assertEquals(parsed.query(TemporalQuery.offset()), null, "Incorrect offset parsing: " + lcText); - assertEquals(parsed.query(TemporalQuery.zone()), expected, "Incorrect zone parsing: " + lcText); + ZoneId zid = parsed.query(TemporalQueries.zoneId()); + assertEquals(parsed.query(TemporalQueries.zoneId()), expected, "Incorrect zoneId parsing: " + lcText); + assertEquals(parsed.query(TemporalQueries.offset()), null, "Incorrect offset parsing: " + lcText); + assertEquals(parsed.query(TemporalQueries.zone()), expected, "Incorrect zone parsing: " + lcText); } else { assertEquals(parsed, null); } diff --git a/test/java/time/tck/java/time/temporal/TCKTemporalAdjusters.java b/test/java/time/tck/java/time/temporal/TCKTemporalAdjusters.java index 66f129c09..b901125fc 100644 --- a/test/java/time/tck/java/time/temporal/TCKTemporalAdjusters.java +++ b/test/java/time/tck/java/time/temporal/TCKTemporalAdjusters.java @@ -73,12 +73,13 @@ import java.time.DayOfWeek; import java.time.LocalDate; import java.time.Month; import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAdjusters; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** - * Test TemporalAdjuster. + * Test TemporalAdjusters. */ @Test public class TCKTemporalAdjusters { @@ -88,13 +89,13 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_ofDateAdjuster() { - TemporalAdjuster test = TemporalAdjuster.ofDateAdjuster(date -> date.plusDays(2)); + TemporalAdjuster test = TemporalAdjusters.ofDateAdjuster(date -> date.plusDays(2)); assertEquals(LocalDate.of(2012, 6, 30).with(test), LocalDate.of(2012, 7, 2)); } @Test(expectedExceptions = NullPointerException.class) public void factory_ofDateAdjuster_null() { - TemporalAdjuster.ofDateAdjuster(null); + TemporalAdjusters.ofDateAdjuster(null); } @@ -103,7 +104,7 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_firstDayOfMonth() { - assertNotNull(TemporalAdjuster.firstDayOfMonth()); + assertNotNull(TemporalAdjusters.firstDayOfMonth()); } @Test @@ -111,7 +112,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), 1); @@ -124,7 +125,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), 1); @@ -137,7 +138,7 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_lastDayOfMonth() { - assertNotNull(TemporalAdjuster.lastDayOfMonth()); + assertNotNull(TemporalAdjusters.lastDayOfMonth()); } @Test @@ -145,7 +146,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), month.length(false)); @@ -158,7 +159,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfMonth().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), month); assertEquals(test.getDayOfMonth(), month.length(true)); @@ -171,7 +172,7 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_firstDayOfNextMonth() { - assertNotNull(TemporalAdjuster.firstDayOfNextMonth()); + assertNotNull(TemporalAdjusters.firstDayOfNextMonth()); } @Test @@ -179,7 +180,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfNextMonth().adjustInto(date); assertEquals(test.getYear(), month == DECEMBER ? 2008 : 2007); assertEquals(test.getMonth(), month.plus(1)); assertEquals(test.getDayOfMonth(), 1); @@ -192,7 +193,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextMonth().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfNextMonth().adjustInto(date); assertEquals(test.getYear(), month == DECEMBER ? 2009 : 2008); assertEquals(test.getMonth(), month.plus(1)); assertEquals(test.getDayOfMonth(), 1); @@ -205,7 +206,7 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_firstDayOfYear() { - assertNotNull(TemporalAdjuster.firstDayOfYear()); + assertNotNull(TemporalAdjusters.firstDayOfYear()); } @Test @@ -213,7 +214,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), Month.JANUARY); assertEquals(test.getDayOfMonth(), 1); @@ -226,7 +227,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), Month.JANUARY); assertEquals(test.getDayOfMonth(), 1); @@ -239,7 +240,7 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_lastDayOfYear() { - assertNotNull(TemporalAdjuster.lastDayOfYear()); + assertNotNull(TemporalAdjusters.lastDayOfYear()); } @Test @@ -247,7 +248,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2007); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); @@ -260,7 +261,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.lastDayOfYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.lastDayOfYear().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), Month.DECEMBER); assertEquals(test.getDayOfMonth(), 31); @@ -273,7 +274,7 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_firstDayOfNextYear() { - assertNotNull(TemporalAdjuster.firstDayOfNextYear()); + assertNotNull(TemporalAdjusters.firstDayOfNextYear()); } @Test @@ -281,7 +282,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(false); i++) { LocalDate date = date(2007, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfNextYear().adjustInto(date); assertEquals(test.getYear(), 2008); assertEquals(test.getMonth(), JANUARY); assertEquals(test.getDayOfMonth(), 1); @@ -294,7 +295,7 @@ public class TCKTemporalAdjusters { for (Month month : Month.values()) { for (int i = 1; i <= month.length(true); i++) { LocalDate date = date(2008, month, i); - LocalDate test = (LocalDate) TemporalAdjuster.firstDayOfNextYear().adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.firstDayOfNextYear().adjustInto(date); assertEquals(test.getYear(), 2009); assertEquals(test.getMonth(), JANUARY); assertEquals(test.getDayOfMonth(), 1); @@ -307,12 +308,12 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_dayOfWeekInMonth() { - assertNotNull(TemporalAdjuster.dayOfWeekInMonth(1, MONDAY)); + assertNotNull(TemporalAdjusters.dayOfWeekInMonth(1, MONDAY)); } @Test(expectedExceptions=NullPointerException.class) public void factory_dayOfWeekInMonth_nullDayOfWeek() { - TemporalAdjuster.dayOfWeekInMonth(1, null); + TemporalAdjusters.dayOfWeekInMonth(1, null); } @DataProvider(name = "dayOfWeekInMonth_positive") @@ -338,7 +339,7 @@ public class TCKTemporalAdjusters { for (int ordinal = 1; ordinal <= 5; ordinal++) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) TemporalAdjuster.dayOfWeekInMonth(ordinal, dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.dayOfWeekInMonth(ordinal, dow).adjustInto(date); assertEquals(test, expected.plusWeeks(ordinal - 1)); } } @@ -366,7 +367,7 @@ public class TCKTemporalAdjusters { public void test_dayOfWeekInMonth_zero(int year, int month, DayOfWeek dow, LocalDate expected) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) TemporalAdjuster.dayOfWeekInMonth(0, dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.dayOfWeekInMonth(0, dow).adjustInto(date); assertEquals(test, expected); } } @@ -394,7 +395,7 @@ public class TCKTemporalAdjusters { for (int ordinal = 0; ordinal < 5; ordinal++) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) TemporalAdjuster.dayOfWeekInMonth(-1 - ordinal, dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.dayOfWeekInMonth(-1 - ordinal, dow).adjustInto(date); assertEquals(test, expected.minusWeeks(ordinal)); } } @@ -405,19 +406,19 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_firstInMonth() { - assertNotNull(TemporalAdjuster.firstInMonth(MONDAY)); + assertNotNull(TemporalAdjusters.firstInMonth(MONDAY)); } @Test(expectedExceptions=NullPointerException.class) public void factory_firstInMonth_nullDayOfWeek() { - TemporalAdjuster.firstInMonth(null); + TemporalAdjusters.firstInMonth(null); } @Test(dataProvider = "dayOfWeekInMonth_positive") public void test_firstInMonth(int year, int month, DayOfWeek dow, LocalDate expected) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) TemporalAdjuster.firstInMonth(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.firstInMonth(dow).adjustInto(date); assertEquals(test, expected, "day-of-month=" + day); } } @@ -427,19 +428,19 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_lastInMonth() { - assertNotNull(TemporalAdjuster.lastInMonth(MONDAY)); + assertNotNull(TemporalAdjusters.lastInMonth(MONDAY)); } @Test(expectedExceptions=NullPointerException.class) public void factory_lastInMonth_nullDayOfWeek() { - TemporalAdjuster.lastInMonth(null); + TemporalAdjusters.lastInMonth(null); } @Test(dataProvider = "dayOfWeekInMonth_negative") public void test_lastInMonth(int year, int month, DayOfWeek dow, LocalDate expected) { for (int day = 1; day <= Month.of(month).length(false); day++) { LocalDate date = date(year, month, day); - LocalDate test = (LocalDate) TemporalAdjuster.lastInMonth(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.lastInMonth(dow).adjustInto(date); assertEquals(test, expected, "day-of-month=" + day); } } @@ -449,12 +450,12 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_next() { - assertNotNull(TemporalAdjuster.next(MONDAY)); + assertNotNull(TemporalAdjusters.next(MONDAY)); } @Test(expectedExceptions = NullPointerException.class) public void factory_next_nullDayOfWeek() { - TemporalAdjuster.next(null); + TemporalAdjusters.next(null); } @Test @@ -464,7 +465,7 @@ public class TCKTemporalAdjusters { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) TemporalAdjuster.next(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.next(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow, date + " " + test); @@ -488,12 +489,12 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_nextOrCurrent() { - assertNotNull(TemporalAdjuster.nextOrSame(MONDAY)); + assertNotNull(TemporalAdjusters.nextOrSame(MONDAY)); } @Test(expectedExceptions = NullPointerException.class) public void factory_nextOrCurrent_nullDayOfWeek() { - TemporalAdjuster.nextOrSame(null); + TemporalAdjusters.nextOrSame(null); } @Test @@ -503,7 +504,7 @@ public class TCKTemporalAdjusters { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) TemporalAdjuster.nextOrSame(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.nextOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); @@ -529,12 +530,12 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_previous() { - assertNotNull(TemporalAdjuster.previous(MONDAY)); + assertNotNull(TemporalAdjusters.previous(MONDAY)); } @Test(expectedExceptions = NullPointerException.class) public void factory_previous_nullDayOfWeek() { - TemporalAdjuster.previous(null); + TemporalAdjusters.previous(null); } @Test @@ -544,7 +545,7 @@ public class TCKTemporalAdjusters { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) TemporalAdjuster.previous(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.previous(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow, date + " " + test); @@ -568,12 +569,12 @@ public class TCKTemporalAdjusters { //----------------------------------------------------------------------- @Test public void factory_previousOrCurrent() { - assertNotNull(TemporalAdjuster.previousOrSame(MONDAY)); + assertNotNull(TemporalAdjusters.previousOrSame(MONDAY)); } @Test(expectedExceptions = NullPointerException.class) public void factory_previousOrCurrent_nullDayOfWeek() { - TemporalAdjuster.previousOrSame(null); + TemporalAdjusters.previousOrSame(null); } @Test @@ -583,7 +584,7 @@ public class TCKTemporalAdjusters { LocalDate date = date(2007, month, i); for (DayOfWeek dow : DayOfWeek.values()) { - LocalDate test = (LocalDate) TemporalAdjuster.previousOrSame(dow).adjustInto(date); + LocalDate test = (LocalDate) TemporalAdjusters.previousOrSame(dow).adjustInto(date); assertSame(test.getDayOfWeek(), dow); diff --git a/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java b/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java index 05a6d4b51..9fbe6d1c0 100644 --- a/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java +++ b/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java @@ -60,7 +60,7 @@ import java.time.format.FormatStyle; import java.time.temporal.ChronoField; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalAdjuster; +import java.time.temporal.TemporalAdjusters; import java.time.temporal.ValueRange; import java.time.temporal.WeekFields; import java.util.Locale; @@ -357,12 +357,12 @@ public class TestUmmAlQuraChronology { @Test public void test_temporalDayAdjustments() { HijrahDate date = HijrahDate.of(1554, 7, 21); - assertEquals(date.with(TemporalAdjuster.firstDayOfMonth()), HijrahDate.of(1554, 7, 1)); - assertEquals(date.with(TemporalAdjuster.lastDayOfMonth()), HijrahDate.of(1554, 7, 29)); - assertEquals(date.with(TemporalAdjuster.firstDayOfNextMonth()), HijrahDate.of(1554, 8, 1)); - assertEquals(date.with(TemporalAdjuster.firstDayOfNextYear()), HijrahDate.of(1555, 1, 1)); - assertEquals(date.with(TemporalAdjuster.firstDayOfYear()), HijrahDate.of(1554, 1, 1)); - assertEquals(date.with(TemporalAdjuster.lastDayOfYear()), HijrahDate.of(1554, 12, 30)); + assertEquals(date.with(TemporalAdjusters.firstDayOfMonth()), HijrahDate.of(1554, 7, 1)); + assertEquals(date.with(TemporalAdjusters.lastDayOfMonth()), HijrahDate.of(1554, 7, 29)); + assertEquals(date.with(TemporalAdjusters.firstDayOfNextMonth()), HijrahDate.of(1554, 8, 1)); + assertEquals(date.with(TemporalAdjusters.firstDayOfNextYear()), HijrahDate.of(1555, 1, 1)); + assertEquals(date.with(TemporalAdjusters.firstDayOfYear()), HijrahDate.of(1554, 1, 1)); + assertEquals(date.with(TemporalAdjusters.lastDayOfYear()), HijrahDate.of(1554, 12, 30)); } // Data provider for string representation of the date instances @@ -412,7 +412,7 @@ public class TestUmmAlQuraChronology { @Test(dataProvider="monthDays") public void test_lastDayOfMonth(int year, int month, int numDays) { HijrahDate hDate = HijrahChronology.INSTANCE.date(year, month, 1); - hDate = hDate.with(TemporalAdjuster.lastDayOfMonth()); + hDate = hDate.with(TemporalAdjusters.lastDayOfMonth()); assertEquals(hDate.get(ChronoField.DAY_OF_MONTH), numDays); } diff --git a/test/java/time/test/java/time/format/TestCharLiteralParser.java b/test/java/time/test/java/time/format/TestCharLiteralParser.java index 92cd6f885..696aab0f5 100644 --- a/test/java/time/test/java/time/format/TestCharLiteralParser.java +++ b/test/java/time/test/java/time/format/TestCharLiteralParser.java @@ -66,7 +66,7 @@ import static org.testng.Assert.fail; import java.text.ParsePosition; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalQueries; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -111,8 +111,8 @@ public class TestCharLiteralParser extends AbstractTestPrinterParser { } else { assertEquals(ppos.getIndex(), expectedPos); assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(TemporalQuery.chronology()), null); - assertEquals(parsed.query(TemporalQuery.zoneId()), null); + assertEquals(parsed.query(TemporalQueries.chronology()), null); + assertEquals(parsed.query(TemporalQueries.zoneId()), null); } } diff --git a/test/java/time/test/java/time/format/TestNonIsoFormatter.java b/test/java/time/test/java/time/format/TestNonIsoFormatter.java index 7246a82af..6747cdc93 100644 --- a/test/java/time/test/java/time/format/TestNonIsoFormatter.java +++ b/test/java/time/test/java/time/format/TestNonIsoFormatter.java @@ -39,7 +39,7 @@ import java.time.format.DateTimeParseException; import java.time.format.FormatStyle; import java.time.format.TextStyle; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalQueries; import java.util.Locale; import org.testng.annotations.BeforeMethod; @@ -163,7 +163,7 @@ public class TestNonIsoFormatter { String text = dtf.format(chrono.dateNow()); assertEquals(text, expected); TemporalAccessor ta = dtf.parse(text); - Chronology cal = ta.query(TemporalQuery.chronology()); + Chronology cal = ta.query(TemporalQueries.chronology()); assertEquals(cal, chrono); } } diff --git a/test/java/time/test/java/time/format/TestNumberParser.java b/test/java/time/test/java/time/format/TestNumberParser.java index 3e6575821..f3ac13b79 100644 --- a/test/java/time/test/java/time/format/TestNumberParser.java +++ b/test/java/time/test/java/time/format/TestNumberParser.java @@ -72,7 +72,7 @@ import java.time.format.DateTimeFormatter; import java.time.format.SignStyle; import java.time.temporal.TemporalAccessor; import java.time.temporal.TemporalField; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalQueries; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -178,8 +178,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { assertTrue(subsequentWidth >= 0); assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); assertEquals(parsed.getLong(DAY_OF_MONTH), expectedValue); - assertEquals(parsed.query(TemporalQuery.chronology()), null); - assertEquals(parsed.query(TemporalQuery.zoneId()), null); + assertEquals(parsed.query(TemporalQueries.chronology()), null); + assertEquals(parsed.query(TemporalQueries.zoneId()), null); } } @@ -198,8 +198,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { assertTrue(subsequentWidth >= 0); assertEquals(ppos.getIndex(), expectedPos + subsequentWidth); assertEquals(parsed.getLong(DAY_OF_WEEK), expectedValue); - assertEquals(parsed.query(TemporalQuery.chronology()), null); - assertEquals(parsed.query(TemporalQuery.zoneId()), null); + assertEquals(parsed.query(TemporalQueries.chronology()), null); + assertEquals(parsed.query(TemporalQueries.zoneId()), null); } } @@ -313,8 +313,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { } else { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(TemporalQuery.chronology()), null); - assertEquals(parsed.query(TemporalQuery.zoneId()), null); + assertEquals(parsed.query(TemporalQueries.chronology()), null); + assertEquals(parsed.query(TemporalQueries.zoneId()), null); } } @@ -423,8 +423,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { } else { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(TemporalQuery.chronology()), null); - assertEquals(parsed.query(TemporalQuery.zoneId()), null); + assertEquals(parsed.query(TemporalQueries.chronology()), null); + assertEquals(parsed.query(TemporalQueries.zoneId()), null); } } @@ -514,8 +514,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { } else { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(DAY_OF_MONTH), (long)parseVal); - assertEquals(parsed.query(TemporalQuery.chronology()), null); - assertEquals(parsed.query(TemporalQuery.zoneId()), null); + assertEquals(parsed.query(TemporalQueries.chronology()), null); + assertEquals(parsed.query(TemporalQueries.zoneId()), null); } } @@ -552,8 +552,8 @@ public class TestNumberParser extends AbstractTestPrinterParser { assertEquals(pos.getIndex(), parseLen); assertEquals(parsed.getLong(MONTH_OF_YEAR), (long) parseMonth); assertEquals(parsed.getLong(DAY_OF_MONTH), (long) parsedDay); - assertEquals(parsed.query(TemporalQuery.chronology()), null); - assertEquals(parsed.query(TemporalQuery.zoneId()), null); + assertEquals(parsed.query(TemporalQueries.chronology()), null); + assertEquals(parsed.query(TemporalQueries.zoneId()), null); } } diff --git a/test/java/time/test/java/time/format/TestStringLiteralParser.java b/test/java/time/test/java/time/format/TestStringLiteralParser.java index 8b6244178..f8f5147f9 100644 --- a/test/java/time/test/java/time/format/TestStringLiteralParser.java +++ b/test/java/time/test/java/time/format/TestStringLiteralParser.java @@ -66,7 +66,7 @@ import static org.testng.Assert.fail; import java.text.ParsePosition; import java.time.temporal.TemporalAccessor; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalQueries; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -114,8 +114,8 @@ public class TestStringLiteralParser extends AbstractTestPrinterParser { } else { assertEquals(ppos.getIndex(), expectedPos); assertEquals(parsed.isSupported(YEAR), false); - assertEquals(parsed.query(TemporalQuery.chronology()), null); - assertEquals(parsed.query(TemporalQuery.zoneId()), null); + assertEquals(parsed.query(TemporalQueries.chronology()), null); + assertEquals(parsed.query(TemporalQueries.zoneId()), null); } } diff --git a/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java b/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java index 7ab8804a9..6e3723561 100644 --- a/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java +++ b/test/java/time/test/java/time/format/TestZoneTextPrinterParser.java @@ -33,7 +33,7 @@ import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.time.format.TextStyle; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalQueries; import java.time.zone.ZoneRulesProvider; import java.util.Arrays; import java.util.Date; @@ -150,7 +150,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { .toFormatter(locale) .withDecimalStyle(DecimalStyle.of(locale)); - String ret = fmt.parse(text, TemporalQuery.zone()).getId(); + String ret = fmt.parse(text, TemporalQueries.zone()).getId(); System.out.printf("[%-5s %s] %24s -> %s(%s)%n", locale.toString(), @@ -186,7 +186,7 @@ public class TestZoneTextPrinterParser extends AbstractTestPrinterParser { if (ci) { text = text.toUpperCase(); } - String ret = fmt.parse(text, TemporalQuery.zone()).getId(); + String ret = fmt.parse(text, TemporalQueries.zone()).getId(); // TBD: need an excluding list // assertEquals(...); if (ret.equals(expected) || diff --git a/test/java/time/test/java/util/TestFormatter.java b/test/java/time/test/java/util/TestFormatter.java index 4c3ac4b60..ac183ba66 100644 --- a/test/java/time/test/java/util/TestFormatter.java +++ b/test/java/time/test/java/util/TestFormatter.java @@ -36,7 +36,7 @@ import java.time.chrono.ChronoZonedDateTime; import java.time.chrono.Chronology; import java.time.temporal.ChronoField; -import java.time.temporal.TemporalQuery; +import java.time.temporal.TemporalQueries; import java.time.temporal.TemporalAccessor; import java.util.*; @@ -134,7 +134,7 @@ public class TestFormatter { Class c = o.getClass(); String clname = c.getName().substring(c.getPackage().getName().length() + 1); if (o instanceof TemporalAccessor) { - Chronology chrono = ((TemporalAccessor)o).query(TemporalQuery.chronology()); + Chronology chrono = ((TemporalAccessor)o).query(TemporalQueries.chronology()); if (chrono != null) { clname = clname + "(" + chrono.getId() + ")"; } -- cgit v1.2.3 From 84f61e4bc1fd665fd80fb635957425e845485914 Mon Sep 17 00:00:00 2001 From: chegar Date: Tue, 15 Oct 2013 20:46:47 +0100 Subject: 8026513: ProblemList.txt Updates (10/2013) Reviewed-by: alanb --- test/ProblemList.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test') diff --git a/test/ProblemList.txt b/test/ProblemList.txt index 441fe6732..cf4d9b8e5 100644 --- a/test/ProblemList.txt +++ b/test/ProblemList.txt @@ -138,6 +138,9 @@ java/lang/ThreadLocal/ThreadLocalSupplierTest.java generic-all java/lang/instrument/RetransformBigClass.sh generic-all java/lang/instrument/RedefineBigClass.sh generic-all +# 8026502 +java/lang/invoke/MethodHandleConstants.java generic-all + ############################################################################ # jdk_management -- cgit v1.2.3 From 1c1341510ef80c16ebc224eab87efe303f259f72 Mon Sep 17 00:00:00 2001 From: dholmes Date: Tue, 15 Oct 2013 20:54:00 -0400 Subject: 8026378: TEST_BUG: Clean up TEST.groups Reviewed-by: mduigou, mchung, alanb --- test/TEST.groups | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/TEST.groups b/test/TEST.groups index aa305fd72..c680117cc 100644 --- a/test/TEST.groups +++ b/test/TEST.groups @@ -86,7 +86,6 @@ jdk_collections = \ # java.util.stream (JSR-335) jdk_stream = \ java/util/Optional \ - java/util/SummaryStatistics \ java/util/function \ java/util/stream @@ -126,7 +125,6 @@ jdk_security3 = \ javax/security \ com/sun/security \ com/sun/org/apache/xml/internal/security \ - com/oracle/security \ sun/security \ lib/security @@ -319,7 +317,6 @@ needs_jdk = \ java/net/URLClassLoader/closetest/GetResourceAsStream.java \ java/util/Collections/EmptyIterator.java \ java/util/concurrent/locks/Lock/TimedAcquireLeak.java \ - java/util/jar/Manifest/CreateManifest.java \ java/util/jar/JarInputStream/ExtraFileInMetaInf.java \ java/util/logging/AnonLoggerWeakRefLeak.sh \ java/util/logging/LoggerWeakRefLeak.sh \ @@ -358,6 +355,7 @@ needs_jre = \ java/net/URLConnection/HandleContentTypeWithAttrs.java \ java/security/Security/ClassLoaderDeadlock/ClassLoaderDeadlock.sh \ java/security/Security/ClassLoaderDeadlock/Deadlock.sh \ + java/util/jar/Manifest/CreateManifest.java \ java/util/logging/Listeners.java \ java/util/logging/ListenersWithSM.java \ java/util/logging/TestMainAppContext.java \ @@ -528,10 +526,10 @@ needs_compact2 = \ java/net/CookieHandler/EmptyCookieHeader.java \ java/net/HttpCookie/IllegalCookieNameTest.java \ java/net/HttpURLConnection/UnmodifiableMaps.java \ - java/net/HttpURLPermission/URLTest.java \ java/net/ResponseCache/Test.java \ java/net/URLClassLoader/ClassLoad.java \ java/net/URLClassLoader/closetest/CloseTest.java \ + java/net/URLPermission/URLTest.java \ java/nio/Buffer/Chars.java \ java/nio/file/Files/StreamTest.java \ java/security/BasicPermission/Wildcard.java \ @@ -539,7 +537,6 @@ needs_compact2 = \ java/util/Arrays/SetAllTest.java \ java/util/BitSet/BitSetStreamTest.java \ java/util/Collection/CollectionDefaults.java \ - java/util/Collection/ListDefaults.java \ java/util/Collections/CheckedIdentityMap.java \ java/util/Collections/CheckedMapBash.java \ java/util/Collections/CheckedSetBash.java \ @@ -551,6 +548,7 @@ needs_compact2 = \ java/util/Comparator/TypeTest.java \ java/util/Iterator/IteratorDefaults.java \ java/util/Iterator/PrimitiveIteratorDefaults.java \ + java/util/List/ListDefaults.java \ java/util/Map/BasicSerialization.java \ java/util/Map/Defaults.java \ java/util/Map/EntryComparators.java \ -- cgit v1.2.3 From f342b71ab93b3bf63851f9b56a140aee251533d4 Mon Sep 17 00:00:00 2001 From: igerasim Date: Tue, 15 Oct 2013 21:15:17 +0400 Subject: 8023431: Test java/util/zip/GZIP/GZIPInZip.java failed Summary: Properly close PipedStreams. Additional testing for malformed input Reviewed-by: darcy, sherman --- test/java/util/zip/GZIP/GZIPInZip.java | 51 +++++++++++++++++++++++----------- 1 file changed, 35 insertions(+), 16 deletions(-) (limited to 'test') diff --git a/test/java/util/zip/GZIP/GZIPInZip.java b/test/java/util/zip/GZIP/GZIPInZip.java index 558ad962e..fab869ae1 100644 --- a/test/java/util/zip/GZIP/GZIPInZip.java +++ b/test/java/util/zip/GZIP/GZIPInZip.java @@ -22,12 +22,15 @@ */ /* @test - * @bug 7021870 - * @summary Reading last gzip chain member must not close the input stream + * @bug 7021870 8023431 + * @summary Reading last gzip chain member must not close the input stream. + * Garbage following gzip entry must be ignored. */ -import java.io.*; -import java.util.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.PipedInputStream; +import java.io.PipedOutputStream; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import java.util.zip.ZipEntry; @@ -40,6 +43,15 @@ public class GZIPInZip { private static volatile Throwable trouble; public static void main(String[] args) throws Throwable { + doTest(false, false); + doTest(false, true); + doTest(true, false); + doTest(true, true); + } + + private static void doTest(final boolean appendGarbage, + final boolean limitGISBuff) + throws Throwable { final PipedOutputStream pos = new PipedOutputStream(); final PipedInputStream pis = new PipedInputStream(pos); @@ -47,17 +59,23 @@ public class GZIPInZip { Thread compressor = new Thread() { public void run() { final byte[] xbuf = { 'x' }; - try { - ZipOutputStream zos = new ZipOutputStream(pos); + try (ZipOutputStream zos = new ZipOutputStream(pos)) { zos.putNextEntry(new ZipEntry("a.gz")); - GZIPOutputStream gos1 = new GZIPOutputStream(zos); - gos1.write(xbuf); gos1.finish(); + try (GZIPOutputStream gos1 = new GZIPOutputStream(zos)) { + gos1.write(xbuf); + gos1.finish(); + } + if (appendGarbage) + zos.write(xbuf); + zos.closeEntry(); zos.putNextEntry(new ZipEntry("b.gz")); - GZIPOutputStream gos2 = new GZIPOutputStream(zos); - gos2.write(xbuf); gos2.finish(); + try (GZIPOutputStream gos2 = new GZIPOutputStream(zos)) { + gos2.write(xbuf); + gos2.finish(); + } zos.closeEntry(); } catch (Throwable t) { @@ -68,19 +86,20 @@ public class GZIPInZip { Thread uncompressor = new Thread() { public void run() { - try { - ZipInputStream zis = new ZipInputStream(pis); + try (ZipInputStream zis = new ZipInputStream(pis)) { zis.getNextEntry(); - InputStream gis = new GZIPInputStream(zis); - // try to read more than the entry has - gis.skip(2); + try (InputStream gis = limitGISBuff ? + new GZIPInputStream(zis, 4) : + new GZIPInputStream(zis)) { + // try to read more than the entry has + gis.skip(2); + } try { zis.getNextEntry(); } catch (IOException e) { throw new AssertionError("ZIP stream was prematurely closed"); } - } catch (Throwable t) { trouble = t; } -- cgit v1.2.3 From 5c0c57908ab6dcb8883dfd1669a77da3183dab35 Mon Sep 17 00:00:00 2001 From: robm Date: Wed, 16 Oct 2013 15:06:27 +0100 Subject: 8026245: InetAddress.getLocalHost crash if IPv6 disabled (macosx) Reviewed-by: chegar, alanb --- test/java/net/InetAddress/GetLocalHostWithSM.java | 6 ++++-- test/java/net/Socket/GetLocalAddress.java | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/java/net/InetAddress/GetLocalHostWithSM.java b/test/java/net/InetAddress/GetLocalHostWithSM.java index c8d06acb6..9701a7414 100644 --- a/test/java/net/InetAddress/GetLocalHostWithSM.java +++ b/test/java/net/InetAddress/GetLocalHostWithSM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -23,9 +23,11 @@ /** * @test - * @bug 4531817 + * @bug 4531817 8026245 * @summary Inet[46]Address.localHost need doPrivileged * @run main/othervm GetLocalHostWithSM + * @run main/othervm -Djava.net.preferIPv4Stack=true GetLocalHostWithSM + * @run main/othervm -Djava.net.preferIPv6Addresses=true GetLocalHostWithSM * files needed: GetLocalHostWithSM.java, MyPrincipal.java, and policy.file */ diff --git a/test/java/net/Socket/GetLocalAddress.java b/test/java/net/Socket/GetLocalAddress.java index 606ba644c..e9573d2ef 100644 --- a/test/java/net/Socket/GetLocalAddress.java +++ b/test/java/net/Socket/GetLocalAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -23,7 +23,10 @@ /* * @test - * @bug 4106601 + * @bug 4106601 8026245 + * @run main/othervm GetLocalAddress + * @run main/othervm -Djava.net.preferIPv4Stack=true GetLocalAddress + * @run main/othervm -Djava.net.preferIPv6Addresses=true GetLocalAddress * @summary Test the java.net.socket.GetLocalAddress method * */ -- cgit v1.2.3 From 9074642fc7ff3c7565465ea8e8848069e1a9caca Mon Sep 17 00:00:00 2001 From: dfuchs Date: Wed, 16 Oct 2013 17:19:09 +0200 Subject: 8011638: Remove deprecated methods in sun.util.logging.PlatformLogger Reviewed-by: psandoz, mchung, alanb, chegar --- test/sun/util/logging/PlatformLoggerTest.java | 91 ++++++++++++++++----------- 1 file changed, 55 insertions(+), 36 deletions(-) (limited to 'test') diff --git a/test/sun/util/logging/PlatformLoggerTest.java b/test/sun/util/logging/PlatformLoggerTest.java index ac399c097..3fdab49ad 100644 --- a/test/sun/util/logging/PlatformLoggerTest.java +++ b/test/sun/util/logging/PlatformLoggerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 6882376 6985460 8010309 + * @bug 6882376 6985460 8010309 8011638 * @summary Test if java.util.logging.Logger is created before and after * logging is enabled. Also validate some basic PlatformLogger * operations. othervm mode to make sure java.util.logging @@ -34,8 +34,10 @@ */ import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.logging.*; import sun.util.logging.PlatformLogger; +import sun.util.logging.LoggingSupport; import static sun.util.logging.PlatformLogger.Level.*; public class PlatformLoggerTest { @@ -104,17 +106,6 @@ public class PlatformLoggerTest { throw new RuntimeException("logger " + logger.getName() + ": " + level + (expected ? " not loggable" : " loggable")); } - - if (logger.isLoggable(level.intValue()) != expected) { - throw new RuntimeException("logger " + logger.getName() + ": " + level.intValue() + - (expected ? " not loggable" : " loggable")); - } - - int value = level.intValue() + 5; // custom level value - if (expected && !logger.isLoggable(value)) { - throw new RuntimeException("logger " + logger.getName() + ": " + value + - " not loggable"); - } } private static void checkLevel(PlatformLogger logger, PlatformLogger.Level level) { @@ -122,11 +113,6 @@ public class PlatformLoggerTest { throw new RuntimeException("Invalid level for logger " + logger.getName() + ": " + logger.level() + " != " + level); } - - if (logger.getLevel() != level.intValue()) { - throw new RuntimeException("Invalid level for logger " + - logger.getName() + ": " + logger.getLevel() + " != " + level.intValue()); - } } private static void checkLogger(String name, Level level) { @@ -177,6 +163,11 @@ public class PlatformLoggerTest { checkLoggerLevel(logger, Level.ALL); } } + + Logger javaLogger = Logger.getLogger("foo.bar.baz"); + for (Level level : levels) { + checkJavaLoggerLevel(javaLogger, level); + } } private static void checkLoggerLevel(PlatformLogger logger, Level level) { @@ -196,6 +187,50 @@ public class PlatformLoggerTest { } } + private static void checkJavaLoggerLevel(Logger logger, Level level) { + // This method exercise the mapping of java level to platform level + // when the java level is not one of the standard levels... + + System.out.println("Testing Java Level with: " + level.getName()); + + // create a brand new java logger + Logger javaLogger = (Logger) LoggingSupport.getLogger(logger.getName()+"."+level.getName()); + + // Set a non standard java.util.logging.Level on the java logger + // (except for OFF & ALL - which will remain unchanged) + int intValue = level.intValue(); + if (level != Level.ALL && level != Level.OFF) { + intValue -= 7; + } + javaLogger.setLevel(Level.parse(String.valueOf(intValue))); + + // check the level set in java.util.logging.Logger + Level effectiveLevel = javaLogger.getLevel(); + System.out.println("Effective Java Level used is: " + effectiveLevel); + + if (effectiveLevel.intValue() != intValue) { + throw new RuntimeException("Retrieved backing java.util.logging.Logger level.intValue() " + + effectiveLevel.intValue() + " is not the expected " + intValue); + } + if (intValue != level.intValue() && javaLogger.getLevel() == level) { + throw new RuntimeException("Retrieved backing java.util.logging.Logger level " + + effectiveLevel + " is " + level); + } + if (intValue == level.intValue() && javaLogger.getLevel() != level) { + throw new RuntimeException("Retrieved backing java.util.logging.Logger level " + + effectiveLevel + " is not " + level); + } + + // check the level set in the PlatformLogger + PlatformLogger plogger = PlatformLogger.getLogger(javaLogger.getName()); + PlatformLogger.Level expected = PlatformLogger.Level.valueOf(level.getName()); + if (plogger.level() != expected) { + throw new RuntimeException("Retrieved backing PlatformLogger level " + + plogger.level() + " is not the expected " + expected); + + } + } + private static void checkPlatformLoggerLevelMapping(Level level) { // map the given level to PlatformLogger.Level of the same name and value PlatformLogger.Level platformLevel = PlatformLogger.Level.valueOf(level.getName()); @@ -203,26 +238,10 @@ public class PlatformLoggerTest { throw new RuntimeException("Mismatched level: " + level + " PlatformLogger.Level" + platformLevel); } - - try { - // validate if there is a public static final field in PlatformLogger - Field constantField = PlatformLogger.class.getField(level.getName()); - int l = (int) constantField.get(null); - if (l != platformLevel.intValue()) { - throw new RuntimeException("static final " + level.getName() + " (" + - l + ") != " + platformLevel.intValue()); - } - } catch (Exception e) { - throw new RuntimeException("No public static PlatformLogger." + level.getName() + - " field", e); - } - if (!platformLevel.name().equals(level.getName())) + if (!platformLevel.name().equals(level.getName())) { throw new RuntimeException("The value of PlatformLogger." + level.getName() + ".name() is " + platformLevel.name() + " but expected " + level.getName()); - - if (platformLevel.intValue() != level.intValue()) - throw new RuntimeException("The value of PlatformLogger." + level.intValue() + ".intValue() is " - + platformLevel.intValue() + " but expected " + level.intValue()); + } } static Point[] getPoints() { -- cgit v1.2.3 From c155924dc0952d63fcefc530f0222c66889afc69 Mon Sep 17 00:00:00 2001 From: dfuchs Date: Wed, 16 Oct 2013 20:47:30 +0200 Subject: 8013839: Enhance Logger API for handling of resource bundles 4814565: (rb) add method to get basename from a ResourceBundle Summary: adds Logger.setResourceBundle(ResourceBundle) and ResourceBundle.getBaseBundleName() Reviewed-by: mchung, naoto --- .../getBaseBundleName/TestGetBaseBundleName.java | 144 ++++++++ .../getBaseBundleName/resources/ListBundle.java | 41 +++ .../getBaseBundleName/resources/ListBundle_fr.java | 41 +++ .../resources/PropertyBundle.properties | 24 ++ .../resources/PropertyBundle_fr.properties | 24 ++ .../Logger/logrb/TestLogrbResourceBundle.java | 381 ++++++++++++++++++++ .../logging/Logger/logrb/resources/ListBundle.java | 41 +++ .../Logger/logrb/resources/ListBundle_fr.java | 41 +++ .../logrb/resources/PropertyBundle.properties | 24 ++ .../logrb/resources/PropertyBundle_fr.properties | 24 ++ .../setResourceBundle/TestSetResourceBundle.java | 393 +++++++++++++++++++++ .../setResourceBundle/resources/ListBundle.java | 41 +++ .../setResourceBundle/resources/ListBundle_fr.java | 41 +++ .../resources/PropertyBundle.properties | 24 ++ .../resources/PropertyBundle_fr.properties | 24 ++ 15 files changed, 1308 insertions(+) create mode 100644 test/java/util/ResourceBundle/getBaseBundleName/TestGetBaseBundleName.java create mode 100644 test/java/util/ResourceBundle/getBaseBundleName/resources/ListBundle.java create mode 100644 test/java/util/ResourceBundle/getBaseBundleName/resources/ListBundle_fr.java create mode 100644 test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle.properties create mode 100644 test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle_fr.properties create mode 100644 test/java/util/logging/Logger/logrb/TestLogrbResourceBundle.java create mode 100644 test/java/util/logging/Logger/logrb/resources/ListBundle.java create mode 100644 test/java/util/logging/Logger/logrb/resources/ListBundle_fr.java create mode 100644 test/java/util/logging/Logger/logrb/resources/PropertyBundle.properties create mode 100644 test/java/util/logging/Logger/logrb/resources/PropertyBundle_fr.properties create mode 100644 test/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java create mode 100644 test/java/util/logging/Logger/setResourceBundle/resources/ListBundle.java create mode 100644 test/java/util/logging/Logger/setResourceBundle/resources/ListBundle_fr.java create mode 100644 test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle.properties create mode 100644 test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle_fr.properties (limited to 'test') diff --git a/test/java/util/ResourceBundle/getBaseBundleName/TestGetBaseBundleName.java b/test/java/util/ResourceBundle/getBaseBundleName/TestGetBaseBundleName.java new file mode 100644 index 000000000..aca4017c7 --- /dev/null +++ b/test/java/util/ResourceBundle/getBaseBundleName/TestGetBaseBundleName.java @@ -0,0 +1,144 @@ +/* + * 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. + */ +import java.util.Collections; +import java.util.Enumeration; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.PropertyResourceBundle; +import java.util.ResourceBundle; + +/** + * @test + * @bug 4814565 + * @summary tests ResourceBundle.getBaseBundleName(); + * @build TestGetBaseBundleName resources.ListBundle resources.ListBundle_fr + * @run main TestGetBaseBundleName + * @author danielfuchs + */ +public class TestGetBaseBundleName { + + final static String PROPERTY_BUNDLE_NAME = "resources/PropertyBundle"; + final static String LIST_BUNDLE_NAME = "resources.ListBundle"; + + public static String getBaseName(ResourceBundle bundle) { + return bundle == null ? null : bundle.getBaseBundleName(); + } + + public static void main(String... args) throws Exception { + + Locale defaultLocale = Locale.getDefault(); + System.out.println("Default locale is: " + defaultLocale); + for (String baseName : new String[] { + PROPERTY_BUNDLE_NAME, + LIST_BUNDLE_NAME + }) { + ResourceBundle bundle = ResourceBundle.getBundle(baseName); + System.out.println(getBaseName(bundle)); + if (!Locale.ROOT.equals(bundle.getLocale())) { + throw new RuntimeException("Unexpected locale: " + + bundle.getLocale()); + } + if (!baseName.equals(getBaseName(bundle))) { + throw new RuntimeException("Unexpected base name: " + + getBaseName(bundle)); + } + Locale.setDefault(Locale.FRENCH); + try { + ResourceBundle bundle_fr = ResourceBundle.getBundle(baseName); + if (!Locale.FRENCH.equals(bundle_fr.getLocale())) { + throw new RuntimeException("Unexpected locale: " + + bundle_fr.getLocale()); + } + if (!baseName.equals(getBaseName(bundle_fr))) { + throw new RuntimeException("Unexpected base name: " + + getBaseName(bundle_fr)); + } + } finally { + Locale.setDefault(defaultLocale); + } + } + + final ResourceBundle bundle = new ResourceBundle() { + @Override + protected Object handleGetObject(String key) { + if ("dummy".equals(key)) return "foo"; + throw new MissingResourceException("Missing key", + this.getClass().getName(), key); + } + @Override + public Enumeration getKeys() { + return Collections.enumeration(java.util.Arrays.asList( + new String[] {"dummy"})); + } + }; + + if (getBaseName(bundle) != null) { + throw new RuntimeException("Expected null baseName, got " + + getBaseName(bundle)); + } + + final ResourceBundle bundle2 = new ResourceBundle() { + @Override + protected Object handleGetObject(String key) { + if ("dummy".equals(key)) return "foo"; + throw new MissingResourceException("Missing key", + this.getClass().getName(), key); + } + @Override + public Enumeration getKeys() { + return Collections.enumeration(java.util.Arrays.asList( + new String[] {"dummy"})); + } + + @Override + public String getBaseBundleName() { + return this.getClass().getName(); + } + + + }; + + if (!bundle2.getClass().getName().equals(getBaseName(bundle2))) { + throw new RuntimeException("Expected " + + bundle2.getClass().getName() + ", got " + + getBaseName(bundle2)); + } + + ResourceBundle propertyBundle = new PropertyResourceBundle( + TestGetBaseBundleName.class.getResourceAsStream( + PROPERTY_BUNDLE_NAME+".properties")); + + if (getBaseName(propertyBundle) != null) { + throw new RuntimeException("Expected null baseName, got " + + getBaseName(propertyBundle)); + } + + ResourceBundle listBundle = new resources.ListBundle_fr(); + if (getBaseName(listBundle) != null) { + throw new RuntimeException("Expected null baseName, got " + + getBaseName(listBundle)); + } + + + } +} diff --git a/test/java/util/ResourceBundle/getBaseBundleName/resources/ListBundle.java b/test/java/util/ResourceBundle/getBaseBundleName/resources/ListBundle.java new file mode 100644 index 000000000..121db2914 --- /dev/null +++ b/test/java/util/ResourceBundle/getBaseBundleName/resources/ListBundle.java @@ -0,0 +1,41 @@ +/* + * 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. + */ +package resources; + +import java.util.ListResourceBundle; + +/** + * + * @author danielfuchs + */ +public class ListBundle extends ListResourceBundle { + + @Override + protected Object[][] getContents() { + return new Object[][] { + { "dummy", "foo" }, + }; + + } + +} diff --git a/test/java/util/ResourceBundle/getBaseBundleName/resources/ListBundle_fr.java b/test/java/util/ResourceBundle/getBaseBundleName/resources/ListBundle_fr.java new file mode 100644 index 000000000..b168bf7ab --- /dev/null +++ b/test/java/util/ResourceBundle/getBaseBundleName/resources/ListBundle_fr.java @@ -0,0 +1,41 @@ +/* + * 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. + */ +package resources; + +import java.util.ListResourceBundle; + +/** + * + * @author danielfuchs + */ +public class ListBundle_fr extends ListResourceBundle { + + @Override + protected Object[][] getContents() { + return new Object[][] { + { "dummy", "toto" }, + }; + + } + +} diff --git a/test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle.properties b/test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle.properties new file mode 100644 index 000000000..343c64825 --- /dev/null +++ b/test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle.properties @@ -0,0 +1,24 @@ +# +# Copyright (c) 20013, 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. +# +dummy=foo + diff --git a/test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle_fr.properties b/test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle_fr.properties new file mode 100644 index 000000000..312027104 --- /dev/null +++ b/test/java/util/ResourceBundle/getBaseBundleName/resources/PropertyBundle_fr.properties @@ -0,0 +1,24 @@ +# +# 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. +# +dummy=toto + diff --git a/test/java/util/logging/Logger/logrb/TestLogrbResourceBundle.java b/test/java/util/logging/Logger/logrb/TestLogrbResourceBundle.java new file mode 100644 index 000000000..f47219492 --- /dev/null +++ b/test/java/util/logging/Logger/logrb/TestLogrbResourceBundle.java @@ -0,0 +1,381 @@ +/* + * 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. + */ +import java.util.Arrays; +import java.util.Locale; +import java.util.Objects; +import java.util.ResourceBundle; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import resources.ListBundle; + +/** + * @test + * @bug 8013839 + * @summary tests Logger.logrb(..., ResourceBundle); + * @build TestLogrbResourceBundle resources.ListBundle resources.ListBundle_fr + * @run main TestLogrbResourceBundle + * @author danielfuchs + */ +public class TestLogrbResourceBundle { + + final static String LIST_BUNDLE_NAME = "resources.ListBundle"; + final static String PROPERTY_BUNDLE_NAME = "resources.PropertyBundle"; + + /** + * A dummy handler class that we can use to check the bundle/bundle name + * that was present in the last LogRecord instance published. + */ + static final class TestHandler extends Handler { + ResourceBundle lastBundle = null; + String lastBundleName = null; + Object[] lastParams = null; + Throwable lastThrown = null; + String lastMessage = null; + @Override + public void publish(LogRecord record) { + lastBundle = record.getResourceBundle(); + lastBundleName = record.getResourceBundleName(); + lastParams = record.getParameters(); + lastThrown = record.getThrown(); + lastMessage = record.getMessage(); + } + + @Override + public void flush() { + } + + @Override + public void close() throws SecurityException { + } + } + + /** + * We're going to do the same test with each of the different new logrb + * forms. + *
    + *
  • LOGRB_NO_ARGS: calling logrb with no message argument. + *
  • LOGRB_SINGLE_ARG: calling logrb with a single message argument. + *
  • LOGRB_ARG_ARRAY: calling logrb with an array of message arguments. + *
  • LOGRB_VARARGS: calling logrb with a variable list of message arguments. + *
  • LOGRB_THROWABLE: calling logrb with an exception. + *
+ */ + private static enum TestCase { + LOGRB_NO_ARGS, LOGRB_SINGLE_ARG, LOGRB_ARG_ARRAY, LOGRB_VARARGS, LOGRB_THROWABLE; + + public void logrb(Logger logger, ResourceBundle bundle) { + switch(this) { + case LOGRB_NO_ARGS: + logger.logrb(Level.CONFIG, + TestLogrbResourceBundle.class.getName(), + "main", bundle, "dummy"); + break; + case LOGRB_SINGLE_ARG: + logger.logrb(Level.CONFIG, + TestLogrbResourceBundle.class.getName(), + "main", bundle, "dummy", "bar"); + break; + case LOGRB_ARG_ARRAY: + logger.logrb(Level.CONFIG, + TestLogrbResourceBundle.class.getName(), + "main", bundle, "dummy", + new Object[] { "bar", "baz"} ); + break; + case LOGRB_VARARGS: + logger.logrb(Level.CONFIG, + TestLogrbResourceBundle.class.getName(), + "main", bundle, "dummy", + "bar", "baz" ); + break; + case LOGRB_THROWABLE: + logger.logrb(Level.CONFIG, + TestLogrbResourceBundle.class.getName(), + "main", bundle, "dummy", + new Exception("dummy exception") ); + break; + default: + } + } + + /** + * Checks that the last published logged record had the expected data. + * @param handler the TestHandler through which the record was published. + */ + public void checkLogged(TestHandler handler) { + checkLogged(handler.lastMessage, handler.lastParams, handler.lastThrown); + } + + private void checkLogged(String message, Object[] parameters, Throwable thrown) { + switch(this) { + case LOGRB_NO_ARGS: + if ("dummy".equals(message) && thrown == null + && (parameters == null || parameters.length == 0)) { + return; // OK: all was as expected. + } + break; + case LOGRB_SINGLE_ARG: + if ("dummy".equals(message) && thrown == null + && parameters != null + && parameters.length == 1 + && "bar".equals(parameters[0])) { + return; // OK: all was as expected. + } + break; + case LOGRB_VARARGS: + case LOGRB_ARG_ARRAY: + if ("dummy".equals(message) && thrown == null + && parameters != null + && parameters.length > 1 + && Arrays.deepEquals(new Object[] { "bar", "baz"}, + parameters)) { + return; // OK: all was as expected. + } + break; + case LOGRB_THROWABLE: + if ("dummy".equals(message) && thrown != null + && thrown.getClass() == Exception.class + && "dummy exception".equals(thrown.getMessage())) { + return; // OK: all was as expected. + } + break; + default: + } + + // We had some unexpected stuff: throw exception. + throw new RuntimeException(this + ": " + + "Unexpected content in last published log record: " + + "\n\tmessage=\"" + message + "\"" + + "\n\tparameters=" + Arrays.toString(parameters) + + "\n\tthrown=" + thrown); + } + } + + static String getBaseName(ResourceBundle bundle) { + return bundle == null ? null : bundle.getBaseBundleName(); + } + + public static void main(String... args) throws Exception { + + Locale defaultLocale = Locale.getDefault(); + + final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); + final ResourceBundle bundle_fr = + ResourceBundle.getBundle(LIST_BUNDLE_NAME, Locale.FRENCH); + final ResourceBundle propertyBundle = ResourceBundle.getBundle(PROPERTY_BUNDLE_NAME); + final ResourceBundle propertyBundle_fr = + ResourceBundle.getBundle(PROPERTY_BUNDLE_NAME, Locale.FRENCH); + Logger foobar = Logger.getLogger("foo.bar"); + final TestHandler handler = new TestHandler(); + foobar.addHandler(handler); + foobar.setLevel(Level.CONFIG); + + final ResourceBundle anonBundle = new ListBundle(); + try { + // First we're going to call logrb on a logger that + // has no bundle set... + + // For each possible logrb form... + for (TestCase test : TestCase.values()) { + // For various resource bundles + for (ResourceBundle b : new ResourceBundle[] { + anonBundle, bundle, bundle_fr, propertyBundle, + anonBundle, null, propertyBundle_fr, + }) { + // Prints the resource bundle base name (can be null, + // we don't enforce non-null names in logrb. + final String baseName = getBaseName(b); + System.out.println("Testing " + test + " with " + baseName); + + // log in the 'foobar' logger using bundle 'b' + test.logrb(foobar, b); + + // check that the correct bundle was set in the published + // LogRecord + if (handler.lastBundle != b) { + throw new RuntimeException("Unexpected bundle: " + + handler.lastBundle); + } + + // check that the correct bundle name was set in the published + // LogRecord + if (!Objects.equals(handler.lastBundleName, baseName)) { + throw new RuntimeException("Unexpected bundle name: " + + handler.lastBundleName); + } + + // check that calling foobar.logrb() had no side effect on + // the bundle used by foobar. foobar should still have no + // bundle set. + if (foobar.getResourceBundle() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundle()); + } + if (foobar.getResourceBundleName() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundleName()); + } + + // Test that the last published log record had all the + // data that this test case had logged (message, parameters, + // thrown... + test.checkLogged(handler); + } + } + + // No we're going to set a resource bundle on the foobar logger + // and do it all again... + + // For the same bundle in two different locales + for (ResourceBundle propBundle : new ResourceBundle[] { + propertyBundle, propertyBundle_fr, + }) { + + // set the bundle on foobar... + foobar.setResourceBundle(propBundle); + + // check the bundle was correctly set... + if (!propBundle.equals(foobar.getResourceBundle())) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundle()); + } + if (!Objects.equals(getBaseName(propBundle), foobar.getResourceBundleName())) { + throw new RuntimeException("Unexpected bundle name: " + + foobar.getResourceBundleName()); + } + + System.out.println("Configuring " + foobar.getName() + " with " + + propBundle); + + // for each possible logrb form... + for (TestCase test : TestCase.values()) { + + // for various resource bundles + for (ResourceBundle b : new ResourceBundle[] { + anonBundle, bundle, null, bundle_fr, propertyBundle, + anonBundle, propertyBundle_fr, + }) { + + final String baseName = getBaseName(b); + System.out.println("Testing " + test + " with " + baseName); + + // call foobar.logrb + test.logrb(foobar, b); + + // check which resource bundle was used (should be + // the one passed to logrb) + if (handler.lastBundle != b) { + throw new RuntimeException("Unexpected bundle: " + + handler.lastBundle); + } + if (!Objects.equals(handler.lastBundleName, baseName)) { + throw new RuntimeException("Unexpected bundle name: " + + handler.lastBundleName); + } + + // Verify there was no side effect on the bundle that + // had been previously set on the logger... + if (foobar.getResourceBundle() != propBundle) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundle()); + } + if (!Objects.equals(getBaseName(propBundle), + foobar.getResourceBundleName())) { + throw new RuntimeException("Unexpected bundle name: " + + foobar.getResourceBundleName()); + } + + // Checked that the published LogRecord had the + // expected content logged by this test case. + test.checkLogged(handler); + } + } + } + + // Now we're going to the same thing, but with a logger which + // has an inherited resource bundle. + Logger foobaz = Logger.getLogger("foo.bar.baz"); + + // check that foobaz has no bundle set locally. + if (foobaz.getResourceBundle() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobaz.getResourceBundle()); + } + if (foobaz.getResourceBundleName() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobaz.getResourceBundle()); + } + + // The current locale should have no effect on logrb. + Locale.setDefault(Locale.GERMAN); // shouldn't change anything... + + // for each possible logrb form + for (TestCase test : TestCase.values()) { + + // for various resource bundle + for (ResourceBundle b : new ResourceBundle[] { + anonBundle, bundle, bundle_fr, propertyBundle, null, + anonBundle, propertyBundle_fr, + }) { + final String baseName = getBaseName(b); + System.out.println("Testing " + test + " with " + + foobaz.getName() + " and " + + baseName); + + // call foobaz.logrb with the bundle + test.logrb(foobaz, b); + + // check that the bundle passed to logrb was used. + if (handler.lastBundle != b) { + throw new RuntimeException("Unexpected bundle: " + + handler.lastBundle); + } + if (!Objects.equals(handler.lastBundleName, baseName)) { + throw new RuntimeException("Unexpected bundle name: " + + handler.lastBundleName); + } + + // check that there was no effect on the bundle set + // on foobaz: it should still be null. + if (foobaz.getResourceBundle() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobaz.getResourceBundle()); + } + if (foobaz.getResourceBundleName() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobaz.getResourceBundleName()); + } + + // check that the last published log record had all the + // data that was logged by this testcase. + test.checkLogged(handler); + } + } + + } finally { + Locale.setDefault(defaultLocale); + } + + } +} diff --git a/test/java/util/logging/Logger/logrb/resources/ListBundle.java b/test/java/util/logging/Logger/logrb/resources/ListBundle.java new file mode 100644 index 000000000..121db2914 --- /dev/null +++ b/test/java/util/logging/Logger/logrb/resources/ListBundle.java @@ -0,0 +1,41 @@ +/* + * 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. + */ +package resources; + +import java.util.ListResourceBundle; + +/** + * + * @author danielfuchs + */ +public class ListBundle extends ListResourceBundle { + + @Override + protected Object[][] getContents() { + return new Object[][] { + { "dummy", "foo" }, + }; + + } + +} diff --git a/test/java/util/logging/Logger/logrb/resources/ListBundle_fr.java b/test/java/util/logging/Logger/logrb/resources/ListBundle_fr.java new file mode 100644 index 000000000..b168bf7ab --- /dev/null +++ b/test/java/util/logging/Logger/logrb/resources/ListBundle_fr.java @@ -0,0 +1,41 @@ +/* + * 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. + */ +package resources; + +import java.util.ListResourceBundle; + +/** + * + * @author danielfuchs + */ +public class ListBundle_fr extends ListResourceBundle { + + @Override + protected Object[][] getContents() { + return new Object[][] { + { "dummy", "toto" }, + }; + + } + +} diff --git a/test/java/util/logging/Logger/logrb/resources/PropertyBundle.properties b/test/java/util/logging/Logger/logrb/resources/PropertyBundle.properties new file mode 100644 index 000000000..343c64825 --- /dev/null +++ b/test/java/util/logging/Logger/logrb/resources/PropertyBundle.properties @@ -0,0 +1,24 @@ +# +# Copyright (c) 20013, 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. +# +dummy=foo + diff --git a/test/java/util/logging/Logger/logrb/resources/PropertyBundle_fr.properties b/test/java/util/logging/Logger/logrb/resources/PropertyBundle_fr.properties new file mode 100644 index 000000000..312027104 --- /dev/null +++ b/test/java/util/logging/Logger/logrb/resources/PropertyBundle_fr.properties @@ -0,0 +1,24 @@ +# +# 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. +# +dummy=toto + diff --git a/test/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java b/test/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java new file mode 100644 index 000000000..3ba69e7af --- /dev/null +++ b/test/java/util/logging/Logger/setResourceBundle/TestSetResourceBundle.java @@ -0,0 +1,393 @@ +/* + * 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. + */ +import java.security.AccessControlException; +import java.security.Permission; +import java.security.Permissions; +import java.security.Policy; +import java.security.ProtectionDomain; +import java.util.Locale; +import java.util.Objects; +import java.util.PropertyPermission; +import java.util.ResourceBundle; +import java.util.logging.Handler; +import java.util.logging.Level; +import java.util.logging.LogManager; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import java.util.logging.LoggingPermission; +import resources.ListBundle; + +/** + * @test + * @bug 8013839 + * @summary tests Logger.setResourceBundle; + * @build TestSetResourceBundle resources.ListBundle resources.ListBundle_fr + * @run main/othervm TestSetResourceBundle UNSECURE + * @run main/othervm TestSetResourceBundle PERMISSION + * @run main/othervm TestSetResourceBundle SECURE + * @author danielfuchs + */ +public class TestSetResourceBundle { + + final static String LIST_BUNDLE_NAME = "resources.ListBundle"; + final static String PROPERTY_BUNDLE_NAME = "resources.PropertyBundle"; + + /** + * A dummy handler class that we can use to check the bundle/bundle name + * that was present in the last LogRecord instance published. + */ + static final class TestHandler extends Handler { + ResourceBundle lastBundle = null; + String lastBundleName = null; + @Override + public void publish(LogRecord record) { + lastBundle = record.getResourceBundle(); + lastBundleName = record.getResourceBundleName(); + } + + @Override + public void flush() { + } + + @Override + public void close() throws SecurityException { + } + } + + /** + * We will test setResourceBundle() in 3 configurations. + * UNSECURE: No security manager. + * SECURE: With the security manager present - and the required + * LoggingPermission("control") granted. + * PERMISSION: With the security manager present - and the required + * LoggingPermission("control") *not* granted. Here we will + * test that the expected security permission is thrown. + */ + public static enum TestCase { + UNSECURE, SECURE, PERMISSION; + public void run(String name) throws Exception { + System.out.println("Running test case: " + name()); + switch (this) { + case UNSECURE: + testUnsecure(name); + break; + case SECURE: + testSecure(name); + break; + case PERMISSION: + testPermission(name); + break; + default: + throw new Error("Unknown test case: "+this); + } + } + public String loggerName(String name) { + return name().toLowerCase(Locale.ROOT) + "." + name; + } + } + + public static void main(String... args) throws Exception { + + Locale defaultLocale = Locale.getDefault(); + + if (args == null || args.length == 0) { + args = new String[] { + TestCase.UNSECURE.name(), + TestCase.SECURE.name() + }; + } + + for (String testName : args) { + TestCase test = TestCase.valueOf(testName); + try { + test.run(test.loggerName("foo.bar")); + } finally { + Locale.setDefault(defaultLocale); + } + } + } + + /** + * Test without security manager. + * @param loggerName The logger to use. + * @throws Exception if the test fails. + */ + public static void testUnsecure(String loggerName) throws Exception { + if (System.getSecurityManager() != null) { + throw new Error("Security manager is set"); + } + test(loggerName); + } + + /** + * Test with security manager. + * @param loggerName The logger to use. + * @throws Exception if the test fails. + */ + public static void testSecure(String loggerName) throws Exception { + if (System.getSecurityManager() != null) { + throw new Error("Security manager is already set"); + } + Policy.setPolicy(new SimplePolicy(TestCase.SECURE)); + System.setSecurityManager(new SecurityManager()); + test(loggerName); + } + + /** + * Test the LoggingPermission("control") is required. + * @param loggerName The logger to use. + */ + public static void testPermission(String loggerName) { + if (System.getSecurityManager() != null) { + throw new Error("Security manager is already set"); + } + Policy.setPolicy(new SimplePolicy(TestCase.PERMISSION)); + System.setSecurityManager(new SecurityManager()); + final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); + Logger foobar = Logger.getLogger(loggerName); + try { + foobar.setResourceBundle(bundle); + throw new RuntimeException("Permission not checked!"); + } catch (AccessControlException x) { + if (x.getPermission() instanceof LoggingPermission) { + if ("control".equals(x.getPermission().getName())) { + System.out.println("Got expected exception: " + x); + return; + } + } + throw new RuntimeException("Unexpected exception: "+x, x); + } + + } + + static String getBaseName(ResourceBundle bundle) { + return bundle == null ? null : bundle.getBaseBundleName(); + } + + public static void test(String loggerName) throws Exception { + + final ResourceBundle bundle = ResourceBundle.getBundle(LIST_BUNDLE_NAME); + Logger foobar = Logger.getLogger(loggerName); + + // Checks that IAE is thrown if the bundle has a null base name. + try { + foobar.setResourceBundle(new ListBundle()); + throw new RuntimeException("Expected exception not raised!"); + } catch (IllegalArgumentException x) { + System.out.println("Got expected exception: " + x); + } + + // Verify that resource bundle was not set. + if (foobar.getResourceBundle() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundle()); + } + if (foobar.getResourceBundleName() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundleName()); + } + + // Set acceptable resource bundle on logger. + foobar.setResourceBundle(bundle); + + // check that the bundle has been set correctly + if (bundle != foobar.getResourceBundle()) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundle()); + } + if (!Objects.equals(getBaseName(bundle), foobar.getResourceBundleName())) { + throw new RuntimeException("Unexpected bundle name: " + + foobar.getResourceBundleName()); + } + + // Check that we can replace the bundle with a bundle of the same name. + final ResourceBundle bundle_fr = + ResourceBundle.getBundle(LIST_BUNDLE_NAME, Locale.FRENCH); + foobar.setResourceBundle(bundle_fr); + + if (bundle_fr != foobar.getResourceBundle()) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundle()); + } + if (!Objects.equals(getBaseName(bundle_fr), foobar.getResourceBundleName())) { + throw new RuntimeException("Unexpected bundle name: " + + foobar.getResourceBundleName()); + } + + // Create a child logger + Logger foobaz = Logger.getLogger(loggerName + ".baz"); + + // Check that the child logger does not have a bundle set locally + if (foobaz.getResourceBundle() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundle()); + } + if (foobaz.getResourceBundleName() != null) { + throw new RuntimeException("Unexpected bundle: " + + foobar.getResourceBundleName()); + } + + + // Add a handler on the child logger. + final TestHandler handler = new TestHandler(); + foobaz.addHandler(handler); + + // log a message on the child logger + foobaz.severe("dummy"); + + // checks that the message has been logged with the bundle + // inherited from the parent logger + if (!LIST_BUNDLE_NAME.equals(handler.lastBundleName)) { + throw new RuntimeException("Unexpected bundle name: " + + handler.lastBundleName); + } + if (!bundle_fr.equals(handler.lastBundle)) { + throw new RuntimeException("Unexpected bundle: " + + handler.lastBundle); + } + + // Check that we can get set a bundle on the child logger + // using Logger.getLogger. + foobaz = Logger.getLogger(loggerName + ".baz", PROPERTY_BUNDLE_NAME); + + // check that the child logger has the correct bundle. + // it should no longer inherit it from its parent. + if (!PROPERTY_BUNDLE_NAME.equals(foobaz.getResourceBundleName())) { + throw new RuntimeException("Unexpected bundle name: " + + foobaz.getResourceBundleName()); + } + if (!PROPERTY_BUNDLE_NAME.equals(foobaz.getResourceBundle().getBaseBundleName())) { + throw new RuntimeException("Unexpected bundle name: " + + foobaz.getResourceBundle().getBaseBundleName()); + } + + // log a message on the child logger + foobaz.severe("dummy"); + + // check that the last published log record has the appropriate + // bundle. + if (!PROPERTY_BUNDLE_NAME.equals(handler.lastBundleName)) { + throw new RuntimeException("Unexpected bundle name: " + + handler.lastBundleName); + } + if (foobaz.getResourceBundle() != handler.lastBundle) { + throw new RuntimeException("Unexpected bundle: " + + handler.lastBundle); + } + + // try to set a bundle that has a different name, and checks that + // it fails in IAE. + try { + foobaz.setResourceBundle(bundle_fr); + throw new RuntimeException("Expected exception not raised!"); + } catch (IllegalArgumentException x) { + System.out.println("Got expected exception: " + x); + } + + // Test with a subclass of logger which overrides + // getResourceBundle() and getResourceBundleName() + Logger customLogger = new Logger(foobar.getName()+".bie", null) { + @Override + public ResourceBundle getResourceBundle() { + return bundle_fr; + } + + @Override + public String getResourceBundleName() { + return PROPERTY_BUNDLE_NAME; + } + }; + + final TestHandler handler2 = new TestHandler(); + customLogger.addHandler(handler2); + customLogger.setLevel(Level.FINE); + LogManager.getLogManager().addLogger(customLogger); + + Logger l = Logger.getLogger(customLogger.getName()); + if (l != customLogger) { + throw new RuntimeException("Wrong logger: " + l); + } + + // log on the custom logger. + customLogger.fine("dummy"); + + // check that the log record had the correct bundle. + if (! PROPERTY_BUNDLE_NAME.equals(handler2.lastBundleName)) { + throw new RuntimeException("Unexpected bundle name: " + + handler2.lastBundleName); + } + if (! PROPERTY_BUNDLE_NAME.equals(customLogger.getResourceBundleName())) { + throw new RuntimeException("Unexpected bundle name: " + + customLogger.getResourceBundleName()); + } + if (bundle_fr != handler2.lastBundle) { + throw new RuntimeException("Unexpected bundle: " + + handler2.lastBundle); + } + if (bundle_fr != customLogger.getResourceBundle()) { + throw new RuntimeException("Unexpected bundle: " + + customLogger.getResourceBundle()); + } + + // Do the same thing again with a child of the custom logger. + Logger biebar = Logger.getLogger(customLogger.getName() + ".bar"); + biebar.fine("dummy"); + + // because getResourceBundleName() is called on parent logger + // we will have handler2.lastBundleName = PROPERTY_BUNDLE_NAME + if (!PROPERTY_BUNDLE_NAME.equals(handler2.lastBundleName)) { + throw new RuntimeException("Unexpected bundle name: " + + handler2.lastBundleName); + } + // because getResourceBundle() is not called on parent logger + // we will have getBaseName(handler2.lastBundle) = PROPERTY_BUNDLE_NAME + // and not handler2.lastBundle = bundle_fr + if (handler2.lastBundle == null) { + throw new RuntimeException("Unexpected bundle: " + + handler2.lastBundle); + } + if (!PROPERTY_BUNDLE_NAME.equals(getBaseName(handler2.lastBundle))) { + throw new RuntimeException("Unexpected bundle name: " + + getBaseName(handler2.lastBundle)); + } + } + + public static class SimplePolicy extends Policy { + + final Permissions permissions; + public SimplePolicy(TestCase test) { + permissions = new Permissions(); + if (test != TestCase.PERMISSION) { + permissions.add(new LoggingPermission("control", null)); + } + // required for calling Locale.setDefault in the test. + permissions.add(new PropertyPermission("user.language", "write")); + } + + @Override + public boolean implies(ProtectionDomain domain, Permission permission) { + return permissions.implies(permission); + } + } + +} diff --git a/test/java/util/logging/Logger/setResourceBundle/resources/ListBundle.java b/test/java/util/logging/Logger/setResourceBundle/resources/ListBundle.java new file mode 100644 index 000000000..121db2914 --- /dev/null +++ b/test/java/util/logging/Logger/setResourceBundle/resources/ListBundle.java @@ -0,0 +1,41 @@ +/* + * 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. + */ +package resources; + +import java.util.ListResourceBundle; + +/** + * + * @author danielfuchs + */ +public class ListBundle extends ListResourceBundle { + + @Override + protected Object[][] getContents() { + return new Object[][] { + { "dummy", "foo" }, + }; + + } + +} diff --git a/test/java/util/logging/Logger/setResourceBundle/resources/ListBundle_fr.java b/test/java/util/logging/Logger/setResourceBundle/resources/ListBundle_fr.java new file mode 100644 index 000000000..b168bf7ab --- /dev/null +++ b/test/java/util/logging/Logger/setResourceBundle/resources/ListBundle_fr.java @@ -0,0 +1,41 @@ +/* + * 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. + */ +package resources; + +import java.util.ListResourceBundle; + +/** + * + * @author danielfuchs + */ +public class ListBundle_fr extends ListResourceBundle { + + @Override + protected Object[][] getContents() { + return new Object[][] { + { "dummy", "toto" }, + }; + + } + +} diff --git a/test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle.properties b/test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle.properties new file mode 100644 index 000000000..343c64825 --- /dev/null +++ b/test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle.properties @@ -0,0 +1,24 @@ +# +# Copyright (c) 20013, 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. +# +dummy=foo + diff --git a/test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle_fr.properties b/test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle_fr.properties new file mode 100644 index 000000000..312027104 --- /dev/null +++ b/test/java/util/logging/Logger/setResourceBundle/resources/PropertyBundle_fr.properties @@ -0,0 +1,24 @@ +# +# 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. +# +dummy=toto + -- cgit v1.2.3 From fb6e031f9cf13ae1bcfa6324ec5d9ea3860bbef1 Mon Sep 17 00:00:00 2001 From: mduigou Date: Wed, 16 Oct 2013 13:03:58 -0700 Subject: 8025910: rename substream(long) -> skip and remove substream(long,long) Reviewed-by: psandoz, henryjen --- .../java/util/stream/SpinedBufferTest.java | 8 +- .../util/stream/InfiniteStreamWithLimitOpTest.java | 24 ++-- .../tests/java/util/stream/IntSliceOpTest.java | 104 +++++++-------- .../tests/java/util/stream/SliceOpTest.java | 141 ++++++++++----------- 4 files changed, 122 insertions(+), 155 deletions(-) (limited to 'test') diff --git a/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java b/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java index 8f9c4ffd8..26a62cab6 100644 --- a/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java +++ b/test/java/util/stream/boottest/java/util/stream/SpinedBufferTest.java @@ -109,7 +109,7 @@ public class SpinedBufferTest { List end = Arrays.stream(array) .boxed() - .substream(array.length - lastSplitSize) + .skip(array.length - lastSplitSize) .collect(Collectors.toList()); assertEquals(contentOfLastSplit, end); } @@ -184,7 +184,7 @@ public class SpinedBufferTest { List end = Arrays.stream(array) .boxed() - .substream(array.length - lastSplitSize) + .skip(array.length - lastSplitSize) .collect(Collectors.toList()); assertEquals(contentOfLastSplit, end); } @@ -259,7 +259,7 @@ public class SpinedBufferTest { List end = Arrays.stream(array) .boxed() - .substream(array.length - lastSplitSize) + .skip(array.length - lastSplitSize) .collect(Collectors.toList()); assertEquals(contentOfLastSplit, end); } @@ -335,7 +335,7 @@ public class SpinedBufferTest { List end = Arrays.stream(array) .boxed() - .substream(array.length - lastSplitSize) + .skip(array.length - lastSplitSize) .collect(Collectors.toList()); assertEquals(contentOfLastSplit, end); } diff --git a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java index 091583941..e082e9df7 100644 --- a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java +++ b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest.java @@ -63,10 +63,8 @@ public class InfiniteStreamWithLimitOpTest extends OpTestCase { data.add(new Object[]{f.apply("Stream.limit(%d)"), (UnaryOperator) s -> s.limit(SKIP_LIMIT_SIZE)}); - data.add(new Object[]{f.apply("Stream.substream(%d)"), - (UnaryOperator) s -> s.substream(SKIP_LIMIT_SIZE, SKIP_LIMIT_SIZE * 2)}); - data.add(new Object[]{f.apply("Stream.substream(%1$d).limit(%1$d)"), - (UnaryOperator) s -> s.substream(SKIP_LIMIT_SIZE).limit(SKIP_LIMIT_SIZE)}); + data.add(new Object[]{f.apply("Stream.skip(%1$d).limit(%1$d)"), + (UnaryOperator) s -> s.skip(SKIP_LIMIT_SIZE).limit(SKIP_LIMIT_SIZE)}); return data.toArray(new Object[0][]); } @@ -79,10 +77,8 @@ public class InfiniteStreamWithLimitOpTest extends OpTestCase { data.add(new Object[]{f.apply("IntStream.limit(%d)"), (UnaryOperator) s -> s.limit(SKIP_LIMIT_SIZE)}); - data.add(new Object[]{f.apply("IntStream.substream(%d)"), - (UnaryOperator) s -> s.substream(SKIP_LIMIT_SIZE, SKIP_LIMIT_SIZE * 2)}); - data.add(new Object[]{f.apply("IntStream.substream(%1$d).limit(%1$d)"), - (UnaryOperator) s -> s.substream(SKIP_LIMIT_SIZE).limit(SKIP_LIMIT_SIZE)}); + data.add(new Object[]{f.apply("IntStream.skip(%1$d).limit(%1$d)"), + (UnaryOperator) s -> s.skip(SKIP_LIMIT_SIZE).limit(SKIP_LIMIT_SIZE)}); return data.toArray(new Object[0][]); } @@ -95,10 +91,8 @@ public class InfiniteStreamWithLimitOpTest extends OpTestCase { data.add(new Object[]{f.apply("LongStream.limit(%d)"), (UnaryOperator) s -> s.limit(SKIP_LIMIT_SIZE)}); - data.add(new Object[]{f.apply("LongStream.substream(%d)"), - (UnaryOperator) s -> s.substream(SKIP_LIMIT_SIZE, SKIP_LIMIT_SIZE * 2)}); - data.add(new Object[]{f.apply("LongStream.substream(%1$d).limit(%1$d)"), - (UnaryOperator) s -> s.substream(SKIP_LIMIT_SIZE).limit(SKIP_LIMIT_SIZE)}); + data.add(new Object[]{f.apply("LongStream.skip(%1$d).limit(%1$d)"), + (UnaryOperator) s -> s.skip(SKIP_LIMIT_SIZE).limit(SKIP_LIMIT_SIZE)}); return data.toArray(new Object[0][]); } @@ -111,10 +105,8 @@ public class InfiniteStreamWithLimitOpTest extends OpTestCase { data.add(new Object[]{f.apply("DoubleStream.limit(%d)"), (UnaryOperator) s -> s.limit(SKIP_LIMIT_SIZE)}); - data.add(new Object[]{f.apply("DoubleStream.substream(%d)"), - (UnaryOperator) s -> s.substream(SKIP_LIMIT_SIZE, SKIP_LIMIT_SIZE * 2)}); - data.add(new Object[]{f.apply("DoubleStream.substream(%1$d).limit(%1$d)"), - (UnaryOperator) s -> s.substream(SKIP_LIMIT_SIZE).limit(SKIP_LIMIT_SIZE)}); + data.add(new Object[]{f.apply("DoubleStream.skip(%1$d).limit(%1$d)"), + (UnaryOperator) s -> s.skip(SKIP_LIMIT_SIZE).limit(SKIP_LIMIT_SIZE)}); return data.toArray(new Object[0][]); } diff --git a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntSliceOpTest.java b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntSliceOpTest.java index 0d74f4873..51d1362da 100644 --- a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntSliceOpTest.java +++ b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/IntSliceOpTest.java @@ -44,27 +44,27 @@ public class IntSliceOpTest extends OpTestCase { private static final int[] EMPTY_INT_ARRAY = new int[0]; public void testSkip() { - assertCountSum(IntStream.range(0, 0).substream(0).boxed(), 0, 0); - assertCountSum(IntStream.range(0, 0).substream(4).boxed(), 0, 0); - assertCountSum(IntStream.range(1, 5).substream(4).boxed(), 0, 0); - assertCountSum(IntStream.range(1, 5).substream(2).boxed(), 2, 7); - assertCountSum(IntStream.range(1, 5).substream(0).boxed(), 4, 10); - - assertCountSum(IntStream.range(0, 0).parallel().substream(0).boxed(), 0, 0); - assertCountSum(IntStream.range(0, 0).parallel().substream(4).boxed(), 0, 0); - assertCountSum(IntStream.range(1, 5).parallel().substream(4).boxed(), 0, 0); - assertCountSum(IntStream.range(1, 5).parallel().substream(2).boxed(), 2, 7); - assertCountSum(IntStream.range(1, 5).parallel().substream(0).boxed(), 4, 10); - - exerciseOps(EMPTY_INT_ARRAY, s -> s.substream(0), EMPTY_INT_ARRAY); - exerciseOps(EMPTY_INT_ARRAY, s -> s.substream(10), EMPTY_INT_ARRAY); - - exerciseOps(IntStream.range(1, 2).toArray(), s -> s.substream(0), IntStream.range(1, 2).toArray()); - exerciseOps(IntStream.range(1, 2).toArray(), s -> s.substream(1), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(0), IntStream.range(1, 101).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(10), IntStream.range(11, 101).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(100), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(200), EMPTY_INT_ARRAY); + assertCountSum(IntStream.range(0, 0).skip(0).boxed(), 0, 0); + assertCountSum(IntStream.range(0, 0).skip(4).boxed(), 0, 0); + assertCountSum(IntStream.range(1, 5).skip(4).boxed(), 0, 0); + assertCountSum(IntStream.range(1, 5).skip(2).boxed(), 2, 7); + assertCountSum(IntStream.range(1, 5).skip(0).boxed(), 4, 10); + + assertCountSum(IntStream.range(0, 0).parallel().skip(0).boxed(), 0, 0); + assertCountSum(IntStream.range(0, 0).parallel().skip(4).boxed(), 0, 0); + assertCountSum(IntStream.range(1, 5).parallel().skip(4).boxed(), 0, 0); + assertCountSum(IntStream.range(1, 5).parallel().skip(2).boxed(), 2, 7); + assertCountSum(IntStream.range(1, 5).parallel().skip(0).boxed(), 4, 10); + + exerciseOps(EMPTY_INT_ARRAY, s -> s.skip(0), EMPTY_INT_ARRAY); + exerciseOps(EMPTY_INT_ARRAY, s -> s.skip(10), EMPTY_INT_ARRAY); + + exerciseOps(IntStream.range(1, 2).toArray(), s -> s.skip(0), IntStream.range(1, 2).toArray()); + exerciseOps(IntStream.range(1, 2).toArray(), s -> s.skip(1), EMPTY_INT_ARRAY); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(0), IntStream.range(1, 101).toArray()); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(10), IntStream.range(11, 101).toArray()); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(100), EMPTY_INT_ARRAY); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(200), EMPTY_INT_ARRAY); } public void testLimit() { @@ -92,41 +92,23 @@ public class IntSliceOpTest extends OpTestCase { } public void testSkipLimit() { - exerciseOps(EMPTY_INT_ARRAY, s -> s.substream(0).limit(0), EMPTY_INT_ARRAY); - exerciseOps(EMPTY_INT_ARRAY, s -> s.substream(0).limit(10), EMPTY_INT_ARRAY); - exerciseOps(EMPTY_INT_ARRAY, s -> s.substream(10).limit(0), EMPTY_INT_ARRAY); - exerciseOps(EMPTY_INT_ARRAY, s -> s.substream(10).limit(10), EMPTY_INT_ARRAY); - - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(0).limit(100), IntStream.range(1, 101).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(0).limit(10), IntStream.range(1, 11).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(0).limit(0), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(10).limit(100), IntStream.range(11, 101).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(10).limit(10), IntStream.range(11, 21).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(10).limit(0), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(100).limit(100), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(100).limit(10), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(100).limit(0), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(200).limit(100), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(200).limit(10), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(200).limit(0), EMPTY_INT_ARRAY); - } - - public void testSlice() { - exerciseOps(EMPTY_INT_ARRAY, s -> s.substream(0, 0), EMPTY_INT_ARRAY); - exerciseOps(EMPTY_INT_ARRAY, s -> s.substream(10, 10), EMPTY_INT_ARRAY); - - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(0, 100), IntStream.range(1, 101).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(0, 10), IntStream.range(1, 11).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(0, 0), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(10, 110), IntStream.range(11, 101).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(10, 20), IntStream.range(11, 21).toArray()); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(10, 10), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(100, 200), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(100, 110), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(100, 100), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(200, 300), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(200, 210), EMPTY_INT_ARRAY); - exerciseOps(IntStream.range(1, 101).toArray(), s -> s.substream(200, 200), EMPTY_INT_ARRAY); + exerciseOps(EMPTY_INT_ARRAY, s -> s.skip(0).limit(0), EMPTY_INT_ARRAY); + exerciseOps(EMPTY_INT_ARRAY, s -> s.skip(0).limit(10), EMPTY_INT_ARRAY); + exerciseOps(EMPTY_INT_ARRAY, s -> s.skip(10).limit(0), EMPTY_INT_ARRAY); + exerciseOps(EMPTY_INT_ARRAY, s -> s.skip(10).limit(10), EMPTY_INT_ARRAY); + + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(0).limit(100), IntStream.range(1, 101).toArray()); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(0).limit(10), IntStream.range(1, 11).toArray()); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(0).limit(0), EMPTY_INT_ARRAY); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(10).limit(100), IntStream.range(11, 101).toArray()); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(10).limit(10), IntStream.range(11, 21).toArray()); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(10).limit(0), EMPTY_INT_ARRAY); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(100).limit(100), EMPTY_INT_ARRAY); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(100).limit(10), EMPTY_INT_ARRAY); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(100).limit(0), EMPTY_INT_ARRAY); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(200).limit(100), EMPTY_INT_ARRAY); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(200).limit(10), EMPTY_INT_ARRAY); + exerciseOps(IntStream.range(1, 101).toArray(), s -> s.skip(200).limit(0), EMPTY_INT_ARRAY); } private int sliceSize(int dataSize, int skip, int limit) { @@ -146,10 +128,10 @@ public class IntSliceOpTest extends OpTestCase { for (int s : skips) { setContext("skip", s); - Collection sr = exerciseOps(data, st -> st.substream(s)); + Collection sr = exerciseOps(data, st -> st.skip(s)); assertEquals(sr.size(), sliceSize(data.size(), s)); - sr = exerciseOps(data, st -> st.substream(s).substream(s / 2)); + sr = exerciseOps(data, st -> st.skip(s).skip(s / 2)); assertEquals(sr.size(), sliceSize(sliceSize(data.size(), s), s / 2)); } } @@ -163,10 +145,10 @@ public class IntSliceOpTest extends OpTestCase { setContext("skip", s); for (int limit : limits) { setContext("limit", limit); - Collection sr = exerciseOps(data, st -> st.substream(s).limit(limit)); + Collection sr = exerciseOps(data, st -> st.skip(s).limit(limit)); assertEquals(sr.size(), sliceSize(sliceSize(data.size(), s), 0, limit)); - sr = exerciseOps(data, st -> st.substream(s, limit+s)); + sr = exerciseOps(data, st -> st.skip(s).limit(limit)); assertEquals(sr.size(), sliceSize(data.size(), s, limit)); } } @@ -204,7 +186,7 @@ public class IntSliceOpTest extends OpTestCase { } public void testSkipParallel() { - int[] l = IntStream.range(1, 1001).parallel().substream(200).limit(200).sequential().toArray(); + int[] l = IntStream.range(1, 1001).parallel().skip(200).limit(200).sequential().toArray(); assertEquals(l.length, 200); assertEquals(l[l.length - 1], 400); } diff --git a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java index a02348623..44499d021 100644 --- a/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java +++ b/test/java/util/stream/test/org/openjdk/tests/java/util/stream/SliceOpTest.java @@ -50,27 +50,27 @@ import static java.util.stream.LambdaTestHelpers.*; public class SliceOpTest extends OpTestCase { public void testSkip() { - assertCountSum(countTo(0).stream().substream(0), 0, 0); - assertCountSum(countTo(0).stream().substream(4), 0, 0); - assertCountSum(countTo(4).stream().substream(4), 0, 0); - assertCountSum(countTo(4).stream().substream(2), 2, 7); - assertCountSum(countTo(4).stream().substream(0), 4, 10); - - assertCountSum(countTo(0).parallelStream().substream(0), 0, 0); - assertCountSum(countTo(0).parallelStream().substream(4), 0, 0); - assertCountSum(countTo(4).parallelStream().substream(4), 0, 0); - assertCountSum(countTo(4).parallelStream().substream(2), 2, 7); - assertCountSum(countTo(4).parallelStream().substream(0), 4, 10); - - exerciseOps(Collections.emptyList(), s -> s.substream(0), Collections.emptyList()); - exerciseOps(Collections.emptyList(), s -> s.substream(10), Collections.emptyList()); - - exerciseOps(countTo(1), s -> s.substream(0), countTo(1)); - exerciseOps(countTo(1), s -> s.substream(1), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(0), countTo(100)); - exerciseOps(countTo(100), s -> s.substream(10), range(11, 100)); - exerciseOps(countTo(100), s -> s.substream(100), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(200), Collections.emptyList()); + assertCountSum(countTo(0).stream().skip(0), 0, 0); + assertCountSum(countTo(0).stream().skip(4), 0, 0); + assertCountSum(countTo(4).stream().skip(4), 0, 0); + assertCountSum(countTo(4).stream().skip(2), 2, 7); + assertCountSum(countTo(4).stream().skip(0), 4, 10); + + assertCountSum(countTo(0).parallelStream().skip(0), 0, 0); + assertCountSum(countTo(0).parallelStream().skip(4), 0, 0); + assertCountSum(countTo(4).parallelStream().skip(4), 0, 0); + assertCountSum(countTo(4).parallelStream().skip(2), 2, 7); + assertCountSum(countTo(4).parallelStream().skip(0), 4, 10); + + exerciseOps(Collections.emptyList(), s -> s.skip(0), Collections.emptyList()); + exerciseOps(Collections.emptyList(), s -> s.skip(10), Collections.emptyList()); + + exerciseOps(countTo(1), s -> s.skip(0), countTo(1)); + exerciseOps(countTo(1), s -> s.skip(1), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(0), countTo(100)); + exerciseOps(countTo(100), s -> s.skip(10), range(11, 100)); + exerciseOps(countTo(100), s -> s.skip(100), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(200), Collections.emptyList()); } public void testLimit() { @@ -97,43 +97,43 @@ public class SliceOpTest extends OpTestCase { } public void testSkipLimit() { - exerciseOps(Collections.emptyList(), s -> s.substream(0).limit(0), Collections.emptyList()); - exerciseOps(Collections.emptyList(), s -> s.substream(0).limit(10), Collections.emptyList()); - exerciseOps(Collections.emptyList(), s -> s.substream(10).limit(0), Collections.emptyList()); - exerciseOps(Collections.emptyList(), s -> s.substream(10).limit(10), Collections.emptyList()); - - exerciseOps(countTo(100), s -> s.substream(0).limit(100), countTo(100)); - exerciseOps(countTo(100), s -> s.substream(0).limit(10), countTo(10)); - exerciseOps(countTo(100), s -> s.substream(0).limit(0), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(10).limit(100), range(11, 100)); - exerciseOps(countTo(100), s -> s.substream(10).limit(10), range(11, 20)); - exerciseOps(countTo(100), s -> s.substream(10).limit(0), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(100).limit(100), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(100).limit(10), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(100).limit(0), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(200).limit(100), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(200).limit(10), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(200).limit(0), Collections.emptyList()); + exerciseOps(Collections.emptyList(), s -> s.skip(0).limit(0), Collections.emptyList()); + exerciseOps(Collections.emptyList(), s -> s.skip(0).limit(10), Collections.emptyList()); + exerciseOps(Collections.emptyList(), s -> s.skip(10).limit(0), Collections.emptyList()); + exerciseOps(Collections.emptyList(), s -> s.skip(10).limit(10), Collections.emptyList()); + + exerciseOps(countTo(100), s -> s.skip(0).limit(100), countTo(100)); + exerciseOps(countTo(100), s -> s.skip(0).limit(10), countTo(10)); + exerciseOps(countTo(100), s -> s.skip(0).limit(0), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(10).limit(100), range(11, 100)); + exerciseOps(countTo(100), s -> s.skip(10).limit(10), range(11, 20)); + exerciseOps(countTo(100), s -> s.skip(10).limit(0), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(100).limit(100), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(100).limit(10), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(100).limit(0), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(200).limit(100), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(200).limit(10), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(200).limit(0), Collections.emptyList()); } public void testSlice() { - exerciseOps(Collections.emptyList(), s -> s.substream(0, 0), Collections.emptyList()); - exerciseOps(Collections.emptyList(), s -> s.substream(0, 10), Collections.emptyList()); - exerciseOps(Collections.emptyList(), s -> s.substream(10, 10), Collections.emptyList()); - exerciseOps(Collections.emptyList(), s -> s.substream(10, 20), Collections.emptyList()); - - exerciseOps(countTo(100), s -> s.substream(0, 100), countTo(100)); - exerciseOps(countTo(100), s -> s.substream(0, 10), countTo(10)); - exerciseOps(countTo(100), s -> s.substream(0, 0), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(10, 110), range(11, 100)); - exerciseOps(countTo(100), s -> s.substream(10, 20), range(11, 20)); - exerciseOps(countTo(100), s -> s.substream(10, 10), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(100, 200), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(100, 110), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(100, 100), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(200, 300), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(200, 210), Collections.emptyList()); - exerciseOps(countTo(100), s -> s.substream(200, 200), Collections.emptyList()); + exerciseOps(Collections.emptyList(), s -> s.skip(0).limit(0), Collections.emptyList()); + exerciseOps(Collections.emptyList(), s -> s.skip(0).limit(10), Collections.emptyList()); + exerciseOps(Collections.emptyList(), s -> s.skip(10).limit(10), Collections.emptyList()); + exerciseOps(Collections.emptyList(), s -> s.skip(10).limit(20), Collections.emptyList()); + + exerciseOps(countTo(100), s -> s.skip(0).limit(100), countTo(100)); + exerciseOps(countTo(100), s -> s.skip(0).limit(10), countTo(10)); + exerciseOps(countTo(100), s -> s.skip(0).limit(0), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(10).limit(100), range(11, 100)); + exerciseOps(countTo(100), s -> s.skip(10).limit(10), range(11, 20)); + exerciseOps(countTo(100), s -> s.skip(10).limit(0), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(100).limit(100), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(100).limit(10), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(100).limit(0), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(200).limit(100), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(200).limit(10), Collections.emptyList()); + exerciseOps(countTo(100), s -> s.skip(200).limit(0), Collections.emptyList()); } private int sliceSize(int dataSize, int skip, int limit) { @@ -156,17 +156,17 @@ public class SliceOpTest extends OpTestCase { setContext("skip", s); testSliceMulti(data, sliceSize(data.size(), s), - st -> st.substream(s), - st -> st.substream(s), - st -> st.substream(s), - st -> st.substream(s)); + st -> st.skip(s), + st -> st.skip(s), + st -> st.skip(s), + st -> st.skip(s)); testSliceMulti(data, sliceSize(sliceSize(data.size(), s), s/2), - st -> st.substream(s).substream(s / 2), - st -> st.substream(s).substream(s / 2), - st -> st.substream(s).substream(s / 2), - st -> st.substream(s).substream(s / 2)); + st -> st.skip(s).skip(s / 2), + st -> st.skip(s).skip(s / 2), + st -> st.skip(s).skip(s / 2), + st -> st.skip(s).skip(s / 2)); } } @@ -182,17 +182,10 @@ public class SliceOpTest extends OpTestCase { setContext("limit", l); testSliceMulti(data, sliceSize(sliceSize(data.size(), s), 0, l), - st -> st.substream(s).limit(l), - st -> st.substream(s).limit(l), - st -> st.substream(s).limit(l), - st -> st.substream(s).limit(l)); - - testSliceMulti(data, - sliceSize(data.size(), s, l), - st -> st.substream(s, l+s), - st -> st.substream(s, l+s), - st -> st.substream(s, l+s), - st -> st.substream(s, l+s)); + st -> st.skip(s).limit(l), + st -> st.skip(s).limit(l), + st -> st.skip(s).limit(l), + st -> st.skip(s).limit(l)); } } } -- cgit v1.2.3 From 24c484e5bb899f58af006c2ec75efae1f283885a Mon Sep 17 00:00:00 2001 From: aefimov Date: Sun, 13 Oct 2013 14:19:31 +0400 Subject: 8025255: (tz) Support tzdata2013g Reviewed-by: okutsu, mfang --- test/sun/util/calendar/zi/tzdata/VERSION | 2 +- test/sun/util/calendar/zi/tzdata/africa | 52 +++++++--- test/sun/util/calendar/zi/tzdata/antarctica | 27 ++--- test/sun/util/calendar/zi/tzdata/asia | 91 +++++++++++------ test/sun/util/calendar/zi/tzdata/australasia | 31 ++++-- test/sun/util/calendar/zi/tzdata/backward | 12 ++- test/sun/util/calendar/zi/tzdata/etcetera | 4 +- test/sun/util/calendar/zi/tzdata/europe | 126 ++++++++++++++++------- test/sun/util/calendar/zi/tzdata/iso3166.tab | 6 +- test/sun/util/calendar/zi/tzdata/leapseconds | 70 +++---------- test/sun/util/calendar/zi/tzdata/northamerica | 142 ++++++++++---------------- test/sun/util/calendar/zi/tzdata/southamerica | 57 +++++++++-- test/sun/util/calendar/zi/tzdata/zone.tab | 32 +++--- 13 files changed, 362 insertions(+), 290 deletions(-) (limited to 'test') diff --git a/test/sun/util/calendar/zi/tzdata/VERSION b/test/sun/util/calendar/zi/tzdata/VERSION index e50b6f37d..ea1c49a6f 100644 --- a/test/sun/util/calendar/zi/tzdata/VERSION +++ b/test/sun/util/calendar/zi/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2013d +tzdata2013g diff --git a/test/sun/util/calendar/zi/tzdata/africa b/test/sun/util/calendar/zi/tzdata/africa index 6b19b982c..19bc98afe 100644 --- a/test/sun/util/calendar/zi/tzdata/africa +++ b/test/sun/util/calendar/zi/tzdata/africa @@ -881,13 +881,23 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou # transitions would be 2013-07-07 and 2013-08-10; see: # http://www.maroc.ma/en/news/morocco-suspends-daylight-saving-time-july-7-aug10 -# From Paul Eggert (2013-07-03): +# From Steffen Thorsen (2013-09-28): +# Morocco extends DST by one month, on very short notice, just 1 day +# before it was going to end. There is a new decree (2.13.781) for +# this, where DST from now on goes from last Sunday of March at 02:00 +# to last Sunday of October at 03:00, similar to EU rules. Official +# source (French): +# http://www.maroc.gov.ma/fr/actualites/lhoraire-dete-gmt1-maintenu-jusquau-27-octobre-2013 +# Another source (specifying the time for start and end in the decree): +# http://www.lemag.ma/Heure-d-ete-au-Maroc-jusqu-au-27-octobre_a75620.html + +# From Paul Eggert (2013-09-30): # To estimate what the Moroccan government will do in future years, -# transition dates for 2014 through 2021 were determined by running +# transition dates for 2014 through 2037 were determined by running # the following program under GNU Emacs 24.3: # # (let ((islamic-year 1435)) -# (while (< islamic-year 1444) +# (while (< islamic-year 1460) # (let ((a # (calendar-gregorian-from-absolute # (calendar-islamic-to-absolute (list 9 1 islamic-year)))) @@ -902,13 +912,14 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou # (car (cdr (cdr b))) (calendar-month-name (car b) t) (car (cdr b))))) # (setq islamic-year (+ 1 islamic-year)))) # -# with the results hand-edited for 2020-2022, when the normal spring-forward -# date falls during the estimated Ramadan. -# -# From 2023 through 2038 Ramadan is not predicted to overlap with -# daylight saving time. Starting in 2039 there will be overlap again, +# with spring-forward transitions removed for 2023-2025, when the +# normal spring-forward date falls during the estimated Ramadan; with +# all transitions removed for 2026-2035, where the estimated Ramadan +# falls entirely outside daylight-saving time; and with fall-back +# transitions removed for 2036-2037, where the normal fall-back +# date falls during the estimated Ramadan. Problems continue after that, # but 32-bit time_t values roll around in 2038 so for now do not worry -# about dates after 2038. +# about dates after 2037. # RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -935,12 +946,14 @@ Rule Morocco 2010 only - May 2 0:00 1:00 S Rule Morocco 2010 only - Aug 8 0:00 0 - Rule Morocco 2011 only - Apr 3 0:00 1:00 S Rule Morocco 2011 only - Jul 31 0 0 - -Rule Morocco 2012 2019 - Apr lastSun 2:00 1:00 S -Rule Morocco 2012 max - Sep lastSun 3:00 0 - +Rule Morocco 2012 2013 - Apr lastSun 2:00 1:00 S +Rule Morocco 2012 only - Sep 30 3:00 0 - Rule Morocco 2012 only - Jul 20 3:00 0 - Rule Morocco 2012 only - Aug 20 2:00 1:00 S Rule Morocco 2013 only - Jul 7 3:00 0 - Rule Morocco 2013 only - Aug 10 2:00 1:00 S +Rule Morocco 2013 2035 - Oct lastSun 3:00 0 - +Rule Morocco 2014 2022 - Mar lastSun 2:00 1:00 S Rule Morocco 2014 only - Jun 29 3:00 0 - Rule Morocco 2014 only - Jul 29 2:00 1:00 S Rule Morocco 2015 only - Jun 18 3:00 0 - @@ -953,10 +966,21 @@ Rule Morocco 2018 only - May 16 3:00 0 - Rule Morocco 2018 only - Jun 15 2:00 1:00 S Rule Morocco 2019 only - May 6 3:00 0 - Rule Morocco 2019 only - Jun 5 2:00 1:00 S +Rule Morocco 2020 only - Apr 24 3:00 0 - Rule Morocco 2020 only - May 24 2:00 1:00 S +Rule Morocco 2021 only - Apr 13 3:00 0 - Rule Morocco 2021 only - May 13 2:00 1:00 S +Rule Morocco 2022 only - Apr 3 3:00 0 - Rule Morocco 2022 only - May 3 2:00 1:00 S -Rule Morocco 2023 max - Apr lastSun 2:00 1:00 S +Rule Morocco 2023 only - Apr 22 2:00 1:00 S +Rule Morocco 2024 only - Apr 10 2:00 1:00 S +Rule Morocco 2025 only - Mar 31 2:00 1:00 S +Rule Morocco 2026 max - Mar lastSun 2:00 1:00 S +Rule Morocco 2036 only - Oct 21 3:00 0 - +Rule Morocco 2037 only - Oct 11 3:00 0 - +Rule Morocco 2038 only - Sep 30 3:00 0 - +Rule Morocco 2038 only - Oct 30 2:00 1:00 S +Rule Morocco 2038 max - Oct lastSun 3:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26 @@ -1123,9 +1147,7 @@ Zone Africa/Khartoum 2:10:08 - LMT 1931 3:00 - EAT # South Sudan -Zone Africa/Juba 2:06:24 - LMT 1931 - 2:00 Sudan CA%sT 2000 Jan 15 12:00 - 3:00 - EAT +Link Africa/Khartoum Africa/Juba # Swaziland # Zone NAME GMTOFF RULES FORMAT [UNTIL] diff --git a/test/sun/util/calendar/zi/tzdata/antarctica b/test/sun/util/calendar/zi/tzdata/antarctica index 434432611..f30cf747f 100644 --- a/test/sun/util/calendar/zi/tzdata/antarctica +++ b/test/sun/util/calendar/zi/tzdata/antarctica @@ -39,9 +39,9 @@ # # Except for the French entries, # I made up all time zone abbreviations mentioned here; corrections welcome! -# FORMAT is `zzz' and GMTOFF is 0 for locations while uninhabited. +# FORMAT is 'zzz' and GMTOFF is 0 for locations while uninhabited. -# These rules are stolen from the `southamerica' file. +# These rules are stolen from the 'southamerica' file. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule ArgAQ 1964 1966 - Mar 1 0:00 0 - Rule ArgAQ 1964 1966 - Oct 15 0:00 1:00 S @@ -251,9 +251,10 @@ Zone Antarctica/Syowa 0 - zzz 1957 Jan 29 # Scott Island (never inhabited) # # year-round base -# Scott, Ross Island, since 1957-01, is like Antarctica/McMurdo. +# Scott Base, Ross Island, since 1957-01. +# See Pacific/Auckland. # -# These rules for New Zealand are stolen from the `australasia' file. +# These rules for New Zealand are stolen from the 'australasia' file. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule NZAQ 1974 only - Nov 3 2:00s 1:00 D Rule NZAQ 1975 1988 - Oct lastSun 2:00s 1:00 D @@ -291,11 +292,11 @@ Rule NZAQ 2008 max - Apr Sun>=1 2:00s 0 S # From Lee Hotz (2001-03-08): # I queried the folks at Columbia who spent the summer at Vostok and this is # what they had to say about time there: -# ``in the US Camp (East Camp) we have been on New Zealand (McMurdo) +# "in the US Camp (East Camp) we have been on New Zealand (McMurdo) # time, which is 12 hours ahead of GMT. The Russian Station Vostok was # 6 hours behind that (although only 2 miles away, i.e. 6 hours ahead # of GMT). This is a time zone I think two hours east of Moscow. The -# natural time zone is in between the two: 8 hours ahead of GMT.'' +# natural time zone is in between the two: 8 hours ahead of GMT." # # From Paul Eggert (2001-05-04): # This seems to be hopelessly confusing, so I asked Lee Hotz about it @@ -360,16 +361,8 @@ Zone Antarctica/Palmer 0 - zzz 1965 -4:00 ChileAQ CL%sT # # -# McMurdo, Ross Island, since 1955-12 -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Antarctica/McMurdo 0 - zzz 1956 - 12:00 NZAQ NZ%sT -# -# Amundsen-Scott, South Pole, continuously occupied since 1956-11-20 -# -# From Paul Eggert (1996-09-03): -# Normally it wouldn't have a separate entry, since it's like the -# larger Antarctica/McMurdo since 1970, but it's too famous to omit. +# McMurdo Station, Ross Island, since 1955-12 +# Amundsen-Scott South Pole Station, continuously occupied since 1956-11-20 # # From Chris Carrier (1996-06-27): # Siple, the first commander of the South Pole station, @@ -391,4 +384,4 @@ Zone Antarctica/McMurdo 0 - zzz 1956 # we have to go around and set them back 5 minutes or so. # Maybe if we let them run fast all of the time, we'd get to leave here sooner!! # -Link Antarctica/McMurdo Antarctica/South_Pole +# See 'australasia' for Antarctica/McMurdo. diff --git a/test/sun/util/calendar/zi/tzdata/asia b/test/sun/util/calendar/zi/tzdata/asia index f0931b326..fd278e5c8 100644 --- a/test/sun/util/calendar/zi/tzdata/asia +++ b/test/sun/util/calendar/zi/tzdata/asia @@ -29,7 +29,7 @@ # go ahead and edit the file (and please send any changes to # tz@iana.org for general use in the future). -# From Paul Eggert (2013-02-21): +# From Paul Eggert (2013-08-11): # # A good source for time zone historical data outside the U.S. is # Thomas G. Shanks and Rique Pottenger, The International Atlas (6th edition), @@ -67,11 +67,11 @@ # 4:00 GST Gulf* # 5:30 IST India # 7:00 ICT Indochina* -# 7:00 WIT west Indonesia -# 8:00 CIT central Indonesia +# 7:00 WIB west Indonesia (Waktu Indonesia Barat) +# 8:00 WITA central Indonesia (Waktu Indonesia Tengah) # 8:00 CST China # 9:00 CJT Central Japanese Time (1896/1937)* -# 9:00 EIT east Indonesia +# 9:00 WIT east Indonesia (Waktu Indonesia Timur) # 9:00 JST JDT Japan # 9:00 KST KDT Korea # 9:30 CST (Australian) Central Standard Time @@ -779,7 +779,7 @@ Zone Asia/Dili 8:22:20 - LMT 1912 8:00 - TLT 1942 Feb 21 23:00 # E Timor Time 9:00 - JST 1945 Sep 23 9:00 - TLT 1976 May 3 - 8:00 - CIT 2000 Sep 17 00:00 + 8:00 - WITA 2000 Sep 17 00:00 9:00 - TLT # India @@ -816,36 +816,53 @@ Zone Asia/Kolkata 5:53:28 - LMT 1880 # Kolkata # (Hollandia). For now, assume all Indonesian locations other than Jayapura # switched on 1945-09-23. # +# From Paul Eggert (2013-08-11): +# Normally the tz database uses English-language abbreviations, but in +# Indonesia it's typical to use Indonesian-language abbreviations even +# when writing in English. For example, see the English-language +# summary published by the Time and Frequency Laboratory of the +# Research Center for Calibration, Instrumentation and Metrology, +# Indonesia, (2006-09-29). +# The abbreviations are: +# +# WIB - UTC+7 - Waktu Indonesia Barat (Indonesia western time) +# WITA - UTC+8 - Waktu Indonesia Tengah (Indonesia central time) +# WIT - UTC+9 - Waktu Indonesia Timur (Indonesia eastern time) +# # Zone NAME GMTOFF RULES FORMAT [UNTIL] +# Java, Sumatra Zone Asia/Jakarta 7:07:12 - LMT 1867 Aug 10 # Shanks & Pottenger say the next transition was at 1924 Jan 1 0:13, # but this must be a typo. - 7:07:12 - JMT 1923 Dec 31 23:47:12 # Jakarta + 7:07:12 - BMT 1923 Dec 31 23:47:12 # Batavia 7:20 - JAVT 1932 Nov # Java Time - 7:30 - WIT 1942 Mar 23 + 7:30 - WIB 1942 Mar 23 9:00 - JST 1945 Sep 23 - 7:30 - WIT 1948 May - 8:00 - WIT 1950 May - 7:30 - WIT 1964 - 7:00 - WIT + 7:30 - WIB 1948 May + 8:00 - WIB 1950 May + 7:30 - WIB 1964 + 7:00 - WIB +# west and central Borneo Zone Asia/Pontianak 7:17:20 - LMT 1908 May 7:17:20 - PMT 1932 Nov # Pontianak MT - 7:30 - WIT 1942 Jan 29 + 7:30 - WIB 1942 Jan 29 9:00 - JST 1945 Sep 23 - 7:30 - WIT 1948 May - 8:00 - WIT 1950 May - 7:30 - WIT 1964 - 8:00 - CIT 1988 Jan 1 - 7:00 - WIT + 7:30 - WIB 1948 May + 8:00 - WIB 1950 May + 7:30 - WIB 1964 + 8:00 - WITA 1988 Jan 1 + 7:00 - WIB +# Sulawesi, Lesser Sundas, east and south Borneo Zone Asia/Makassar 7:57:36 - LMT 1920 7:57:36 - MMT 1932 Nov # Macassar MT - 8:00 - CIT 1942 Feb 9 + 8:00 - WITA 1942 Feb 9 9:00 - JST 1945 Sep 23 - 8:00 - CIT + 8:00 - WITA +# Maluku Islands, West Papua, Papua Zone Asia/Jayapura 9:22:48 - LMT 1932 Nov - 9:00 - EIT 1944 Sep 1 + 9:00 - WIT 1944 Sep 1 9:30 - CST 1964 - 9:00 - EIT + 9:00 - WIT # Iran @@ -1387,9 +1404,11 @@ Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u # until about the same time next year (at least). # http://www.petra.gov.jo/Public_News/Nws_NewsDetails.aspx?NewsID=88950 # -# From Paul Eggert (2012-10-25): -# For now, assume this is just a one-year measure. If it becomes -# permanent, we should move Jordan from EET to AST effective tomorrow. +# From Paul Eggert (2013-09-21): +# It's looking like this change will be permanent; see +# Petra News Agency, Cancelling winter saved Jordan $7 million (2013-02-20) +# . +# So move Jordan to UTC+3 as of the abovementioned date. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Jordan 1973 only - Jun 6 0:00 1:00 S @@ -1415,15 +1434,15 @@ Rule Jordan 1995 1998 - Sep Fri>=15 0:00s 0 - Rule Jordan 1999 only - Jul 1 0:00s 1:00 S Rule Jordan 1999 2002 - Sep lastFri 0:00s 0 - Rule Jordan 2000 2001 - Mar lastThu 0:00s 1:00 S -Rule Jordan 2002 max - Mar lastThu 24:00 1:00 S +Rule Jordan 2002 2012 - Mar lastThu 24:00 1:00 S Rule Jordan 2003 only - Oct 24 0:00s 0 - Rule Jordan 2004 only - Oct 15 0:00s 0 - Rule Jordan 2005 only - Sep lastFri 0:00s 0 - -Rule Jordan 2006 2011 - Oct lastFri 0:00s 0 - -Rule Jordan 2013 max - Oct lastFri 0:00s 0 - +Rule Jordan 2006 2012 - Oct lastFri 0:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Amman 2:23:44 - LMT 1931 - 2:00 Jordan EE%sT + 2:00 Jordan EE%sT 2012 Oct 26 0:00s + 3:00 - AST # Kazakhstan @@ -2303,9 +2322,18 @@ Zone Asia/Karachi 4:28:12 - LMT 1907 # http://www.samanews.com/index.php?act=Show&id=154120 # http://safa.ps/details/news/99844/%D8%B1%D8%A7%D9%85-%D8%A7%D9%84%D9%84%D9%87-%D8%A8%D8%AF%D8%A1-%D8%A7%D9%84%D8%AA%D9%88%D9%82%D9%8A%D8%AA-%D8%A7%D9%84%D8%B5%D9%8A%D9%81%D9%8A-29-%D8%A7%D9%84%D8%AC%D8%A7%D8%B1%D9%8A.html -# From Paul Eggert (2013-04-15): +# From Steffen Thorsen (2013-09-24): +# The Gaza and West Bank are ending DST Thursday at midnight +# (2013-09-27 00:00:00) (one hour earlier than last year...). +# This source in English, says "that winter time will go into effect +# at midnight on Thursday in the West Bank and Gaza Strip": +# http://english.wafa.ps/index.php?action=detail&id=23246 +# official source...: +# http://www.palestinecabinet.gov.ps/ar/Views/ViewDetails.aspx?pid=1252 + +# From Paul Eggert (2013-09-24): # For future dates, guess the last Thursday in March at 24:00 through -# the first Friday on or after September 21 at 01:00. This is consistent with +# the first Friday on or after September 21 at 00:00. This is consistent with # the predictions in today's editions of the following URLs, # which are for Gaza and Hebron respectively: # http://www.timeanddate.com/worldclock/timezone.html?n=702 @@ -2336,7 +2364,8 @@ Rule Palestine 2011 only - Aug 1 0:00 0 - Rule Palestine 2011 only - Aug 30 0:00 1:00 S Rule Palestine 2011 only - Sep 30 0:00 0 - Rule Palestine 2012 max - Mar lastThu 24:00 1:00 S -Rule Palestine 2012 max - Sep Fri>=21 1:00 0 - +Rule Palestine 2012 only - Sep 21 1:00 0 - +Rule Palestine 2013 max - Sep Fri>=21 0:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Gaza 2:17:52 - LMT 1900 Oct diff --git a/test/sun/util/calendar/zi/tzdata/australasia b/test/sun/util/calendar/zi/tzdata/australasia index 11a3cb97f..cd6b72485 100644 --- a/test/sun/util/calendar/zi/tzdata/australasia +++ b/test/sun/util/calendar/zi/tzdata/australasia @@ -375,16 +375,25 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 # today confirmed that Fiji will start daylight savings at 2 am on Sunday 21st # October 2012 and end at 3 am on Sunday 20th January 2013. # http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=6702&catid=71&Itemid=155 + +# From the Fijian Government Media Center (2013-08-30) via David Wheeler: +# Fiji will start daylight savings on Sunday 27th October, 2013 and end at 3am +# on Sunday 19th January, 2014.... move clocks forward by one hour from 2am +# http://www.fiji.gov.fj/Media-Center/Press-Releases/DAYLIGHT-SAVING-STARTS-ON-SUNDAY,-27th-OCTOBER-201.aspx # -# From Paul Eggert (2012-08-31): -# For now, guess a pattern of the penultimate Sundays in October and January. +# From Paul Eggert (2013-09-09): +# For now, guess that Fiji springs forward the Sunday before the fourth +# Monday in October. This matches both recent practice and +# timeanddate.com's current spring-forward prediction. +# For the January 2014 transition we guessed right while timeanddate.com +# guessed wrong, so leave the fall-back prediction alone. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 S Rule Fiji 1999 2000 - Feb lastSun 3:00 0 - Rule Fiji 2009 only - Nov 29 2:00 1:00 S Rule Fiji 2010 only - Mar lastSun 3:00 0 - -Rule Fiji 2010 max - Oct Sun>=18 2:00 1:00 S +Rule Fiji 2010 max - Oct Sun>=21 2:00 1:00 S Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - Rule Fiji 2012 max - Jan Sun>=18 3:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -510,6 +519,7 @@ Zone Pacific/Auckland 11:39:04 - LMT 1868 Nov 2 Zone Pacific/Chatham 12:13:48 - LMT 1957 Jan 1 12:45 Chatham CHA%sT +Link Pacific/Auckland Antarctica/McMurdo # Auckland Is # uninhabited; Maori and Moriori, colonial settlers, pastoralists, sealers, @@ -759,7 +769,7 @@ Zone Pacific/Funafuti 11:56:52 - LMT 1901 # 1886-1891; Baker was similar but exact dates are not known. # Inhabited by civilians 1935-1942; U.S. military bases 1943-1944; # uninhabited thereafter. -# Howland observed Hawaii Standard Time (UTC-10:30) in 1937; +# Howland observed Hawaii Standard Time (UT-10:30) in 1937; # see page 206 of Elgen M. Long and Marie K. Long, # Amelia Earhart: the Mystery Solved, Simon & Schuster (2000). # So most likely Howland and Baker observed Hawaii Time from 1935 @@ -772,8 +782,17 @@ Zone Pacific/Funafuti 11:56:52 - LMT 1901 # no information; was probably like Pacific/Kiritimati # Johnston -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Pacific/Johnston -10:00 - HST +# +# From Paul Eggert (2013-09-03): +# In his memoirs of June 6th to October 4, 1945 +# (2005), Herbert C. Bach writes, +# "We started our letdown to Kwajalein Atoll and landed there at 5:00 AM +# Johnston time, 1:30 AM Kwajalein time." This was in June 1945, and +# confirms that Johnston kept the same time as Honolulu in summer 1945. +# We have no better information, so for now, assume this has been true +# indefinitely into the past. +# +# See 'northamerica' for Pacific/Johnston. # Kingman # uninhabited diff --git a/test/sun/util/calendar/zi/tzdata/backward b/test/sun/util/calendar/zi/tzdata/backward index ca4c437a1..5afe9a317 100644 --- a/test/sun/util/calendar/zi/tzdata/backward +++ b/test/sun/util/calendar/zi/tzdata/backward @@ -45,15 +45,17 @@ Link America/Kentucky/Louisville America/Louisville Link America/Argentina/Mendoza America/Mendoza Link America/Rio_Branco America/Porto_Acre Link America/Argentina/Cordoba America/Rosario -Link America/St_Thomas America/Virgin +Link America/Denver America/Shiprock +Link America/Port_of_Spain America/Virgin +Link Pacific/Auckland Antarctica/South_Pole Link Asia/Ashgabat Asia/Ashkhabad +Link Asia/Kolkata Asia/Calcutta Link Asia/Chongqing Asia/Chungking Link Asia/Dhaka Asia/Dacca Link Asia/Kathmandu Asia/Katmandu -Link Asia/Kolkata Asia/Calcutta Link Asia/Macau Asia/Macao -Link Asia/Jerusalem Asia/Tel_Aviv Link Asia/Ho_Chi_Minh Asia/Saigon +Link Asia/Jerusalem Asia/Tel_Aviv Link Asia/Thimphu Asia/Thimbu Link Asia/Makassar Asia/Ujung_Pandang Link Asia/Ulaanbaatar Asia/Ulan_Bator @@ -111,10 +113,10 @@ Link Pacific/Auckland NZ Link Pacific/Chatham NZ-CHAT Link America/Denver Navajo Link Asia/Shanghai PRC +Link Pacific/Pohnpei Pacific/Ponape Link Pacific/Pago_Pago Pacific/Samoa -Link Pacific/Chuuk Pacific/Yap Link Pacific/Chuuk Pacific/Truk -Link Pacific/Pohnpei Pacific/Ponape +Link Pacific/Chuuk Pacific/Yap Link Europe/Warsaw Poland Link Europe/Lisbon Portugal Link Asia/Taipei ROC diff --git a/test/sun/util/calendar/zi/tzdata/etcetera b/test/sun/util/calendar/zi/tzdata/etcetera index d557e3033..ebaa5fdfc 100644 --- a/test/sun/util/calendar/zi/tzdata/etcetera +++ b/test/sun/util/calendar/zi/tzdata/etcetera @@ -54,9 +54,9 @@ Link Etc/GMT Etc/GMT0 # even though this is the opposite of what many people expect. # POSIX has positive signs west of Greenwich, but many people expect # positive signs east of Greenwich. For example, TZ='Etc/GMT+4' uses -# the abbreviation "GMT+4" and corresponds to 4 hours behind UTC +# the abbreviation "GMT+4" and corresponds to 4 hours behind UT # (i.e. west of Greenwich) even though many people would expect it to -# mean 4 hours ahead of UTC (i.e. east of Greenwich). +# mean 4 hours ahead of UT (i.e. east of Greenwich). # # In the draft 5 of POSIX 1003.1-200x, the angle bracket notation allows for # TZ='+4'; if you want time zone abbreviations conforming to diff --git a/test/sun/util/calendar/zi/tzdata/europe b/test/sun/util/calendar/zi/tzdata/europe index 688136c80..9f574a3b2 100644 --- a/test/sun/util/calendar/zi/tzdata/europe +++ b/test/sun/util/calendar/zi/tzdata/europe @@ -65,7 +65,7 @@ # (1998-09-21, in Portuguese) # -# I invented the abbreviations marked `*' in the following table; +# I invented the abbreviations marked '*' in the following table; # the rest are from earlier versions of this file, or from other sources. # Corrections are welcome! # std dst 2dst @@ -119,7 +119,7 @@ # and a sketch map showing some of the sightlines involved. One paragraph # of the text said: # -# `An old stone obelisk marking a forgotten terrestrial meridian stands +# 'An old stone obelisk marking a forgotten terrestrial meridian stands # beside the river at Kew. In the 18th century, before time and longitude # was standardised by the Royal Observatory in Greenwich, scholars observed # this stone and the movement of stars from Kew Observatory nearby. They @@ -163,7 +163,7 @@ # From Paul Eggert (2003-09-27): # Summer Time was first seriously proposed by William Willett (1857-1915), # a London builder and member of the Royal Astronomical Society -# who circulated a pamphlet ``The Waste of Daylight'' (1907) +# who circulated a pamphlet "The Waste of Daylight" (1907) # that proposed advancing clocks 20 minutes on each of four Sundays in April, # and retarding them by the same amount on four Sundays in September. # A bill was drafted in 1909 and introduced in Parliament several times, @@ -188,10 +188,10 @@ # # From Paul Eggert (1996-09-03): -# The OED Supplement says that the English originally said ``Daylight Saving'' +# The OED Supplement says that the English originally said "Daylight Saving" # when they were debating the adoption of DST in 1908; but by 1916 this # term appears only in quotes taken from DST's opponents, whereas the -# proponents (who eventually won the argument) are quoted as using ``Summer''. +# proponents (who eventually won the argument) are quoted as using "Summer". # From Arthur David Olson (1989-01-19): # @@ -231,9 +231,9 @@ # which could not be said to run counter to any official description. # From Paul Eggert (2000-10-02): -# Howse writes (p 157) `DBST' too, but `BDST' seems to have been common +# Howse writes (p 157) 'DBST' too, but 'BDST' seems to have been common # and follows the more usual convention of putting the location name first, -# so we use `BDST'. +# so we use 'BDST'. # Peter Ilieve (1998-04-19) described at length # the history of summer time legislation in the United Kingdom. @@ -454,6 +454,8 @@ Rule GB-Eire 1981 1989 - Oct Sun>=23 1:00u 0 GMT Rule GB-Eire 1990 1995 - Oct Sun>=22 1:00u 0 GMT # Summer Time Order 1997 (S.I. 1997/2982) # See EU for rules starting in 1996. +# +# Use Europe/London for Jersey, Guernsey, and the Isle of Man. # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/London -0:01:15 - LMT 1847 Dec 1 0:00s @@ -820,7 +822,7 @@ Zone Europe/Brussels 0:17:30 - LMT 1880 1:00 EU CE%sT # Bosnia and Herzegovina -# see Serbia +# See Europe/Belgrade. # Bulgaria # @@ -848,10 +850,10 @@ Zone Europe/Sofia 1:33:16 - LMT 1880 2:00 EU EE%sT # Croatia -# see Serbia +# See Europe/Belgrade. # Cyprus -# Please see the `asia' file for Asia/Nicosia. +# Please see the 'asia' file for Asia/Nicosia. # Czech Republic # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -868,6 +870,7 @@ Zone Europe/Prague 0:57:44 - LMT 1850 1:00 C-Eur CE%sT 1944 Sep 17 2:00s 1:00 Czech CE%sT 1979 1:00 EU CE%sT +# Use Europe/Prague also for Slovakia. # Denmark, Faroe Islands, and Greenland @@ -1031,12 +1034,12 @@ Zone America/Thule -4:35:08 - LMT 1916 Jul 28 # Pituffik air base # From Peter Ilieve (1996-10-28): # [IATA SSIM (1992/1996) claims that the Baltic republics switch at 01:00s, # but a relative confirms that Estonia still switches at 02:00s, writing:] -# ``I do not [know] exactly but there are some little different +# "I do not [know] exactly but there are some little different # (confusing) rules for International Air and Railway Transport Schedules # conversion in Sunday connected with end of summer time in Estonia.... # A discussion is running about the summer time efficiency and effect on # human physiology. It seems that Estonia maybe will not change to -# summer time next spring.'' +# summer time next spring." # From Peter Ilieve (1998-11-04), heavily edited: # @@ -1091,7 +1094,7 @@ Zone Europe/Tallinn 1:39:00 - LMT 1880 # Well, here in Helsinki we're just changing from summer time to regular one, # and it's supposed to change at 4am... -# From Janne Snabb (2010-0715): +# From Janne Snabb (2010-07-15): # # I noticed that the Finland data is not accurate for years 1981 and 1982. # During these two first trial years the DST adjustment was made one hour @@ -1148,7 +1151,7 @@ Link Europe/Helsinki Europe/Mariehamn # -# Shank & Pottenger seem to use `24:00' ambiguously; resolve it with Whitman. +# Shank & Pottenger seem to use '24:00' ambiguously; resolve it with Whitman. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule France 1916 only - Jun 14 23:00s 1:00 S Rule France 1916 1919 - Oct Sun>=1 23:00s 0 - @@ -1438,7 +1441,7 @@ Zone Atlantic/Reykjavik -1:27:24 - LMT 1837 # # Day-light Saving Time in Italy (2006-02-03) # -# (`FP' below), taken from an Italian National Electrotechnical Institute +# ('FP' below), taken from an Italian National Electrotechnical Institute # publication. When the three sources disagree, guess who's right, as follows: # # year FP Shanks&P. (S) Whitman (W) Go with: @@ -1584,10 +1587,22 @@ Zone Europe/Riga 1:36:24 - LMT 1880 2:00 EU EE%sT # Liechtenstein -# Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Vaduz 0:38:04 - LMT 1894 Jun - 1:00 - CET 1981 - 1:00 EU CE%sT + +# From Paul Eggert (2013-09-09): +# Shanks & Pottenger say Vaduz is like Zurich. + +# From Alois Treindl (2013-09-18): +# http://www.eliechtensteinensia.li/LIJ/1978/1938-1978/1941.pdf +# ... confirms on p. 6 that Liechtenstein followed Switzerland in 1941 and 1942. +# I ... translate only the last two paragraphs: +# ... during second world war, in the years 1941 and 1942, Liechtenstein +# introduced daylight saving time, adapting to Switzerland. From 1943 on +# central European time was in force throughout the year. +# From a report of the duke's government to the high council, +# regarding the introduction of a time law, of 31 May 1977. + +Link Europe/Zurich Europe/Vaduz + # Lithuania @@ -1675,7 +1690,7 @@ Zone Europe/Luxembourg 0:24:36 - LMT 1904 Jun 1:00 EU CE%sT # Macedonia -# see Serbia +# See Europe/Belgrade. # Malta # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -1768,7 +1783,7 @@ Zone Europe/Monaco 0:29:32 - LMT 1891 Mar 15 1:00 EU CE%sT # Montenegro -# see Serbia +# See Europe/Belgrade. # Netherlands @@ -1883,7 +1898,7 @@ Zone Europe/Oslo 0:43:00 - LMT 1895 Jan 1 # before 1895, and therefore probably changed the local time somewhere # between 1895 and 1925 (inclusive). -# From Paul Eggert (2001-05-01): +# From Paul Eggert (2013-09-04): # # Actually, Jan Mayen was never occupied by Germany during World War II, # so it must have diverged from Oslo time during the war, as Oslo was @@ -1894,7 +1909,7 @@ Zone Europe/Oslo 0:43:00 - LMT 1895 Jan 1 # 1941 with a small Norwegian garrison and continued operations despite # frequent air ttacks from Germans. In 1943 the Americans established a # radiolocating station on the island, called "Atlantic City". Possibly -# the UTC offset changed during the war, but I think it unlikely that +# the UT offset changed during the war, but I think it unlikely that # Jan Mayen used German daylight-saving rules. # # Svalbard is more complicated, as it was raided in August 1941 by an @@ -1907,9 +1922,8 @@ Zone Europe/Oslo 0:43:00 - LMT 1895 Jan 1 # the German armed forces at the Svalbard weather station code-named # Haudegen did not surrender to the Allies until September 1945. # -# All these events predate our cutoff date of 1970. Unless we can -# come up with more definitive info about the timekeeping during the -# war years it's probably best just do...the following for now: +# All these events predate our cutoff date of 1970, so use Europe/Oslo +# for these regions. Link Europe/Oslo Arctic/Longyearbyen # Poland @@ -2167,7 +2181,7 @@ Zone Europe/Bucharest 1:44:24 - LMT 1891 Oct # so we (Novosibirsk) simply did not switch. # # From Andrey A. Chernov (1996-10-04): -# `MSK' and `MSD' were born and used initially on Moscow computers with +# 'MSK' and 'MSD' were born and used initially on Moscow computers with # UNIX-like OSes by several developer groups (e.g. Demos group, Kiae group).... # The next step was the UUCP network, the Relcom predecessor # (used mainly for mail), and MSK/MSD was actively used there. @@ -2466,6 +2480,9 @@ Zone Asia/Anadyr 11:49:56 - LMT 1924 May 2 11:00 Russia ANA%sT 2011 Mar 27 2:00s 12:00 - ANAT +# San Marino +# See Europe/Rome. + # Serbia # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Europe/Belgrade 1:22:00 - LMT 1884 @@ -2488,7 +2505,7 @@ Link Europe/Belgrade Europe/Zagreb # Croatia Link Europe/Prague Europe/Bratislava # Slovenia -# see Serbia +# See Europe/Belgrade. # Spain # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S @@ -2622,7 +2639,7 @@ Zone Europe/Stockholm 1:12:12 - LMT 1879 Jan 1 # and their performance improved enormously. Communities began to keep # mean time in preference to apparent time -- Geneva from 1780 .... # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S -# From Whitman (who writes ``Midnight?''): +# From Whitman (who writes "Midnight?"): # Rule Swiss 1940 only - Nov 2 0:00 1:00 S # Rule Swiss 1940 only - Dec 31 0:00 0 - # From Shanks & Pottenger: @@ -2667,23 +2684,53 @@ Zone Europe/Stockholm 1:12:12 - LMT 1879 Jan 1 # The 1940 rules must be deleted. # # One further detail for Switzerland, which is probably out of scope for -# most users of tzdata: -# The zone file -# Zone Europe/Zurich 0:34:08 - LMT 1848 Sep 12 -# 0:29:44 - BMT 1894 Jun #Bern Mean Time -# 1:00 Swiss CE%sT 1981 -# 1:00 EU CE%sT +# most users of tzdata: The [Europe/Zurich zone] ... # describes all of Switzerland correctly, with the exception of # the Cantone Geneve (Geneva, Genf). Between 1848 and 1894 Geneve did not # follow Bern Mean Time but kept its own local mean time. # To represent this, an extra zone would be needed. +# +# From Alois Treindl (2013-09-11): +# The Federal regulations say +# http://www.admin.ch/opc/de/classified-compilation/20071096/index.html +# ... the meridian for Bern mean time ... is 7 degrees 26'22.50". +# Expressed in time, it is 0h29m45.5s. + +# From Pierre-Yves Berger (2013-09-11): +# the "Circulaire du conseil federal" (December 11 1893) +# ... +# clearly states that the [1894-06-01] change should be done at midnight +# but if no one is present after 11 at night, could be postponed until one +# hour before the beginning of service. + +# From Paul Eggert (2013-09-11): +# Round BMT to the nearest even second, 0:29:46. +# +# We can find no reliable source for Shanks's assertion that all of Switzerland +# except Geneva switched to Bern Mean Time at 00:00 on 1848-09-12. This book: +# +# Jakob Messerli. Gleichmassig, punktlich, schnell: Zeiteinteilung und +# Zeitgebrauch in der Schweiz im 19. Jahrhundert. Chronos, Zurich 1995, +# ISBN 3-905311-68-2, OCLC 717570797. +# +# suggests that the transition was more gradual, and that the Swiss did not +# agree about civil time during the transition. The timekeeping it gives the +# most detail for is postal and telegraph time: here, federal legislation (the +# "Bundesgesetz uber die Erstellung von elektrischen Telegraphen") passed on +# 1851-11-23, and an official implementation notice was published 1853-07-16 +# (Bundesblatt 1853, Bd. II, S. 859). On p 72 Messerli writes that in +# practice since July 1853 Bernese time was used in "all postal and telegraph +# offices in Switzerland from Geneva to St. Gallen and Basel to Chiasso" +# (Google translation). For now, model this transition as occurring on +# 1853-07-16, though it probably occurred at some other date in Zurich, and +# legal civil time probably changed at still some other transition date. # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S Rule Swiss 1941 1942 - May Mon>=1 1:00 1:00 S Rule Swiss 1941 1942 - Oct Mon>=1 2:00 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] -Zone Europe/Zurich 0:34:08 - LMT 1848 Sep 12 - 0:29:44 - BMT 1894 Jun # Bern Mean Time +Zone Europe/Zurich 0:34:08 - LMT 1853 Jul 16 # See above comment. + 0:29:46 - BMT 1894 Jun # Bern Mean Time 1:00 Swiss CE%sT 1981 1:00 EU CE%sT @@ -2907,7 +2954,7 @@ Zone Europe/Simferopol 2:16:24 - LMT 1880 # From Paul Eggert (2006-03-22): # The _Economist_ (1994-05-28, p 45) reports that central Crimea switched # from Kiev to Moscow time sometime after the January 1994 elections. -# Shanks (1999) says ``date of change uncertain'', but implies that it happened +# Shanks (1999) says "date of change uncertain", but implies that it happened # sometime between the 1994 DST switches. Shanks & Pottenger simply say # 1994-09-25 03:00, but that can't be right. For now, guess it # changed in May. @@ -2921,6 +2968,9 @@ Zone Europe/Simferopol 2:16:24 - LMT 1880 3:00 - MSK 1997 Mar lastSun 1:00u 2:00 EU EE%sT +# Vatican City +# See Europe/Rome. + ############################################################################### # One source shows that Bulgaria, Cyprus, Finland, and Greece observe DST from diff --git a/test/sun/util/calendar/zi/tzdata/iso3166.tab b/test/sun/util/calendar/zi/tzdata/iso3166.tab index c6b2d0af3..28fb64b64 100644 --- a/test/sun/util/calendar/zi/tzdata/iso3166.tab +++ b/test/sun/util/calendar/zi/tzdata/iso3166.tab @@ -32,7 +32,7 @@ # 1. ISO 3166-1 alpha-2 country code, current as of # ISO 3166-1 Newsletter VI-15 (2013-05-10). See: Updates on ISO 3166 # http://www.iso.org/iso/home/standards/country_codes/updates_on_iso_3166.htm -# 2. The usual English name for the country, +# 2. The usual English name for the coded region, # chosen so that alphabetic sorting of subsets produces helpful lists. # This is not the same as the English name in the ISO 3166 tables. # @@ -46,7 +46,7 @@ # to take or endorse any position on legal or territorial claims. # #country- -#code country name +#code name of country, territory, area, or subdivision AD Andorra AE United Arab Emirates AF Afghanistan @@ -76,7 +76,7 @@ BL St Barthelemy BM Bermuda BN Brunei BO Bolivia -BQ Bonaire, St Eustatius & Saba +BQ Caribbean Netherlands BR Brazil BS Bahamas BT Bhutan diff --git a/test/sun/util/calendar/zi/tzdata/leapseconds b/test/sun/util/calendar/zi/tzdata/leapseconds index 912801227..faf5319d4 100644 --- a/test/sun/util/calendar/zi/tzdata/leapseconds +++ b/test/sun/util/calendar/zi/tzdata/leapseconds @@ -20,18 +20,24 @@ # 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 in the public domain, so clarified as of
-# 2009-05-17 by Arthur David Olson.
 
 # Allowance for leapseconds added to each timezone file.
 
+# This file is in the public domain.
+
+# This file is generated automatically from the data in the public-domain
+# leap-seconds.list file available from most NIST time servers.
+# If the URL  does not work,
+# you should be able to pick up leap-seconds.list from a secondary NIST server.
+# For more about leap-seconds.list, please see
+# The NTP Timescale and Leap Seconds
+# .
+
 # The International Earth Rotation Service periodically uses leap seconds
 # to keep UTC to within 0.9 s of UT1
 # (which measures the true angular orientation of the earth in space); see
 # Terry J Quinn, The BIPM and the accurate measure of time,
-# Proc IEEE 79, 7 (July 1991), 894-905.
+# Proc IEEE 79, 7 (July 1991), 894-905 .
 # There were no leap seconds before 1972, because the official mechanism
 # accounting for the discrepancy between atomic time and the earth's rotation
 # did not exist until the early 1970s.
@@ -42,8 +48,8 @@
 # or
 #	Leap	YEAR	MON	DAY	23:59:59	-	R/S
 
-# If the leapsecond is Rolling (R) the given time is local time
-# If the leapsecond is Stationary (S) the given time is UTC
+# If the leapsecond is Rolling (R) the given time is local time.
+# If the leapsecond is Stationary (S) the given time is UTC.
 
 # Leap	YEAR	MONTH	DAY	HH:MM:SS	CORR	R/S
 Leap	1972	Jun	30	23:59:60	+	S
@@ -71,53 +77,3 @@ Leap	1998	Dec	31	23:59:60	+	S
 Leap	2005	Dec	31	23:59:60	+	S
 Leap	2008	Dec	31	23:59:60	+	S
 Leap	2012	Jun	30	23:59:60	+	S
-
-# INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS)
-#
-# SERVICE INTERNATIONAL DE LA ROTATION TERRESTRE ET DES SYSTEMES DE REFERENCE
-#
-#
-# SERVICE DE LA ROTATION TERRESTRE
-# OBSERVATOIRE DE PARIS
-# 61, Av. de l'Observatoire 75014 PARIS (France)
-# Tel.      : 33 (0) 1 40 51 22 26
-# FAX       : 33 (0) 1 40 51 22 91
-# e-mail    : (E-Mail Removed)
-# http://hpiers.obspm.fr/eop-pc
-#
-# Paris, 5 January 2012
-#
-#
-# Bulletin C 43
-#
-# To authorities responsible
-# for the measurement and
-# distribution of time
-#
-#
-# UTC TIME STEP
-# on the 1st of July 2012
-#
-#
-# A positive leap second will be introduced at the end of June 2012.
-# The sequence of dates of the UTC second markers will be:
-#
-#                          2012 June 30,     23h 59m 59s
-#                          2012 June 30,     23h 59m 60s
-#                          2012 July  1,      0h  0m  0s
-#
-# The difference between UTC and the International Atomic Time TAI is:
-#
-# from 2009 January 1, 0h UTC, to 2012 July 1  0h UTC  : UTC-TAI = - 34s
-# from 2012 July 1,    0h UTC, until further notice    : UTC-TAI = - 35s
-#
-# Leap seconds can be introduced in UTC at the end of the months of December
-# or June, depending on the evolution of UT1-TAI. Bulletin C is mailed every
-# six months, either to announce a time step in UTC or to confirm that there
-# will be no time step at the next possible date.
-#
-#
-# Daniel GAMBIS
-# Head
-# Earth Orientation Center of IERS
-# Observatoire de Paris, France
diff --git a/test/sun/util/calendar/zi/tzdata/northamerica b/test/sun/util/calendar/zi/tzdata/northamerica
index 43a0b2250..b8caf6d01 100644
--- a/test/sun/util/calendar/zi/tzdata/northamerica
+++ b/test/sun/util/calendar/zi/tzdata/northamerica
@@ -43,7 +43,7 @@
 # Howse writes (pp 121-125) that time zones were invented by
 # Professor Charles Ferdinand Dowd (1825-1904),
 # Principal of Temple Grove Ladies' Seminary (Saratoga Springs, NY).
-# His pamphlet ``A System of National Time for Railroads'' (1870)
+# His pamphlet "A System of National Time for Railroads" (1870)
 # was the result of his proposals at the Convention of Railroad Trunk Lines
 # in New York City (1869-10).  His 1870 proposal was based on Washington, DC,
 # but in 1872-05 he moved the proposed origin to Greenwich.
@@ -63,8 +63,8 @@
 
 # From Paul Eggert (2001-03-06):
 # Daylight Saving Time was first suggested as a joke by Benjamin Franklin
-# in his whimsical essay ``An Economical Project for Diminishing the Cost
-# of Light'' published in the Journal de Paris (1784-04-26).
+# in his whimsical essay "An Economical Project for Diminishing the Cost
+# of Light" published in the Journal de Paris (1784-04-26).
 # Not everyone is happy with the results:
 #
 #	I don't really care how time is reckoned so long as there is some
@@ -190,8 +190,8 @@ Zone	PST8PDT		 -8:00	US	P%sT
 #    of the Aleutian islands.   No DST.
 
 # From Paul Eggert (1995-12-19):
-# The tables below use `NST', not `NT', for Nome Standard Time.
-# I invented `CAWT' for Central Alaska War Time.
+# The tables below use 'NST', not 'NT', for Nome Standard Time.
+# I invented 'CAWT' for Central Alaska War Time.
 
 # From U. S. Naval Observatory (1989-01-19):
 # USA  EASTERN       5 H  BEHIND UTC    NEW YORK, WASHINGTON
@@ -260,9 +260,9 @@ Zone	PST8PDT		 -8:00	US	P%sT
 # H.R. 6, Energy Policy Act of 2005, SEC. 110. DAYLIGHT SAVINGS.
 #   (a) Amendment- Section 3(a) of the Uniform Time Act of 1966 (15
 #   U.S.C. 260a(a)) is amended--
-#     (1) by striking `first Sunday of April' and inserting `second
+#     (1) by striking 'first Sunday of April' and inserting 'second
 #     Sunday of March'; and
-#     (2) by striking `last Sunday of October' and inserting `first
+#     (2) by striking 'last Sunday of October' and inserting 'first
 #     Sunday of November'.
 #   (b) Effective Date- Subsection (a) shall take effect 1 year after the
 #   date of enactment of this Act or March 1, 2007, whichever is later.
@@ -623,6 +623,8 @@ Zone Pacific/Honolulu	-10:31:26 -	LMT	1896 Jan 13 12:00 #Schmitt&Cox
 			-10:30	-	HST	1947 Jun  8 2:00 #Schmitt&Cox+2
 			-10:00	-	HST
 
+Link Pacific/Honolulu Pacific/Johnston
+
 # Now we turn to US areas that have diverged from the consensus since 1970.
 
 # Arizona mostly uses MST.
@@ -659,8 +661,9 @@ Zone America/Phoenix	-7:28:18 -	LMT	1883 Nov 18 11:31:42
 # Navajo Nation participates in the Daylight Saving Time policy, due to its
 # large size and location in three states."  (The "only" means that other
 # tribal nations don't use DST.)
-
-Link America/Denver America/Shiprock
+#
+# From Paul Eggert (2013-08-26):
+# See America/Denver for a zone appropriate for the Navajo Nation.
 
 # Southern Idaho (Ada, Adams, Bannock, Bear Lake, Bingham, Blaine,
 # Boise, Bonneville, Butte, Camas, Canyon, Caribou, Cassia, Clark,
@@ -700,13 +703,13 @@ Zone America/Boise	-7:44:49 -	LMT	1883 Nov 18 12:15:11
 #   and Switzerland counties have their own time zone histories as noted below.
 #
 # Shanks partitioned Indiana into 345 regions, each with its own time history,
-# and wrote ``Even newspaper reports present contradictory information.''
+# and wrote "Even newspaper reports present contradictory information."
 # Those Hoosiers!  Such a flighty and changeable people!
 # Fortunately, most of the complexity occurred before our cutoff date of 1970.
 #
 # Other than Indianapolis, the Indiana place names are so nondescript
-# that they would be ambiguous if we left them at the `America' level.
-# So we reluctantly put them all in a subdirectory `America/Indiana'.
+# that they would be ambiguous if we left them at the 'America' level.
+# So we reluctantly put them all in a subdirectory 'America/Indiana'.
 
 # From Paul Eggert (2005-08-16):
 # http://www.mccsc.edu/time.html says that Indiana will use DST starting 2006.
@@ -970,8 +973,8 @@ Zone America/Kentucky/Monticello -5:39:24 - LMT	1883 Nov 18 12:20:36
 # This story is too entertaining to be false, so go with Howse over Shanks.
 #
 # From Paul Eggert (2001-03-06):
-# Garland (1927) writes ``Cleveland and Detroit advanced their clocks
-# one hour in 1914.''  This change is not in Shanks.  We have no more
+# Garland (1927) writes "Cleveland and Detroit advanced their clocks
+# one hour in 1914."  This change is not in Shanks.  We have no more
 # info, so omit this for now.
 #
 # Most of Michigan observed DST from 1973 on, but was a bit late in 1975.
@@ -1011,7 +1014,7 @@ Zone America/Menominee	-5:50:27 -	LMT	1885 Sep 18 12:00
 # occupied 1857/1900 by the Navassa Phosphate Co
 # US lighthouse 1917/1996-09
 # currently uninhabited
-# see Mark Fineman, ``An Isle Rich in Guano and Discord'',
+# see Mark Fineman, "An Isle Rich in Guano and Discord",
 # _Los Angeles Times_ (1998-11-10), A1, A10; it cites
 # Jimmy Skaggs, _The Great Guano Rush_ (1994).
 
@@ -1045,7 +1048,7 @@ Zone America/Menominee	-5:50:27 -	LMT	1885 Sep 18 12:00
 #	Milne J. Civil time. Geogr J. 1899 Feb;13(2):173-94
 #	.
 #
-# See the `europe' file for Greenland.
+# See the 'europe' file for Greenland.
 
 # Canada
 
@@ -1246,7 +1249,7 @@ Zone America/St_Johns	-3:30:52 -	LMT	1884
 
 # most of east Labrador
 
-# The name `Happy Valley-Goose Bay' is too long; use `Goose Bay'.
+# The name 'Happy Valley-Goose Bay' is too long; use 'Goose Bay'.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Goose_Bay	-4:01:40 -	LMT	1884 # Happy Valley-Goose Bay
 			-3:30:52 -	NST	1918
@@ -1363,25 +1366,27 @@ Zone America/Moncton	-4:19:08 -	LMT	1883 Dec  9
 
 # Quebec
 
-# From Paul Eggert (2006-07-09):
-# Shanks & Pottenger write that since 1970 most of Quebec has been
-# like Montreal.
+# From Paul Eggert (2013-08-30):
+# Since 1970 most of Quebec has been like Toronto.
+# However, because earlier versions of the tz database mistakenly relied on data
+# from Shanks & Pottenger saying that Quebec differed from Ontario after 1970,
+# a separate entry was created for most of Quebec.  We're loath to lose
+# its pre-1970 info, even though the tz database is normally limited to
+# zones that differ after 1970, so keep this otherwise out-of-scope entry.
 
-# From Paul Eggert (2006-06-27):
 # Matthews and Vincent (1998) also write that Quebec east of the -63
 # meridian is supposed to observe AST, but residents as far east as
 # Natashquan use EST/EDT, and residents east of Natashquan use AST.
-# In "Official time in Quebec" the Quebec department of justice writes in
-# http://www.justice.gouv.qc.ca/english/publications/generale/temps-regl-1-a.htm
-# that "The residents of the Municipality of the
-# Cote-Nord-du-Golfe-Saint-Laurent and the municipalities of Saint-Augustin,
-# Bonne-Esperance and Blanc-Sablon apply the Official Time Act as it is
-# written and use Atlantic standard time all year round. The same applies to
-# the residents of the Native facilities along the lower North Shore."
-# 
+# The Quebec department of justice writes in
+# "The situation in Minganie and Basse-Cote-Nord"
+# http://www.justice.gouv.qc.ca/english/publications/generale/temps-minganie-a.htm
+# that the coastal strip from just east of Natashquan to Blanc-Sablon
+# observes Atlantic standard time all year round.
+# http://www.assnat.qc.ca/Media/Process.aspx?MediaId=ANQ.Vigie.Bll.DocumentGenerique_8845en
 # says this common practice was codified into law as of 2007.
 # For lack of better info, guess this practice began around 1970, contra to
 # Shanks & Pottenger who have this region observing AST/ADT.
+# for post-1970 data America/Puerto_Rico.
 
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Mont	1917	only	-	Mar	25	2:00	1:00	D
@@ -1425,7 +1430,6 @@ Zone America/Montreal	-4:54:16 -	LMT	1884
 			-5:00	Mont	E%sT	1974
 			-5:00	Canada	E%sT
 
-
 # Ontario
 
 # From Paul Eggert (2006-07-09):
@@ -1644,7 +1648,7 @@ Zone America/Thunder_Bay -5:57:00 -	LMT	1895
 			-6:00	-	CST	1910
 			-5:00	-	EST	1942
 			-5:00	Canada	E%sT	1970
-			-5:00	Mont	E%sT	1973
+			-5:00	Toronto	E%sT	1973
 			-5:00	-	EST	1974
 			-5:00	Canada	E%sT
 Zone America/Nipigon	-5:53:04 -	LMT	1895
@@ -2231,7 +2235,7 @@ Zone America/Dawson	-9:17:40 -	LMT	1900 Aug 20
 # From Paul Eggert (1996-06-12):
 # For an English translation of the decree, see
 # 
-# ``Diario Oficial: Time Zone Changeover'' (1996-01-04).
+# "Diario Oficial: Time Zone Changeover" (1996-01-04).
 # 
 
 # From Rives McDow (1998-10-08):
@@ -2568,9 +2572,7 @@ Zone America/Santa_Isabel	-7:39:28 -	LMT	1922 Jan  1  0:20:32
 ###############################################################################
 
 # Anguilla
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone America/Anguilla	-4:12:16 -	LMT	1912 Mar 2
-			-4:00	-	AST
+# See 'southamerica'.
 
 # Antigua and Barbuda
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -2639,13 +2641,13 @@ Zone	America/Belize	-5:52:48 -	LMT	1912 Apr
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone Atlantic/Bermuda	-4:19:18 -	LMT	1930 Jan  1 2:00    # Hamilton
 			-4:00	-	AST	1974 Apr 28 2:00
-			-4:00	Bahamas	A%sT	1976
+			-4:00	Canada	A%sT	1976
 			-4:00	US	A%sT
 
 # Cayman Is
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone	America/Cayman	-5:25:32 -	LMT	1890		# Georgetown
-			-5:07:12 -	KMT	1912 Feb    # Kingston Mean Time
+			-5:07:11 -	KMT	1912 Feb    # Kingston Mean Time
 			-5:00	-	EST
 
 # Costa Rica
@@ -2660,7 +2662,7 @@ Rule	CR	1991	1992	-	Jan	Sat>=15	0:00	1:00	D
 # go with Shanks & Pottenger.
 Rule	CR	1991	only	-	Jul	 1	0:00	0	S
 Rule	CR	1992	only	-	Mar	15	0:00	0	S
-# There are too many San Joses elsewhere, so we'll use `Costa Rica'.
+# There are too many San Joses elsewhere, so we'll use 'Costa Rica'.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Costa_Rica	-5:36:13 -	LMT	1890		# San Jose
 			-5:36:13 -	SJMT	1921 Jan 15 # San Jose Mean Time
@@ -2892,9 +2894,7 @@ Zone	America/Havana	-5:29:28 -	LMT	1890
 			-5:00	Cuba	C%sT
 
 # Dominica
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone America/Dominica	-4:05:36 -	LMT	1911 Jul 1 0:01		# Roseau
-			-4:00	-	AST
+# See 'southamerica'.
 
 # Dominican Republic
 
@@ -2943,18 +2943,10 @@ Zone America/El_Salvador -5:56:48 -	LMT	1921		# San Salvador
 			-6:00	Salv	C%sT
 
 # Grenada
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	America/Grenada	-4:07:00 -	LMT	1911 Jul	# St George's
-			-4:00	-	AST
-
 # Guadeloupe
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone America/Guadeloupe	-4:06:08 -	LMT	1911 Jun 8	# Pointe a Pitre
-			-4:00	-	AST
 # St Barthelemy
-Link America/Guadeloupe	America/St_Barthelemy
 # St Martin (French part)
-Link America/Guadeloupe	America/Marigot
+# See 'southamerica'.
 
 # Guatemala
 #
@@ -3097,17 +3089,12 @@ Zone America/Tegucigalpa -5:48:52 -	LMT	1921 Apr
 # Great Swan I ceded by US to Honduras in 1972
 
 # Jamaica
-
-# From Bob Devine (1988-01-28):
-# Follows US rules.
-
-# From U. S. Naval Observatory (1989-01-19):
-# JAMAICA             5 H  BEHIND UTC
-
-# From Shanks & Pottenger:
+# Shanks & Pottenger give -5:07:12, but Milne records -5:07:10.41 from an
+# unspecified official document, and says "This time is used throughout the
+# island".  Go with Milne.  Round to the nearest second as required by zic.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	America/Jamaica	-5:07:12 -	LMT	1890		# Kingston
-			-5:07:12 -	KMT	1912 Feb    # Kingston Mean Time
+Zone	America/Jamaica	-5:07:11 -	LMT	1890		# Kingston
+			-5:07:11 -	KMT	1912 Feb    # Kingston Mean Time
 			-5:00	-	EST	1974 Apr 28 2:00
 			-5:00	US	E%sT	1984
 			-5:00	-	EST
@@ -3121,12 +3108,7 @@ Zone America/Martinique	-4:04:20 -      LMT	1890		# Fort-de-France
 			-4:00	-	AST
 
 # Montserrat
-# From Paul Eggert (2006-03-22):
-# In 1995 volcanic eruptions forced evacuation of Plymouth, the capital.
-# world.gazetteer.com says Cork Hill is the most populous location now.
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone America/Montserrat	-4:08:52 -	LMT	1911 Jul 1 0:01   # Cork Hill
-			-4:00	-	AST
+# See 'southamerica'.
 
 # Nicaragua
 #
@@ -3200,7 +3182,7 @@ Zone	America/Panama	-5:18:08 -	LMT	1890
 			-5:00	-	EST
 
 # Puerto Rico
-# There are too many San Juans elsewhere, so we'll use `Puerto_Rico'.
+# There are too many San Juans elsewhere, so we'll use 'Puerto_Rico'.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Puerto_Rico -4:24:25 -	LMT	1899 Mar 28 12:00    # San Juan
 			-4:00	-	AST	1942 May  3
@@ -3208,18 +3190,11 @@ Zone America/Puerto_Rico -4:24:25 -	LMT	1899 Mar 28 12:00    # San Juan
 			-4:00	-	AST
 
 # St Kitts-Nevis
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone America/St_Kitts	-4:10:52 -	LMT	1912 Mar 2	# Basseterre
-			-4:00	-	AST
-
 # St Lucia
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone America/St_Lucia	-4:04:00 -	LMT	1890		# Castries
-			-4:04:00 -	CMT	1912	    # Castries Mean Time
-			-4:00	-	AST
+# See 'southamerica'.
 
 # St Pierre and Miquelon
-# There are too many St Pierres elsewhere, so we'll use `Miquelon'.
+# There are too many St Pierres elsewhere, so we'll use 'Miquelon'.
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Miquelon	-3:44:40 -	LMT	1911 May 15	# St Pierre
 			-4:00	-	AST	1980 May
@@ -3227,10 +3202,7 @@ Zone America/Miquelon	-3:44:40 -	LMT	1911 May 15	# St Pierre
 			-3:00	Canada	PM%sT
 
 # St Vincent and the Grenadines
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone America/St_Vincent	-4:04:56 -	LMT	1890		# Kingstown
-			-4:04:56 -	KMT	1912	   # Kingstown Mean Time
-			-4:00	-	AST
+# See 'southamerica'.
 
 # Turks and Caicos
 #
@@ -3260,15 +3232,9 @@ Rule	TC	2007	max	-	Mar	Sun>=8	2:00	1:00	D
 Rule	TC	2007	max	-	Nov	Sun>=1	2:00	0	S
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
 Zone America/Grand_Turk	-4:44:32 -	LMT	1890
-			-5:07:12 -	KMT	1912 Feb    # Kingston Mean Time
+			-5:07:11 -	KMT	1912 Feb    # Kingston Mean Time
 			-5:00	TC	E%sT
 
 # British Virgin Is
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone America/Tortola	-4:18:28 -	LMT	1911 Jul    # Road Town
-			-4:00	-	AST
-
 # Virgin Is
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone America/St_Thomas	-4:19:44 -	LMT	1911 Jul    # Charlotte Amalie
-			-4:00	-	AST
+# See 'southamerica'.
diff --git a/test/sun/util/calendar/zi/tzdata/southamerica b/test/sun/util/calendar/zi/tzdata/southamerica
index e7df18ad2..2230d0666 100644
--- a/test/sun/util/calendar/zi/tzdata/southamerica
+++ b/test/sun/util/calendar/zi/tzdata/southamerica
@@ -474,6 +474,17 @@ Rule	Arg	2008	only	-	Oct	Sun>=15	0:00	1:00	S
 # rules...San Luis is still using "Western ARgentina Time" and it got
 # stuck on Summer daylight savings time even though the summer is over.
 
+# From Paul Eggert (2013-09-05):
+# Perhaps San Luis operates on the legal fiction that it is at UTC-4
+# with perpetual summer time, but ordinary usage typically seems to
+# just say it's at UTC-3; see, for example,
+# .
+# We've documented similar situations as being plain changes to
+# standard time, so let's do that here too.  This does not change UTC
+# offsets, only tm_isdst and the time zone abbreviations.  One minor
+# plus is that this silences a zic complaint that there's no POSIX TZ
+# setting for time stamps past 2038.
+
 # From Paul Eggert (2013-02-21):
 # Milne says Cordoba time was -4:16:48.2.  Round to the nearest second.
 
@@ -611,7 +622,7 @@ Zone America/Argentina/Mendoza -4:35:16 - LMT	1894 Oct 31
 # San Luis (SL)
 
 Rule	SanLuis	2008	2009	-	Mar	Sun>=8	0:00	0	-
-Rule	SanLuis	2007	2009	-	Oct	Sun>=8	0:00	1:00	S
+Rule	SanLuis	2007	2008	-	Oct	Sun>=8	0:00	1:00	S
 
 Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
 			-4:16:48 -	CMT	1920 May
@@ -627,7 +638,8 @@ Zone America/Argentina/San_Luis -4:25:24 - LMT	1894 Oct 31
 			-3:00	-	ART	2004 May 31
 			-4:00	-	WART	2004 Jul 25
 			-3:00	Arg	AR%sT	2008 Jan 21
-			-4:00	SanLuis	WAR%sT
+			-4:00	SanLuis	WAR%sT	2009 Oct 11
+			-3:00	-	ART
 #
 # Santa Cruz (SC)
 Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31
@@ -654,10 +666,7 @@ Zone America/Argentina/Ushuaia -4:33:12 - LMT 1894 Oct 31
 			-3:00	-	ART
 
 # Aruba
-# Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
-Zone	America/Aruba	-4:40:24 -	LMT	1912 Feb 12	# Oranjestad
-			-4:30	-	ANT	1965 # Netherlands Antilles Time
-			-4:00	-	AST
+Link America/Curacao America/Aruba
 
 # Bolivia
 # Zone	NAME		GMTOFF	RULES	FORMAT	[UNTIL]
@@ -859,6 +868,12 @@ Zone	America/La_Paz	-4:32:36 -	LMT	1890
 # Tocantins state will have DST.
 # http://noticias.terra.com.br/brasil/noticias/0,,OI6232536-EI306.html
 
+# From Steffen Thorsen (2013-09-20):
+# Tocantins in Brazil is very likely not to observe DST from October....
+# http://conexaoto.com.br/2013/09/18/ministerio-confirma-que-tocantins-esta-fora-do-horario-de-verao-em-2013-mas-falta-publicacao-de-decreto
+# We will keep this article updated when this is confirmed:
+# http://www.timeanddate.com/news/time/brazil-starts-dst-2013.html
+
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 # Decree 20,466 (1931-10-01)
 # Decree 21,896 (1932-01-10)
@@ -1078,7 +1093,8 @@ Zone America/Araguaina	-3:12:48 -	LMT	1914
 			-3:00	-	BRT	1995 Sep 14
 			-3:00	Brazil	BR%sT	2003 Sep 24
 			-3:00	-	BRT	2012 Oct 21
-			-3:00	Brazil	BR%sT
+			-3:00	Brazil	BR%sT	2013 Sep
+			-3:00	-	BRT
 #
 # Alagoas (AL), Sergipe (SE)
 Zone America/Maceio	-2:22:52 -	LMT	1914
@@ -1373,12 +1389,12 @@ Zone	America/Curacao	-4:35:47 -	LMT	1912 Feb 12	# Willemstad
 			-4:00	-	AST
 
 # From Arthur David Olson (2011-06-15):
-# At least for now, use links for places with new iso3166 codes.
+# use links for places with new iso3166 codes.
 # The name "Lower Prince's Quarter" is both longer than fourteen charaters
 # and contains an apostrophe; use "Lower_Princes" below.
 
-Link	America/Curacao	America/Lower_Princes # Sint Maarten
-Link	America/Curacao	America/Kralendijk # Bonaire, Sint Estatius and Saba
+Link	America/Curacao	America/Lower_Princes	# Sint Maarten
+Link	America/Curacao	America/Kralendijk	# Caribbean Netherlands
 
 # Ecuador
 #
@@ -1519,10 +1535,16 @@ Zone	America/Guyana	-3:52:40 -	LMT	1915 Mar	# Georgetown
 			-4:00	-	GYT
 
 # Paraguay
+#
 # From Paul Eggert (2006-03-22):
 # Shanks & Pottenger say that spring transitions are from 01:00 -> 02:00,
 # and autumn transitions are from 00:00 -> 23:00.  Go with pre-1999
 # editions of Shanks, and with the IATA, who say transitions occur at 00:00.
+#
+# From Waldemar Villamayor-Venialbo (2013-09-20):
+# No time of the day is established for the adjustment, so people normally
+# adjust their clocks at 0 hour of the given dates.
+#
 # Rule	NAME	FROM	TO	TYPE	IN	ON	AT	SAVE	LETTER/S
 Rule	Para	1975	1988	-	Oct	 1	0:00	1:00	S
 Rule	Para	1975	1978	-	Mar	 1	0:00	0	-
@@ -1656,6 +1678,19 @@ Zone America/Paramaribo	-3:40:40 -	LMT	1911
 Zone America/Port_of_Spain -4:06:04 -	LMT	1912 Mar 2
 			-4:00	-	AST
 
+Link America/Port_of_Spain America/Anguilla
+Link America/Port_of_Spain America/Dominica
+Link America/Port_of_Spain America/Grenada
+Link America/Port_of_Spain America/Guadeloupe
+Link America/Port_of_Spain America/Marigot
+Link America/Port_of_Spain America/Montserrat
+Link America/Port_of_Spain America/St_Barthelemy
+Link America/Port_of_Spain America/St_Kitts
+Link America/Port_of_Spain America/St_Lucia
+Link America/Port_of_Spain America/St_Thomas
+Link America/Port_of_Spain America/St_Vincent
+Link America/Port_of_Spain America/Tortola
+
 # Uruguay
 # From Paul Eggert (1993-11-18):
 # Uruguay wins the prize for the strangest peacetime manipulation of the rules.
@@ -1673,7 +1708,7 @@ Rule	Uruguay	1937	1941	-	Mar	lastSun	 0:00	0	-
 # Whitman gives 1937 Oct 3; go with Shanks & Pottenger.
 Rule	Uruguay	1937	1940	-	Oct	lastSun	 0:00	0:30	HS
 # Whitman gives 1941 Oct 24 - 1942 Mar 27, 1942 Dec 14 - 1943 Apr 13,
-# and 1943 Apr 13 ``to present time''; go with Shanks & Pottenger.
+# and 1943 Apr 13 "to present time"; go with Shanks & Pottenger.
 Rule	Uruguay	1941	only	-	Aug	 1	 0:00	0:30	HS
 Rule	Uruguay	1942	only	-	Jan	 1	 0:00	0	-
 Rule	Uruguay	1942	only	-	Dec	14	 0:00	1:00	S
diff --git a/test/sun/util/calendar/zi/tzdata/zone.tab b/test/sun/util/calendar/zi/tzdata/zone.tab
index aa247c26d..b34cdb0dc 100644
--- a/test/sun/util/calendar/zi/tzdata/zone.tab
+++ b/test/sun/util/calendar/zi/tzdata/zone.tab
@@ -26,27 +26,30 @@
 # This file is in the public domain, so clarified as of
 # 2009-05-17 by Arthur David Olson.
 #
-# From Paul Eggert (2013-05-27):
+# From Paul Eggert (2013-08-14):
 #
-# This file contains a table with the following columns:
-# 1.  ISO 3166 2-character country code.  See the file `iso3166.tab'.
-#     This identifies a country that overlaps the zone.  The country may
-#     overlap other zones and the zone may overlap other countries.
-# 2.  Latitude and longitude of the zone's principal location
+# This file contains a table where each row stands for an area that is
+# the intersection of a region identified by a country code and of a
+# zone where civil clocks have agreed since 1970.  The columns of the
+# table are as follows:
+#
+# 1.  ISO 3166 2-character country code.  See the file 'iso3166.tab'.
+# 2.  Latitude and longitude of the area's principal location
 #     in ISO 6709 sign-degrees-minutes-seconds format,
 #     either +-DDMM+-DDDMM or +-DDMMSS+-DDDMMSS,
 #     first latitude (+ is north), then longitude (+ is east).
-#     This location need not lie within the column-1 country.
 # 3.  Zone name used in value of TZ environment variable.
 #     Please see the 'Theory' file for how zone names are chosen.
+#     If multiple zones overlap a country, each has a row in the
+#     table, with column 1 being duplicated.
 # 4.  Comments; present if and only if the country has multiple rows.
 #
 # Columns are separated by a single tab.
 # The table is sorted first by country, then an order within the country that
 # (1) makes some geographical sense, and
-# (2) puts the most populous zones first, where that does not contradict (1).
+# (2) puts the most populous areas first, where that does not contradict (1).
 #
-# Lines beginning with `#' are comments.
+# Lines beginning with '#' are comments.
 #
 # This table is intended as an aid for users, to help them select time
 # zone data appropriate for their practical needs.  It is not intended
@@ -62,8 +65,7 @@ AI	+1812-06304	America/Anguilla
 AL	+4120+01950	Europe/Tirane
 AM	+4011+04430	Asia/Yerevan
 AO	-0848+01314	Africa/Luanda
-AQ	-7750+16636	Antarctica/McMurdo	McMurdo Station, Ross Island
-AQ	-9000+00000	Antarctica/South_Pole	Amundsen-Scott Station, South Pole
+AQ	-7750+16636	Antarctica/McMurdo	McMurdo, South Pole, Scott (New Zealand time)
 AQ	-6734-06808	Antarctica/Rothera	Rothera Station, Adelaide Island
 AQ	-6448-06406	Antarctica/Palmer	Palmer Station, Anvers Island
 AQ	-6736+06253	Antarctica/Mawson	Mawson Station, Holme Bay
@@ -143,8 +145,7 @@ CA	+4612-05957	America/Glace_Bay	Atlantic Time - Nova Scotia - places that did n
 CA	+4606-06447	America/Moncton	Atlantic Time - New Brunswick
 CA	+5320-06025	America/Goose_Bay	Atlantic Time - Labrador - most locations
 CA	+5125-05707	America/Blanc-Sablon	Atlantic Standard Time - Quebec - Lower North Shore
-CA	+4531-07334	America/Montreal	Eastern Time - Quebec - most locations
-CA	+4339-07923	America/Toronto	Eastern Time - Ontario - most locations
+CA	+4339-07923	America/Toronto	Eastern Time - Ontario & Quebec - most locations
 CA	+4901-08816	America/Nipigon	Eastern Time - Ontario & Quebec - places that did not observe DST 1967-1973
 CA	+4823-08915	America/Thunder_Bay	Eastern Time - Thunder Bay, Ontario
 CA	+6344-06828	America/Iqaluit	Eastern Time - east Nunavut - most locations
@@ -255,7 +256,7 @@ IR	+3540+05126	Asia/Tehran
 IS	+6409-02151	Atlantic/Reykjavik
 IT	+4154+01229	Europe/Rome
 JE	+4912-00207	Europe/Jersey
-JM	+1800-07648	America/Jamaica
+JM	+175805-0764736	America/Jamaica
 JO	+3157+03556	Asia/Amman
 JP	+353916+1394441	Asia/Tokyo
 KE	-0117+03649	Africa/Nairobi
@@ -444,8 +445,7 @@ US	+465042-1012439	America/North_Dakota/New_Salem	Central Time - North Dakota -
 US	+471551-1014640	America/North_Dakota/Beulah	Central Time - North Dakota - Mercer County
 US	+394421-1045903	America/Denver	Mountain Time
 US	+433649-1161209	America/Boise	Mountain Time - south Idaho & east Oregon
-US	+364708-1084111	America/Shiprock	Mountain Time - Navajo
-US	+332654-1120424	America/Phoenix	Mountain Standard Time - Arizona
+US	+332654-1120424	America/Phoenix	Mountain Standard Time - Arizona (except Navajo)
 US	+340308-1181434	America/Los_Angeles	Pacific Time
 US	+611305-1495401	America/Anchorage	Alaska Time
 US	+581807-1342511	America/Juneau	Alaska Time - Alaska panhandle
-- 
cgit v1.2.3


From ac5ffb4cc431f8e0a30f87b17acfd5ce5cdb6234 Mon Sep 17 00:00:00 2001
From: peytoia 
Date: Thu, 17 Oct 2013 13:57:42 +0900
Subject: 8025703: Update LSR datafile for BCP 47 Reviewed-by: okutsu

---
 test/java/util/Locale/Bug8025703.java              |  71 +++
 .../util/Locale/tools/language-subtag-registry.txt | 707 ++++++++++++++++++++-
 2 files changed, 751 insertions(+), 27 deletions(-)
 create mode 100644 test/java/util/Locale/Bug8025703.java

(limited to 'test')

diff --git a/test/java/util/Locale/Bug8025703.java b/test/java/util/Locale/Bug8025703.java
new file mode 100644
index 000000000..8a694aecb
--- /dev/null
+++ b/test/java/util/Locale/Bug8025703.java
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8025703
+ * @summary Verify implementation for Locale matching.
+ * @run main Bug8025703
+ */
+
+import java.util.*;
+import java.util.Locale.LanguageRange;
+
+public class Bug8025703 {
+
+    public static void main(String[] args) {
+        boolean err = false;
+
+        String[][] mappings = {{"ilw", "gal"},
+                               {"meg", "cir"},
+                               {"pcr", "adx"},
+                               {"xia", "acn"},
+                               {"yos", "zom"}};
+
+        for (int i = 0; i < mappings.length; i++) {
+            List got = LanguageRange.parse(mappings[i][0]);
+            ArrayList expected = new ArrayList<>();
+            expected.add(new LanguageRange(mappings[i][0], 1.0));
+            expected.add(new LanguageRange(mappings[i][1], 1.0));
+
+            if (!expected.equals(got)) {
+                err = true;
+                System.err.println("Incorrect language ranges. ");
+                for (LanguageRange lr : expected) {
+                    System.err.println("  Expected: range="
+                        + lr.getRange() + ", weight=" + lr.getWeight());
+                }
+                for (LanguageRange lr : got) {
+                    System.err.println("  Got:      range="
+                        + lr.getRange() + ", weight=" + lr.getWeight());
+                }
+            }
+        }
+
+        if (err) {
+            throw new RuntimeException("Failed.");
+        }
+    }
+
+}
+
diff --git a/test/java/util/Locale/tools/language-subtag-registry.txt b/test/java/util/Locale/tools/language-subtag-registry.txt
index d7e1d33c1..916cb1013 100644
--- a/test/java/util/Locale/tools/language-subtag-registry.txt
+++ b/test/java/util/Locale/tools/language-subtag-registry.txt
@@ -1,4 +1,4 @@
-File-Date: 2012-09-04
+File-Date: 2013-09-23
 %%
 Type: language
 Subtag: aa
@@ -3103,7 +3103,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: asj
-Description: Nsari
+Description: Sari
 Added: 2009-07-29
 %%
 Type: language
@@ -3622,13 +3622,18 @@ Description: Yaka (Central African Republic)
 Added: 2009-07-29
 %%
 Type: language
+Subtag: axl
+Description: Lower Southern Aranda
+Added: 2013-09-10
+%%
+Type: language
 Subtag: axm
 Description: Middle Armenian
 Added: 2009-07-29
 %%
 Type: language
 Subtag: axx
-Description: Xaragure
+Description: Xârâgurè
 Added: 2009-07-29
 %%
 Type: language
@@ -5021,6 +5026,11 @@ Description: Mid-Southern Banda
 Added: 2009-07-29
 %%
 Type: language
+Subtag: bjp
+Description: Fanamaket
+Added: 2013-09-10
+%%
+Type: language
 Subtag: bjq
 Description: Southern Betsimisaraka Malagasy
 Added: 2009-07-29
@@ -5705,7 +5715,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: bpa
-Description: Dakaka
+Description: Daakaka
 Added: 2009-07-29
 %%
 Type: language
@@ -5741,6 +5751,7 @@ Added: 2009-07-29
 Type: language
 Subtag: bpk
 Description: Orowe
+Description: 'Ôrôê
 Added: 2009-07-29
 %%
 Type: language
@@ -5831,6 +5842,7 @@ Added: 2009-07-29
 Type: language
 Subtag: bqc
 Description: Boko (Benin)
+Description: Boo
 Added: 2009-07-29
 %%
 Type: language
@@ -6523,6 +6535,11 @@ Description: Bolgo
 Added: 2009-07-29
 %%
 Type: language
+Subtag: bvp
+Description: Bumang
+Added: 2013-09-10
+%%
+Type: language
 Subtag: bvq
 Description: Birri
 Added: 2009-07-29
@@ -6696,7 +6713,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: bxa
-Description: Bauro
+Description: Tairaha
 Added: 2009-07-29
 %%
 Type: language
@@ -6722,7 +6739,9 @@ Added: 2009-07-29
 Type: language
 Subtag: bxf
 Description: Bilur
+Description: Minigir
 Added: 2009-07-29
+Comments: see also vmg
 %%
 Type: language
 Subtag: bxg
@@ -7054,7 +7073,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: bzv
-Description: Bebe
+Description: Naami
 Added: 2009-07-29
 %%
 Type: language
@@ -7700,6 +7719,8 @@ Added: 2009-07-29
 Type: language
 Subtag: cir
 Description: Tiri
+Description: Haméa
+Description: Méa
 Added: 2009-07-29
 %%
 Type: language
@@ -7805,6 +7826,11 @@ Description: Cibak
 Added: 2009-07-29
 %%
 Type: language
+Subtag: ckn
+Description: Kaang Chin
+Added: 2013-09-10
+%%
+Type: language
 Subtag: cko
 Description: Anufo
 Added: 2009-07-29
@@ -8229,6 +8255,11 @@ Description: Cherepon
 Added: 2009-07-29
 %%
 Type: language
+Subtag: cpo
+Description: Kpeego
+Added: 2013-09-10
+%%
+Type: language
 Subtag: cpp
 Description: Portuguese-based creoles and pidgins
 Added: 2005-10-16
@@ -8441,6 +8472,11 @@ Description: Coast Miwok
 Added: 2009-07-29
 %%
 Type: language
+Subtag: csj
+Description: Songlai Chin
+Added: 2013-09-10
+%%
+Type: language
 Subtag: csk
 Description: Jola-Kasa
 Added: 2009-07-29
@@ -8800,6 +8836,8 @@ Type: language
 Subtag: daf
 Description: Dan
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see dnj, lda
 %%
 Type: language
 Subtag: dag
@@ -8897,7 +8935,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: dba
-Description: Bangi Me
+Description: Bangime
 Added: 2009-07-29
 %%
 Type: language
@@ -9221,7 +9259,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: dgt
-Description: Ndrag'ngith
+Description: Ndra'ngith
 Added: 2012-08-12
 %%
 Type: language
@@ -9258,6 +9296,7 @@ Macrolanguage: mwr
 %%
 Type: language
 Subtag: dhg
+Description: Djangu
 Description: Dhangu
 Added: 2009-07-29
 %%
@@ -9304,6 +9343,7 @@ Added: 2009-07-29
 Type: language
 Subtag: dhv
 Description: Dehu
+Description: Drehu
 Added: 2009-07-29
 %%
 Type: language
@@ -9312,6 +9352,11 @@ Description: Dhanwar (Nepal)
 Added: 2009-07-29
 %%
 Type: language
+Subtag: dhx
+Description: Dhungaloo
+Added: 2013-09-10
+%%
+Type: language
 Subtag: dia
 Description: Dia
 Added: 2009-07-29
@@ -9489,6 +9534,8 @@ Type: language
 Subtag: djl
 Description: Djiwarli
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see dze, iin
 %%
 Type: language
 Subtag: djm
@@ -9559,6 +9606,11 @@ Description: Dolgan
 Added: 2009-07-29
 %%
 Type: language
+Subtag: dlk
+Description: Dahalik
+Added: 2013-09-10
+%%
+Type: language
 Subtag: dlm
 Description: Dalmatian
 Added: 2009-07-29
@@ -9580,7 +9632,7 @@ Added: 2011-08-16
 %%
 Type: language
 Subtag: dmc
-Description: Dimir
+Description: Gavak
 Added: 2009-07-29
 %%
 Type: language
@@ -9646,6 +9698,11 @@ Description: Dumpas
 Added: 2009-07-29
 %%
 Type: language
+Subtag: dmw
+Description: Mudburra
+Added: 2013-09-10
+%%
+Type: language
 Subtag: dmx
 Description: Dema
 Added: 2009-07-29
@@ -9682,6 +9739,11 @@ Description: Lower Grand Valley Dani
 Added: 2009-07-29
 %%
 Type: language
+Subtag: dnj
+Description: Dan
+Added: 2013-09-10
+%%
+Type: language
 Subtag: dnk
 Description: Dengka
 Added: 2009-07-29
@@ -10067,6 +10129,7 @@ Added: 2009-07-29
 Type: language
 Subtag: duf
 Description: Dumbea
+Description: Drubea
 Added: 2009-07-29
 %%
 Type: language
@@ -10259,6 +10322,11 @@ Description: Daza
 Added: 2009-07-29
 %%
 Type: language
+Subtag: dze
+Description: Djiwarli
+Added: 2013-09-10
+%%
+Type: language
 Subtag: dzg
 Description: Dazaga
 Added: 2009-07-29
@@ -10274,6 +10342,11 @@ Description: Dzando
 Added: 2009-07-29
 %%
 Type: language
+Subtag: eaa
+Description: Karenggapa
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ebg
 Description: Ebughu
 Added: 2009-07-29
@@ -10392,6 +10465,11 @@ Description: Ekajuk
 Added: 2005-10-16
 %%
 Type: language
+Subtag: ekc
+Description: Eastern Karnic
+Added: 2013-09-10
+%%
+Type: language
 Subtag: eke
 Description: Ekit
 Added: 2009-07-29
@@ -10859,6 +10937,11 @@ Added: 2009-07-29
 Macrolanguage: kln
 %%
 Type: language
+Subtag: eza
+Description: Ezaa
+Added: 2013-09-10
+%%
+Type: language
 Subtag: eze
 Description: Uzekwe
 Added: 2009-07-29
@@ -10870,7 +10953,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: fab
-Description: Fa D'ambu
+Description: Fa d'Ambu
 Added: 2009-07-29
 %%
 Type: language
@@ -11374,7 +11457,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: gal
-Description: Galoli
+Description: Galolen
 Added: 2009-07-29
 %%
 Type: language
@@ -11564,6 +11647,11 @@ Description: Gbanu
 Added: 2009-07-29
 %%
 Type: language
+Subtag: gbw
+Description: Gabi-Gabi
+Added: 2013-09-10
+%%
+Type: language
 Subtag: gbx
 Description: Eastern Xwla Gbe
 Added: 2009-07-29
@@ -11710,6 +11798,11 @@ Description: Ghandruk Sign Language
 Added: 2012-08-12
 %%
 Type: language
+Subtag: gdt
+Description: Kungardutyi
+Added: 2013-09-10
+%%
+Type: language
 Subtag: gdu
 Description: Gudu
 Added: 2009-07-29
@@ -11872,6 +11965,8 @@ Type: language
 Subtag: ggr
 Description: Aghu Tharnggalu
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see ggm, gtu, ikr
 %%
 Type: language
 Subtag: ggt
@@ -11881,6 +11976,7 @@ Added: 2009-07-29
 Type: language
 Subtag: ggu
 Description: Gagu
+Description: Gban
 Added: 2009-07-29
 %%
 Type: language
@@ -11970,6 +12066,11 @@ Description: Goaria
 Added: 2009-07-29
 %%
 Type: language
+Subtag: gih
+Description: Githabul
+Added: 2013-09-10
+%%
+Type: language
 Subtag: gil
 Description: Gilbertese
 Added: 2005-10-16
@@ -12052,6 +12153,11 @@ Description: Kachi Koli
 Added: 2009-07-29
 %%
 Type: language
+Subtag: gjm
+Description: Gunditjmara
+Added: 2013-09-10
+%%
+Type: language
 Subtag: gjn
 Description: Gonja
 Added: 2009-07-29
@@ -12119,6 +12225,11 @@ Description: Gilaki
 Added: 2009-07-29
 %%
 Type: language
+Subtag: gll
+Description: Garlali
+Added: 2013-09-10
+%%
+Type: language
 Subtag: glo
 Description: Galambu
 Added: 2009-07-29
@@ -12218,6 +12329,11 @@ Description: Mycenaean Greek
 Added: 2009-07-29
 %%
 Type: language
+Subtag: gmz
+Description: Mgbolizhia
+Added: 2013-09-10
+%%
+Type: language
 Subtag: gna
 Description: Kaansa
 Added: 2009-07-29
@@ -12651,6 +12767,11 @@ Description: Gbati-ri
 Added: 2009-07-29
 %%
 Type: language
+Subtag: gtu
+Description: Aghu-Tharnggala
+Added: 2013-09-10
+%%
+Type: language
 Subtag: gua
 Description: Shiki
 Added: 2009-07-29
@@ -13703,6 +13824,11 @@ Description: Hrangkhol
 Added: 2009-07-29
 %%
 Type: language
+Subtag: hrc
+Description: Niwer Mil
+Added: 2013-09-10
+%%
+Type: language
 Subtag: hre
 Description: Hre
 Added: 2009-07-29
@@ -13724,6 +13850,11 @@ Description: Haroi
 Added: 2009-07-29
 %%
 Type: language
+Subtag: hrp
+Description: Nhirrpi
+Added: 2013-09-10
+%%
+Type: language
 Subtag: hrr
 Description: Horuru
 Added: 2009-07-29
@@ -13741,6 +13872,11 @@ Description: Hruso
 Added: 2009-07-29
 %%
 Type: language
+Subtag: hrw
+Description: Warwar Feni
+Added: 2013-09-10
+%%
+Type: language
 Subtag: hrx
 Description: Hunsrik
 Added: 2009-07-29
@@ -13957,6 +14093,7 @@ Added: 2009-07-29
 Type: language
 Subtag: hwc
 Description: Hawai'i Creole English
+Description: Hawai'i Pidgin
 Added: 2009-07-29
 %%
 Type: language
@@ -14092,6 +14229,7 @@ Added: 2009-07-29
 Type: language
 Subtag: idc
 Description: Idon
+Description: Ajiya
 Added: 2009-07-29
 %%
 Type: language
@@ -14236,6 +14374,11 @@ Description: Bidhawal
 Added: 2012-08-12
 %%
 Type: language
+Subtag: iin
+Description: Thiin
+Added: 2013-09-10
+%%
+Type: language
 Subtag: iir
 Description: Indo-Iranian languages
 Added: 2009-07-29
@@ -14304,6 +14447,11 @@ Description: Ikpeshi
 Added: 2009-07-29
 %%
 Type: language
+Subtag: ikr
+Description: Ikaranggal
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ikt
 Description: Inuinnaqtun
 Description: Western Canadian Inuktitut
@@ -14384,6 +14532,8 @@ Type: language
 Subtag: ilw
 Description: Talur
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Preferred-Value: gal
 %%
 Type: language
 Subtag: ima
@@ -14533,6 +14683,11 @@ Description: Iquito
 Added: 2009-07-29
 %%
 Type: language
+Subtag: iqw
+Description: Ikwo
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ira
 Description: Iranian languages
 Added: 2005-10-16
@@ -14809,6 +14964,8 @@ Type: language
 Subtag: izi
 Description: Izi-Ezaa-Ikwo-Mgbo
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see eza, gmz, iqw, izz
 %%
 Type: language
 Subtag: izr
@@ -14816,6 +14973,11 @@ Description: Izere
 Added: 2009-07-29
 %%
 Type: language
+Subtag: izz
+Description: Izii
+Added: 2013-09-10
+%%
+Type: language
 Subtag: jaa
 Description: Jamamadí
 Added: 2009-07-29
@@ -14932,6 +15094,11 @@ Description: Judeo-Berber
 Added: 2009-07-29
 %%
 Type: language
+Subtag: jbi
+Description: Badjiri
+Added: 2013-09-10
+%%
+Type: language
 Subtag: jbj
 Description: Arandai
 Added: 2009-07-29
@@ -15902,7 +16069,8 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: kdk
-Description: Numee
+Description: Numèè
+Description: Kwényi
 Added: 2009-07-29
 %%
 Type: language
@@ -19073,8 +19241,6 @@ Type: language
 Subtag: lcq
 Description: Luhu
 Added: 2009-07-29
-Deprecated: 2012-08-12
-Preferred-Value: ppr
 %%
 Type: language
 Subtag: lcs
@@ -19082,6 +19248,11 @@ Description: Lisabata-Nuniali
 Added: 2009-07-29
 %%
 Type: language
+Subtag: lda
+Description: Kla-Dan
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ldb
 Description: Dũya
 Added: 2009-07-29
@@ -19526,6 +19697,11 @@ Description: Libinza
 Added: 2009-07-29
 %%
 Type: language
+Subtag: lja
+Description: Golpa
+Added: 2013-09-10
+%%
+Type: language
 Subtag: lje
 Description: Rampi
 Added: 2009-07-29
@@ -19546,6 +19722,16 @@ Description: Lampung Api
 Added: 2009-07-29
 %%
 Type: language
+Subtag: ljw
+Description: Yirandali
+Added: 2013-09-10
+%%
+Type: language
+Subtag: ljx
+Description: Yuru
+Added: 2013-09-10
+%%
+Type: language
 Subtag: lka
 Description: Lakalei
 Added: 2009-07-29
@@ -19593,6 +19779,11 @@ Description: Laeko-Libuat
 Added: 2009-07-29
 %%
 Type: language
+Subtag: lkm
+Description: Kalaamaya
+Added: 2013-09-10
+%%
+Type: language
 Subtag: lkn
 Description: Lakon
 Description: Vure
@@ -19623,6 +19814,11 @@ Description: Lakota
 Added: 2009-07-29
 %%
 Type: language
+Subtag: lku
+Description: Kungkari
+Added: 2013-09-10
+%%
+Type: language
 Subtag: lky
 Description: Lokoya
 Added: 2009-07-29
@@ -19914,6 +20110,11 @@ Description: Longuda
 Added: 2009-07-29
 %%
 Type: language
+Subtag: lnw
+Description: Lanima
+Added: 2013-09-10
+%%
+Type: language
 Subtag: lnz
 Description: Lonzo
 Added: 2009-07-29
@@ -20432,6 +20633,11 @@ Description: Lewotobi
 Added: 2009-07-29
 %%
 Type: language
+Subtag: lwu
+Description: Lawu
+Added: 2013-09-10
+%%
+Type: language
 Subtag: lww
 Description: Lewo
 Added: 2009-07-29
@@ -20526,6 +20732,7 @@ Added: 2009-07-29
 Type: language
 Subtag: man
 Description: Mandingo
+Description: Manding
 Added: 2005-10-16
 Scope: macrolanguage
 %%
@@ -20990,6 +21197,8 @@ Type: language
 Subtag: meg
 Description: Mea
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Preferred-Value: cir
 %%
 Type: language
 Subtag: meh
@@ -21065,7 +21274,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: mev
-Description: Mann
+Description: Mano
 Added: 2009-07-29
 %%
 Type: language
@@ -21117,7 +21326,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: mfg
-Description: Mixifore
+Description: Mogofin
 Added: 2009-07-29
 %%
 Type: language
@@ -21525,6 +21734,7 @@ Added: 2009-07-29
 Type: language
 Subtag: mij
 Description: Abar
+Description: Mungbam
 Added: 2009-07-29
 %%
 Type: language
@@ -21871,6 +22081,7 @@ Type: language
 Subtag: mld
 Description: Malakhel
 Added: 2009-07-29
+Deprecated: 2013-09-10
 %%
 Type: language
 Subtag: mle
@@ -22199,6 +22410,8 @@ Type: language
 Subtag: mnt
 Description: Maykulan
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see wnn, xyj, xyk, xyt
 %%
 Type: language
 Subtag: mnu
@@ -22996,7 +23209,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: muc
-Description: Mbu'
+Description: Ajumbu
 Added: 2009-07-29
 %%
 Type: language
@@ -23250,6 +23463,8 @@ Type: language
 Subtag: mwd
 Description: Mudbura
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see dmw, xrq
 %%
 Type: language
 Subtag: mwe
@@ -23577,6 +23792,7 @@ Type: language
 Subtag: myq
 Description: Forest Maninka
 Added: 2009-07-29
+Deprecated: 2013-09-10
 Macrolanguage: man
 %%
 Type: language
@@ -23990,6 +24206,8 @@ Type: language
 Subtag: nbx
 Description: Ngura
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see ekc, gll, jbi, xpt, xwk
 %%
 Type: language
 Subtag: nby
@@ -24428,7 +24646,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: ngk
-Description: Ngalkbun
+Description: Dalabon
 Added: 2009-07-29
 %%
 Type: language
@@ -25011,9 +25229,16 @@ Description: Ngul
 Added: 2009-07-29
 %%
 Type: language
+Subtag: nlq
+Description: Lao Naga
+Added: 2013-09-10
+%%
+Type: language
 Subtag: nlr
 Description: Ngarla
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see nrk, ywg
 %%
 Type: language
 Subtag: nlu
@@ -25026,6 +25251,11 @@ Description: Orizaba Nahuatl
 Added: 2009-07-29
 %%
 Type: language
+Subtag: nlw
+Description: Walangama
+Added: 2013-09-10
+%%
+Type: language
 Subtag: nlx
 Description: Nahali
 Added: 2009-07-29
@@ -25348,6 +25578,11 @@ Description: Nooksack
 Added: 2009-07-29
 %%
 Type: language
+Subtag: nol
+Description: Nomlaki
+Added: 2013-09-10
+%%
+Type: language
 Subtag: nom
 Description: Nocamán
 Added: 2009-07-29
@@ -25493,6 +25728,11 @@ Added: 2006-06-05
 Suppress-Script: Nkoo
 %%
 Type: language
+Subtag: nqq
+Description: Kyan-Karyaw Naga
+Added: 2013-09-10
+%%
+Type: language
 Subtag: nqy
 Description: Akyaung Ari Naga
 Added: 2012-08-12
@@ -25528,6 +25768,11 @@ Description: Chokri Naga
 Added: 2009-07-29
 %%
 Type: language
+Subtag: nrk
+Description: Ngarla
+Added: 2013-09-10
+%%
+Type: language
 Subtag: nrl
 Description: Ngarluma
 Added: 2009-07-29
@@ -25550,6 +25795,7 @@ Added: 2009-07-29
 Type: language
 Subtag: nrr
 Description: Norra
+Description: Nora
 Added: 2009-07-29
 %%
 Type: language
@@ -25701,6 +25947,11 @@ Description: Nathembo
 Added: 2009-07-29
 %%
 Type: language
+Subtag: ntg
+Description: Ngantangarra
+Added: 2013-09-10
+%%
+Type: language
 Subtag: nti
 Description: Natioro
 Added: 2009-07-29
@@ -25768,7 +26019,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: nua
-Description: Yuaga
+Description: Yuanga
 Added: 2009-07-29
 %%
 Type: language
@@ -26517,6 +26768,11 @@ Description: Olekha
 Added: 2009-07-29
 %%
 Type: language
+Subtag: olk
+Description: Olkol
+Added: 2013-09-10
+%%
+Type: language
 Subtag: olm
 Description: Oloma
 Added: 2009-07-29
@@ -27339,6 +27595,8 @@ Type: language
 Subtag: pcr
 Description: Panang
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Preferred-Value: adx
 %%
 Type: language
 Subtag: pcw
@@ -28086,11 +28344,22 @@ Description: Aoheng
 Added: 2009-07-29
 %%
 Type: language
+Subtag: pnj
+Description: Pinjarup
+Added: 2013-09-10
+%%
+Type: language
 Subtag: pnk
 Description: Paunaka
 Added: 2012-08-12
 %%
 Type: language
+Subtag: pnl
+Description: Paleni
+Added: 2013-09-10
+Comments: see also wbf
+%%
+Type: language
 Subtag: pnm
 Description: Punan Batu 1
 Added: 2009-07-29
@@ -28219,7 +28488,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: pop
-Description: Pwapwa
+Description: Pwapwâ
 Added: 2009-07-29
 %%
 Type: language
@@ -28318,6 +28587,8 @@ Type: language
 Subtag: ppr
 Description: Piru
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Preferred-Value: lcq
 %%
 Type: language
 Subtag: pps
@@ -28758,6 +29029,11 @@ Description: Gapapaiwa
 Added: 2009-07-29
 %%
 Type: language
+Subtag: pwi
+Description: Patwin
+Added: 2013-09-10
+%%
+Type: language
 Subtag: pwm
 Description: Molbog
 Added: 2009-07-29
@@ -29532,6 +29808,11 @@ Description: Kamta
 Added: 2009-07-29
 %%
 Type: language
+Subtag: rkw
+Description: Arakwal
+Added: 2013-09-10
+%%
+Type: language
 Subtag: rma
 Description: Rama
 Added: 2009-07-29
@@ -29941,6 +30222,16 @@ Added: 2009-07-29
 Macrolanguage: mwr
 %%
 Type: language
+Subtag: rxd
+Description: Ngardi
+Added: 2013-09-10
+%%
+Type: language
+Subtag: rxw
+Description: Karuwali
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ryn
 Description: Northern Amami-Oshima
 Added: 2009-07-29
@@ -30840,6 +31131,7 @@ Added: 2009-07-29
 Type: language
 Subtag: sih
 Description: Zire
+Description: Sîshëë
 Added: 2009-07-29
 %%
 Type: language
@@ -32117,6 +32409,11 @@ Description: Satawalese
 Added: 2009-07-29
 %%
 Type: language
+Subtag: sty
+Description: Siberian Tatar
+Added: 2013-09-10
+%%
+Type: language
 Subtag: sua
 Description: Sulka
 Added: 2009-07-29
@@ -32241,6 +32538,11 @@ Description: Slovakian Sign Language
 Added: 2009-07-29
 %%
 Type: language
+Subtag: svm
+Description: Slavomolisano
+Added: 2013-09-10
+%%
+Type: language
 Subtag: svr
 Description: Savara
 Added: 2009-07-29
@@ -33213,6 +33515,8 @@ Type: language
 Subtag: tgg
 Description: Tangga
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see bjp, hrc, hrw
 %%
 Type: language
 Subtag: tgh
@@ -33570,6 +33874,11 @@ Description: Tjurruru
 Added: 2009-07-29
 %%
 Type: language
+Subtag: tjw
+Description: Djabwurrung
+Added: 2013-09-10
+%%
+Type: language
 Subtag: tka
 Description: Truká
 Added: 2009-07-29
@@ -34004,7 +34313,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: tnr
-Description: Bedik
+Description: Ménik
 Added: 2009-07-29
 %%
 Type: language
@@ -35088,7 +35397,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: tye
-Description: Kyenga
+Description: Kyanga
 Added: 2009-07-29
 %%
 Type: language
@@ -35172,6 +35481,11 @@ Description: Tz'utujil
 Added: 2009-07-29
 %%
 Type: language
+Subtag: tzl
+Description: Talossan
+Added: 2013-09-10
+%%
+Type: language
 Subtag: tzm
 Description: Central Atlas Tamazight
 Added: 2009-07-29
@@ -35409,6 +35723,11 @@ Description: Ulch
 Added: 2009-07-29
 %%
 Type: language
+Subtag: ule
+Description: Lule
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ulf
 Description: Usku
 Description: Afra
@@ -35548,6 +35867,11 @@ Added: 2009-07-29
 Macrolanguage: del
 %%
 Type: language
+Subtag: unn
+Description: Kurnai
+Added: 2013-09-10
+%%
+Type: language
 Subtag: unp
 Description: Worora
 Added: 2009-07-29
@@ -35560,6 +35884,11 @@ Description: Mundari
 Added: 2009-07-29
 %%
 Type: language
+Subtag: unu
+Description: Unubahe
+Added: 2013-09-10
+%%
+Type: language
 Subtag: unx
 Description: Munda
 Added: 2009-07-29
@@ -35781,6 +36110,7 @@ Added: 2009-07-29
 Type: language
 Subtag: uve
 Description: West Uvean
+Description: Fagauvea
 Added: 2009-07-29
 %%
 Type: language
@@ -36071,7 +36401,7 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: vmb
-Description: Mbabaram
+Description: Barbaram
 Added: 2009-07-29
 %%
 Type: language
@@ -36096,8 +36426,9 @@ Added: 2009-07-29
 %%
 Type: language
 Subtag: vmg
-Description: Minigir
+Description: Lungalunga
 Added: 2009-07-29
+Comments: see also bxf
 %%
 Type: language
 Subtag: vmh
@@ -36389,6 +36720,7 @@ Added: 2009-07-29
 Type: language
 Subtag: wax
 Description: Watam
+Description: Marangis
 Added: 2009-07-29
 %%
 Type: language
@@ -36420,6 +36752,7 @@ Type: language
 Subtag: wbf
 Description: Wara
 Added: 2009-07-29
+Comments: see also pnl
 %%
 Type: language
 Subtag: wbh
@@ -36508,11 +36841,21 @@ Description: Wadjiginy
 Added: 2009-07-29
 %%
 Type: language
+Subtag: wdk
+Description: Wadikali
+Added: 2013-09-10
+%%
+Type: language
 Subtag: wdu
 Description: Wadjigu
 Added: 2009-07-29
 %%
 Type: language
+Subtag: wdy
+Description: Wadjabangayi
+Added: 2013-09-10
+%%
+Type: language
 Subtag: wea
 Description: Wewaw
 Added: 2009-07-29
@@ -36528,6 +36871,11 @@ Description: Wedau
 Added: 2009-07-29
 %%
 Type: language
+Subtag: weg
+Description: Wergaia
+Added: 2013-09-10
+%%
+Type: language
 Subtag: weh
 Description: Weh
 Added: 2009-07-29
@@ -36720,6 +37068,8 @@ Type: language
 Subtag: wit
 Description: Wintu
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see nol, pwi, wnw
 %%
 Type: language
 Subtag: wiu
@@ -36785,6 +37135,11 @@ Description: Wakawaka
 Added: 2009-07-29
 %%
 Type: language
+Subtag: wky
+Description: Wangkayutyuru
+Added: 2013-09-10
+%%
+Type: language
 Subtag: wla
 Description: Walio
 Added: 2009-07-29
@@ -36975,6 +37330,11 @@ Description: Wanggamala
 Added: 2009-07-29
 %%
 Type: language
+Subtag: wnn
+Description: Wunumara
+Added: 2013-09-10
+%%
+Type: language
 Subtag: wno
 Description: Wano
 Added: 2009-07-29
@@ -36990,6 +37350,11 @@ Description: Usan
 Added: 2009-07-29
 %%
 Type: language
+Subtag: wnw
+Description: Wintu
+Added: 2013-09-10
+%%
+Type: language
 Subtag: wny
 Description: Wanyi
 Added: 2012-08-12
@@ -37221,6 +37586,11 @@ Description: Watiwa
 Added: 2009-07-29
 %%
 Type: language
+Subtag: wth
+Description: Wathawurrung
+Added: 2013-09-10
+%%
+Type: language
 Subtag: wti
 Description: Berta
 Added: 2009-07-29
@@ -37338,6 +37708,11 @@ Description: Waxianghua
 Added: 2009-07-29
 %%
 Type: language
+Subtag: wxw
+Description: Wardandi
+Added: 2013-09-10
+%%
+Type: language
 Subtag: wya
 Description: Wyandot
 Added: 2009-07-29
@@ -37348,6 +37723,11 @@ Description: Wangaaybuwan-Ngiyambaa
 Added: 2009-07-29
 %%
 Type: language
+Subtag: wyi
+Description: Woiwurrung
+Added: 2013-09-10
+%%
+Type: language
 Subtag: wym
 Description: Wymysorys
 Added: 2009-07-29
@@ -37479,11 +37859,31 @@ Description: Bactrian
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xbd
+Description: Bindal
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xbe
+Description: Bigambal
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xbg
+Description: Bunganditj
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xbi
 Description: Kombio
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xbj
+Description: Birrpayi
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xbm
 Description: Middle Breton
 Added: 2009-07-29
@@ -37499,6 +37899,11 @@ Description: Bolgarian
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xbp
+Description: Bibbulman
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xbr
 Description: Kambera
 Added: 2009-07-29
@@ -37514,6 +37919,11 @@ Description: Kabixí
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xby
+Description: Batyala
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xcb
 Description: Cumbric
 Added: 2009-07-29
@@ -37590,11 +38000,21 @@ Description: Cayuse
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xda
+Description: Darkinyung
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xdc
 Description: Dacian
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xdk
+Description: Dharuk
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xdm
 Description: Edomite
 Added: 2009-07-29
@@ -37670,16 +38090,36 @@ Description: Gbin
 Added: 2012-08-12
 %%
 Type: language
+Subtag: xgd
+Description: Gudang
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xgf
 Description: Gabrielino-Fernandeño
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xgg
+Description: Goreng
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xgi
+Description: Garingbal
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xgl
 Description: Galindan
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xgm
+Description: Guwinmal
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xgn
 Description: Mongolian languages
 Added: 2009-07-29
@@ -37696,6 +38136,11 @@ Description: Unggumi
 Added: 2012-08-12
 %%
 Type: language
+Subtag: xgw
+Description: Guwa
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xha
 Description: Harami
 Added: 2009-07-29
@@ -37740,6 +38185,8 @@ Type: language
 Subtag: xia
 Description: Xiandao
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Preferred-Value: acn
 %%
 Type: language
 Subtag: xib
@@ -37782,6 +38229,16 @@ Description: Xipaya
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xjb
+Description: Minjungbal
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xjt
+Description: Jaitmatang
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xka
 Description: Kalkoti
 Added: 2009-07-29
@@ -38127,6 +38584,16 @@ Description: Kuanhua
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xni
+Description: Ngarigu
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xnk
+Description: Nganakarti
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xnn
 Description: Northern Kankanay
 Added: 2009-07-29
@@ -38153,6 +38620,16 @@ Description: Narragansett
 Added: 2010-03-11
 %%
 Type: language
+Subtag: xnu
+Description: Nukunul
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xny
+Description: Nyiyaparli
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xnz
 Description: Kenzi
 Description: Mattoki
@@ -38214,6 +38691,11 @@ Description: Kowaki
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xpa
+Description: Pirriya
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xpc
 Description: Pecheneg
 Added: 2009-07-29
@@ -38280,6 +38762,11 @@ Description: Pisidian
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xpt
+Description: Punthamara
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xpu
 Description: Punic
 Added: 2009-07-29
@@ -38310,11 +38797,21 @@ Description: Eastern Karaboro
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xrd
+Description: Gundungurra
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xre
 Description: Kreye
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xrg
+Description: Minang
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xri
 Description: Krikati-Timbira
 Added: 2009-07-29
@@ -38330,6 +38827,11 @@ Description: Arin
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xrq
+Description: Karranga
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xrr
 Description: Raetic
 Added: 2009-07-29
@@ -38476,6 +38978,11 @@ Description: Transalpine Gaulish
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xth
+Description: Yitha Yitha
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xti
 Description: Sinicahua Mixtec
 Added: 2009-07-29
@@ -38536,6 +39043,11 @@ Description: Cuyamecalco Mixtec
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xtv
+Description: Thawa
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xtw
 Description: Tawandê
 Added: 2009-07-29
@@ -38576,13 +39088,18 @@ Description: Jennu Kurumba
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xul
+Description: Ngunawal
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xum
 Description: Umbrian
 Added: 2009-07-29
 %%
 Type: language
 Subtag: xun
-Description: Unggarranggu
+Description: Unggaranggu
 Added: 2012-08-12
 %%
 Type: language
@@ -38646,6 +39163,11 @@ Description: Woccon
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xwd
+Description: Wadi Wadi
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xwe
 Description: Xwela Gbe
 Added: 2009-07-29
@@ -38656,6 +39178,16 @@ Description: Kwegu
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xwj
+Description: Wajuk
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xwk
+Description: Wangkumara
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xwl
 Description: Western Xwla Gbe
 Added: 2009-07-29
@@ -38671,6 +39203,16 @@ Description: Kwerba Mamberamo
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xwt
+Description: Wotjobaluk
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xww
+Description: Wemba Wemba
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xxb
 Description: Boro (Ghana)
 Added: 2009-07-29
@@ -38681,6 +39223,11 @@ Description: Ke'o
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xxm
+Description: Minkin
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xxr
 Description: Koropó
 Added: 2009-07-29
@@ -38691,11 +39238,36 @@ Description: Tambora
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xya
+Description: Yaygir
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xyb
+Description: Yandjibara
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xyj
+Description: Mayi-Yapi
+Added: 2013-09-10
+%%
+Type: language
+Subtag: xyk
+Description: Mayi-Kulan
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xyl
 Description: Yalakalore
 Added: 2009-07-29
 %%
 Type: language
+Subtag: xyt
+Description: Mayi-Thakurti
+Added: 2013-09-10
+%%
+Type: language
 Subtag: xyy
 Description: Yorta Yorta
 Added: 2012-08-12
@@ -38938,6 +39510,11 @@ Description: Chepya
 Added: 2009-07-29
 %%
 Type: language
+Subtag: yda
+Description: Yanda
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ydd
 Description: Eastern Yiddish
 Added: 2009-07-29
@@ -39036,6 +39613,11 @@ Description: Malyangapa
 Added: 2012-08-12
 %%
 Type: language
+Subtag: ygi
+Description: Yiningayi
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ygl
 Description: Yangum Gel
 Added: 2009-07-29
@@ -39056,6 +39638,11 @@ Description: Yagaria
 Added: 2009-07-29
 %%
 Type: language
+Subtag: ygu
+Description: Yugul
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ygw
 Description: Yagwoia
 Added: 2009-07-29
@@ -39171,6 +39758,8 @@ Type: language
 Subtag: yiy
 Description: Yir Yoront
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Comments: see yrm, yyr
 %%
 Type: language
 Subtag: yiz
@@ -39295,6 +39884,7 @@ Added: 2009-07-29
 Type: language
 Subtag: yly
 Description: Nyâlayu
+Description: Nyelâyu
 Added: 2009-07-29
 %%
 Type: language
@@ -39499,6 +40089,8 @@ Type: language
 Subtag: yos
 Description: Yos
 Added: 2009-07-29
+Deprecated: 2013-09-10
+Preferred-Value: zom
 %%
 Type: language
 Subtag: yot
@@ -39597,6 +40189,11 @@ Description: Nhengatu
 Added: 2009-07-29
 %%
 Type: language
+Subtag: yrm
+Description: Yirrk-Mel
+Added: 2013-09-10
+%%
+Type: language
 Subtag: yrn
 Description: Yerong
 Added: 2009-07-29
@@ -39612,6 +40209,11 @@ Description: Yarawata
 Added: 2009-07-29
 %%
 Type: language
+Subtag: yry
+Description: Yarluyandi
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ysc
 Description: Yassic
 Added: 2009-07-29
@@ -39682,6 +40284,11 @@ Description: Yout Wam
 Added: 2010-03-11
 %%
 Type: language
+Subtag: yty
+Description: Yatay
+Added: 2013-09-10
+%%
+Type: language
 Subtag: yua
 Description: Yucateco
 Description: Yucatec Maya
@@ -39810,6 +40417,11 @@ Description: Kalou
 Added: 2009-07-29
 %%
 Type: language
+Subtag: ywg
+Description: Yinhawangka
+Added: 2013-09-10
+%%
+Type: language
 Subtag: ywl
 Description: Western Lalu
 Added: 2009-07-29
@@ -39846,16 +40458,41 @@ Description: Yawarawarga
 Added: 2009-07-29
 %%
 Type: language
+Subtag: yxa
+Description: Mayawali
+Added: 2013-09-10
+%%
+Type: language
 Subtag: yxg
 Description: Yagara
 Added: 2012-08-12
 %%
 Type: language
+Subtag: yxl
+Description: Yardliyawarra
+Added: 2013-09-10
+%%
+Type: language
+Subtag: yxm
+Description: Yinwum
+Added: 2013-09-10
+%%
+Type: language
+Subtag: yxu
+Description: Yuyu
+Added: 2013-09-10
+%%
+Type: language
 Subtag: yxy
 Description: Yabula Yabula
 Added: 2012-08-12
 %%
 Type: language
+Subtag: yyr
+Description: Yir Yoront
+Added: 2013-09-03
+%%
+Type: language
 Subtag: yyu
 Description: Yau (Sandaun Province)
 Added: 2009-07-29
@@ -40096,6 +40733,11 @@ Added: 2009-07-29
 Macrolanguage: za
 %%
 Type: language
+Subtag: zgh
+Description: Standard Moroccan Tamazight
+Added: 2013-01-25
+%%
+Type: language
 Subtag: zgm
 Description: Minz Zhuang
 Added: 2009-07-29
@@ -40859,7 +41501,7 @@ Macrolanguage: za
 %%
 Type: language
 Subtag: zyp
-Description: Zyphe
+Description: Zyphe Chin
 Added: 2009-07-29
 %%
 Type: language
@@ -42574,6 +43216,11 @@ Description: Afaka
 Added: 2011-01-07
 %%
 Type: script
+Subtag: Aghb
+Description: Caucasian Albanian
+Added: 2012-11-01
+%%
+Type: script
 Subtag: Arab
 Description: Arabic
 Added: 2005-10-16
@@ -42844,6 +43491,7 @@ Added: 2005-10-16
 Type: script
 Subtag: Hung
 Description: Old Hungarian
+Description: Hungarian Runic
 Added: 2005-10-16
 %%
 Type: script
@@ -42986,6 +43634,11 @@ Description: Lydian
 Added: 2006-07-21
 %%
 Type: script
+Subtag: Mahj
+Description: Mahajani
+Added: 2012-11-01
+%%
+Type: script
 Subtag: Mand
 Description: Mandaic
 Description: Mandaean
@@ -44404,7 +45057,7 @@ Added: 2005-10-16
 %%
 Type: region
 Subtag: PS
-Description: Occupied Palestinian Territory
+Description: State of Palestine
 Added: 2005-10-16
 %%
 Type: region
-- 
cgit v1.2.3


From cfef3e9e4408444babb2b312a4f4617617048384 Mon Sep 17 00:00:00 2001
From: weijun 
Date: Thu, 17 Oct 2013 20:56:07 +0800
Subject: 8026712: TEST_BUG: update sun/security/tools/keytool/autotest.sh with
 a new location to find of libsoftokn3.so Reviewed-by: vinnie

---
 test/sun/security/tools/keytool/autotest.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'test')

diff --git a/test/sun/security/tools/keytool/autotest.sh b/test/sun/security/tools/keytool/autotest.sh
index 7afed3ea7..0d8e57ce6 100644
--- a/test/sun/security/tools/keytool/autotest.sh
+++ b/test/sun/security/tools/keytool/autotest.sh
@@ -73,11 +73,13 @@ case "$OS" in
     if [ $B32 = true ]; then
         LIBNAME=`find_one \
             "/usr/lib/libsoftokn3.so" \
-            "/usr/lib/i386-linux-gnu/nss/libsoftokn3.so"`
+            "/usr/lib/i386-linux-gnu/nss/libsoftokn3.so" \
+            "/usr/lib/nss/libsoftokn3.so"`
     else
         LIBNAME=`find_one \
             "/usr/lib64/libsoftokn3.so" \
-            "/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so"`
+            "/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so" \
+            "/usr/lib/nss/libsoftokn3.so"`
     fi
     ;;
   * )
-- 
cgit v1.2.3


From e044bfcae20c6919efbedc5a973e8c492b2e458a Mon Sep 17 00:00:00 2001
From: drchase 
Date: Wed, 16 Oct 2013 17:55:49 -0400
Subject: 8022718: Runtime accessibility checking: protected class, if
 extended, should be accessible from another package Summary: Modify
 accessibility check; it was muddled about Java vs JVM protection terminology.
 Reviewed-by: jrose

---
 .../invoke/accessProtectedSuper/BogoLoader.java    | 157 +++++++++++++++++++++
 .../invoke/accessProtectedSuper/MethodInvoker.java |  40 ++++++
 .../lang/invoke/accessProtectedSuper/Test.java     | 119 ++++++++++++++++
 .../anotherpkg/MethodSupplierOuter.java            |  34 +++++
 4 files changed, 350 insertions(+)
 create mode 100644 test/java/lang/invoke/accessProtectedSuper/BogoLoader.java
 create mode 100644 test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java
 create mode 100644 test/java/lang/invoke/accessProtectedSuper/Test.java
 create mode 100644 test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java

(limited to 'test')

diff --git a/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java b/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java
new file mode 100644
index 000000000..190761dd6
--- /dev/null
+++ b/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java
@@ -0,0 +1,157 @@
+/*
+ * 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.
+ *
+ */
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+import jdk.internal.org.objectweb.asm.*;
+// Compile with -XDignore.symbol.file=true
+
+public class BogoLoader extends ClassLoader {
+
+    static interface VisitorMaker {
+    ClassVisitor make(ClassVisitor visitor);
+    }
+
+
+    /**
+     * Use this property to verify that the desired classloading is happening.
+     */
+    private final boolean verbose = Boolean.getBoolean("bogoloader.verbose");
+    /**
+     * Use this property to disable replacement for testing purposes.
+     */
+    private final boolean noReplace = Boolean.getBoolean("bogoloader.noreplace");
+
+    /**
+     * Set of class names that should be loaded with this loader.
+     * Others are loaded with the system class loader, except for those
+     * that are transformed.
+     */
+    private Set nonSystem;
+
+    /**
+     * Map from class names to a bytecode transformer factory.
+     */
+    private Map replaced;
+
+    /**
+     * Keep track (not terribly efficiently) of which classes have already
+     * been loaded by this class loader.
+     */
+    private final Vector history = new Vector();
+
+    private boolean useSystemLoader(String name) {
+        return ! nonSystem.contains(name) && ! replaced.containsKey(name);
+    }
+
+    public BogoLoader(Set non_system, Map replaced) {
+        super(Thread.currentThread().getContextClassLoader());
+        this.nonSystem = non_system;
+        this.replaced = replaced;
+    }
+
+    private byte[] readResource(String className) throws IOException {
+        return readResource(className, "class");
+    }
+
+    private byte[] readResource(String className, String suffix) throws IOException {
+        // Note to the unwary -- "/" works on Windows, leave it alone.
+        String fileName = className.replace('.', '/') + "." + suffix;
+        InputStream origStream = getResourceAsStream(fileName);
+        if (origStream == null) {
+            throw new IOException("Resource not found : " + fileName);
+        }
+        BufferedInputStream stream = new java.io.BufferedInputStream(origStream);
+        byte[] data = new byte[stream.available()];
+        int how_many = stream.read(data);
+        // Really ought to deal with the corner cases of stream.available()
+        return data;
+    }
+
+    protected byte[] getClass(String name) throws ClassNotFoundException,
+    IOException {
+        return readResource(name, "class");
+    }
+
+    /**
+     * Loads the named class from the system class loader unless
+     * the name appears in either replaced or nonSystem.
+     * nonSystem classes are loaded into this classloader,
+     * and replaced classes get their content from the specified array
+     * of bytes (and are also loaded into this classloader).
+     */
+    protected Class loadClass(String name, boolean resolve)
+            throws ClassNotFoundException {
+        Class clazz;
+
+        if (history.contains(name)) {
+            Class c = this.findLoadedClass(name);
+            return c;
+        }
+        if (useSystemLoader(name)) {
+            clazz = findSystemClass(name);
+            if (verbose) System.err.println("Loading system class " + name);
+        } else {
+            history.add(name);
+            try {
+                if (verbose) {
+                    System.err.println("Loading classloader class " + name);
+                }
+                byte[] classData = getClass(name);;
+                boolean expanded = false;
+                if (!noReplace && replaced.containsKey(name)) {
+                    if (verbose) {
+                        System.err.println("Replacing class " + name);
+                    }
+                    ClassReader cr = new ClassReader(classData);
+                    ClassWriter cw = new ClassWriter(0);
+                    VisitorMaker vm = replaced.get(name);
+                    cr.accept(vm.make(cw), 0);
+                    classData = cw.toByteArray();
+                }
+                clazz = defineClass(name, classData, 0, classData.length);
+            } catch (java.io.EOFException ioe) {
+                throw new ClassNotFoundException(
+                        "IO Exception in reading class : " + name + " ", ioe);
+            } catch (ClassFormatError ioe) {
+                throw new ClassNotFoundException(
+                        "ClassFormatError in reading class file: ", ioe);
+            } catch (IOException ioe) {
+                throw new ClassNotFoundException(
+                        "IO Exception in reading class file: ", ioe);
+            }
+        }
+        if (clazz == null) {
+            throw new ClassNotFoundException(name);
+        }
+        if (resolve) {
+            resolveClass(clazz);
+        }
+        return clazz;
+    }
+}
diff --git a/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java b/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java
new file mode 100644
index 000000000..d14e7ef8a
--- /dev/null
+++ b/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ *
+ */
+
+import anotherpkg.MethodSupplierOuter;
+
+public class MethodInvoker extends MethodSupplierOuter.MethodSupplier {
+    public static void invoke() throws Exception {
+        MethodInvoker ms = new MethodInvoker();
+        ms.m();
+        ms.myfi().invokeMethodReference();
+        MyFunctionalInterface fi = ms::m; // Should not fail with modified bytecodes
+        fi.invokeMethodReference();
+    }
+
+    MyFunctionalInterface myfi() {
+        MyFunctionalInterface fi = this::m; // Should not fail with modified bytecodes
+        return fi;
+    }
+}
diff --git a/test/java/lang/invoke/accessProtectedSuper/Test.java b/test/java/lang/invoke/accessProtectedSuper/Test.java
new file mode 100644
index 000000000..3907ceb18
--- /dev/null
+++ b/test/java/lang/invoke/accessProtectedSuper/Test.java
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8022718
+ * @summary Runtime accessibility checking: protected class, if extended, should be accessible from another package
+ *
+ * @compile -XDignore.symbol.file BogoLoader.java MethodInvoker.java Test.java anotherpkg/MethodSupplierOuter.java
+ * @run main/othervm Test
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.HashSet;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.Opcodes;
+
+interface MyFunctionalInterface {
+
+    void invokeMethodReference();
+}
+
+class MakeProtected implements BogoLoader.VisitorMaker, Opcodes {
+
+    final boolean whenVisitInner;
+
+    MakeProtected(boolean when_visit_inner) {
+        super();
+        whenVisitInner = when_visit_inner;
+    }
+
+    public ClassVisitor make(ClassVisitor cv) {
+        return new ClassVisitor(Opcodes.ASM5, cv) {
+
+            @Override
+            public void visitInnerClass(String name, String outerName,
+                    String innerName, int access) {
+                if (whenVisitInner) {
+                    int access_ = (ACC_PROTECTED | access) & ~(ACC_PRIVATE | ACC_PUBLIC);
+                    System.out.println("visitInnerClass: name = " + name
+                            + ", outerName = " + outerName
+                            + ", innerName = " + innerName
+                            + ", access original = 0x" + Integer.toHexString(access)
+                            + ", access modified to 0x" + Integer.toHexString(access_));
+                    access = access_;
+                }
+                super.visitInnerClass(name, outerName, innerName, access);
+            }
+        };
+    }
+};
+
+public class Test {
+
+    public static void main(String argv[]) throws Exception, Throwable {
+        BogoLoader.VisitorMaker makeProtectedNop = new MakeProtected(false);
+        BogoLoader.VisitorMaker makeProtectedMod = new MakeProtected(true);
+
+        int errors = 0;
+        errors += tryModifiedInvocation(makeProtectedNop);
+        errors += tryModifiedInvocation(makeProtectedMod);
+
+        if (errors > 0) {
+            throw new Error("FAIL; there were errors");
+        }
+    }
+
+    private static int tryModifiedInvocation(BogoLoader.VisitorMaker makeProtected)
+            throws Throwable, ClassNotFoundException {
+        HashMap replace
+                = new HashMap();
+        replace.put("anotherpkg.MethodSupplierOuter$MethodSupplier", makeProtected);
+        HashSet in_bogus = new HashSet();
+        in_bogus.add("MethodInvoker");
+        in_bogus.add("MyFunctionalInterface");
+        in_bogus.add("anotherpkg.MethodSupplierOuter"); // seems to be never loaded
+        in_bogus.add("anotherpkg.MethodSupplierOuter$MethodSupplier");
+
+        BogoLoader bl = new BogoLoader(in_bogus, replace);
+        try {
+            Class isw = bl.loadClass("MethodInvoker");
+            Method meth = isw.getMethod("invoke");
+            Object result = meth.invoke(null);
+        } catch (Throwable th) {
+            System.out.flush();
+            Thread.sleep(250); // Let Netbeans get its I/O sorted out.
+            th.printStackTrace();
+            System.err.flush();
+            Thread.sleep(250); // Let Netbeans get its I/O sorted out.
+            return 1;
+        }
+        return 0;
+    }
+}
diff --git a/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java b/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java
new file mode 100644
index 000000000..314f8eab7
--- /dev/null
+++ b/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ */
+
+package anotherpkg;
+
+public class MethodSupplierOuter {
+    // MethodSupplier is "public" for javac compilation, modified to "protected" for test.
+    public static class MethodSupplier {
+        public void m() {
+            System.out.println("good");
+        }
+    }
+}
-- 
cgit v1.2.3


From 945cd937cf99d4ad134adee07c869a5e33bb1ae7 Mon Sep 17 00:00:00 2001
From: mullan 
Date: Thu, 17 Oct 2013 10:18:44 -0400
Subject: 8026346: test/java/lang/SecurityManager/CheckPackageAccess.java
 failing Reviewed-by: vinnie

---
 .../lang/SecurityManager/CheckPackageAccess.java   | 23 ++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

(limited to 'test')

diff --git a/test/java/lang/SecurityManager/CheckPackageAccess.java b/test/java/lang/SecurityManager/CheckPackageAccess.java
index 10752b94b..ba51e9dce 100644
--- a/test/java/lang/SecurityManager/CheckPackageAccess.java
+++ b/test/java/lang/SecurityManager/CheckPackageAccess.java
@@ -29,9 +29,6 @@
  *  @run main/othervm CheckPackageAccess
  */
 
-import java.io.File;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
 import java.security.Security;
 import java.util.Collections;
 import java.util.Arrays;
@@ -50,6 +47,7 @@ public class CheckPackageAccess {
     /*
      * This array should be updated whenever new packages are added to the
      * package.access property in the java.security file
+     * NOTE: it should be in the same order as the java.security file
      */
     private static final String[] packages = {
         "sun.",
@@ -99,14 +97,14 @@ public class CheckPackageAccess {
         List jspkgs =
             getPackages(Security.getProperty("package.access"));
 
-        // get closed restricted packages
-        File f = new File(System.getProperty("test.src"),
-            "../../../../src/closed/share/lib/security/restricted.pkgs");
-        if (f.exists()) {
-            List ipkgs = Files.readAllLines(f.toPath(),
-                                                    StandardCharsets.UTF_8);
+        if (!isOpenJDKOnly()) {
+            String lastPkg = pkgs.get(pkgs.size() - 1);
+
             // Remove any closed packages from list before comparing
-            jspkgs.removeAll(ipkgs);
+            int index = jspkgs.indexOf(lastPkg);
+            if (index != -1 && index != jspkgs.size() - 1) {
+                jspkgs.subList(index + 1, jspkgs.size()).clear();
+            }
         }
 
         // Sort to ensure lists are comparable
@@ -164,4 +162,9 @@ public class CheckPackageAccess {
         }
         return packages;
     }
+
+    private static boolean isOpenJDKOnly() {
+        String prop = System.getProperty("java.runtime.name");
+        return prop != null && prop.startsWith("OpenJDK");
+    }
 }
-- 
cgit v1.2.3


From 1f8ed31e219d47a71cdfd928590093876b878294 Mon Sep 17 00:00:00 2001
From: joehw 
Date: Thu, 17 Oct 2013 11:43:44 -0700
Subject: 8015243: SchemaFactory does not catch enum. value that is not in the
 value space of the base type, anyURI Reviewed-by: lancea

---
 .../xml/jaxp/validation/8015243/AnyURITest.java    | 60 ++++++++++++++++++++++
 .../xml/jaxp/validation/8015243/anyURI_b006.xsd    | 32 ++++++++++++
 2 files changed, 92 insertions(+)
 create mode 100644 test/javax/xml/jaxp/validation/8015243/AnyURITest.java
 create mode 100644 test/javax/xml/jaxp/validation/8015243/anyURI_b006.xsd

(limited to 'test')

diff --git a/test/javax/xml/jaxp/validation/8015243/AnyURITest.java b/test/javax/xml/jaxp/validation/8015243/AnyURITest.java
new file mode 100644
index 000000000..437610c45
--- /dev/null
+++ b/test/javax/xml/jaxp/validation/8015243/AnyURITest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * @test
+ * @bug 8015243
+ * @summary verifies that illegal URI such as // is rejected
+ * @run main/othervm AnyURITest
+ */
+
+import java.io.*;
+import javax.xml.XMLConstants;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+import org.xml.sax.SAXException;
+
+/**
+ * Similar to java.net.URI, allow empty authority prior to non-empty
+ * path, query component or fragment identifier
+ *
+ * @author huizhe.wang@oracle.com
+ */
+public class AnyURITest {
+    static final String XSDFILE = "anyURI_b006.xsd";
+
+    public static void main(String[] args) throws Exception {
+        try{
+            SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
+            Schema schema = schemaFactory.newSchema(new File(System.getProperty("test.src", "."), XSDFILE));
+            throw new RuntimeException("Illegal URI // should be rejected.");
+        } catch (SAXException e) {
+            //expected:
+            //Enumeration value '//' is not in the value space of the base type, anyURI.
+        }
+
+
+    }
+
+}
diff --git a/test/javax/xml/jaxp/validation/8015243/anyURI_b006.xsd b/test/javax/xml/jaxp/validation/8015243/anyURI_b006.xsd
new file mode 100644
index 000000000..ba131d943
--- /dev/null
+++ b/test/javax/xml/jaxp/validation/8015243/anyURI_b006.xsd
@@ -0,0 +1,32 @@
+
+
+    	
+		
+			
+				
+				
+			
+		
+	
+
+    	
+    	
+
+	
+		
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+			
+		
+	
+
+
-- 
cgit v1.2.3


From 5b83b2ab486ecf6b26a977cf8e99c20a7cb9aac8 Mon Sep 17 00:00:00 2001
From: juh 
Date: Thu, 17 Oct 2013 12:00:20 -0700
Subject: 8026233: test/sun/security/tools/keytool/StorePasswords.java needs to
 clean up files Reviewed-by: vinnie

---
 test/sun/security/tools/keytool/StorePasswords.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

(limited to 'test')

diff --git a/test/sun/security/tools/keytool/StorePasswords.java b/test/sun/security/tools/keytool/StorePasswords.java
index e1f0c275b..573947f65 100644
--- a/test/sun/security/tools/keytool/StorePasswords.java
+++ b/test/sun/security/tools/keytool/StorePasswords.java
@@ -77,6 +77,8 @@ public class StorePasswords {
         }
         System.out.println("\nStored " + storeCount + " user passwords, " +
             "recovered " + recoverCount + " user passwords");
+
+        new File(KEYSTORE).delete();
     }
 
     private static int store() throws Exception {
@@ -144,7 +146,9 @@ public class StorePasswords {
 
         // Store the PKCS#12 keystore
         System.out.println("Storing PKCS#12 keystore to: " + KEYSTORE);
-        keystore.store(new FileOutputStream(KEYSTORE), KEYSTORE_PWD);
+        try (FileOutputStream out = new FileOutputStream(KEYSTORE)) {
+            keystore.store(out, KEYSTORE_PWD);
+        }
 
         return count;
     }
@@ -154,7 +158,9 @@ public class StorePasswords {
         // Load the PKCS#12 keystore
         KeyStore keystore = KeyStore.getInstance("PKCS12");
         System.out.println("\nLoading PKCS#12 keystore from: " + KEYSTORE);
-        keystore.load(new FileInputStream(KEYSTORE), KEYSTORE_PWD);
+        try (FileInputStream in = new FileInputStream(KEYSTORE)) {
+            keystore.load(in, KEYSTORE_PWD);
+        }
 
         SecretKey key;
         SecretKeyFactory factory;
-- 
cgit v1.2.3


From 39f464ee2d4591cb3d5421c10d446e9fc64648ca Mon Sep 17 00:00:00 2001
From: mchung 
Date: Thu, 17 Oct 2013 13:22:11 -0700
Subject: 8015912: jdeps support to output in dot file format 8026255: Switch
 jdeps to follow traditional Java option style Reviewed-by: alanb

---
 test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'test')

diff --git a/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java b/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java
index 135dfff0c..868addd35 100644
--- a/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java
+++ b/test/sun/reflect/CallerSensitive/CallerSensitiveFinder.java
@@ -128,7 +128,7 @@ public class CallerSensitiveFinder {
     {
         ExecutorService pool = Executors.newFixedThreadPool(numThreads);
         for (Path path : classes) {
-            ClassFileReader reader = ClassFileReader.newInstance(path.toFile());
+            ClassFileReader reader = ClassFileReader.newInstance(path);
             for (ClassFile cf : reader.getClassFiles()) {
                 String classFileName = cf.getName();
                 // for each ClassFile
-- 
cgit v1.2.3


From dd796f97bde08ef1feea7a64993f48389a14c462 Mon Sep 17 00:00:00 2001
From: mduigou 
Date: Thu, 17 Oct 2013 12:43:32 -0700
Subject: 8004138: ForkJoinTask leaks exceptions Reviewed-by: chegar, mduigou,
 psandoz, martin Contributed-by: Doug Lea 

---
 .../concurrent/forkjoin/FJExceptionTableLeak.java  | 73 ++++++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java

(limited to 'test')

diff --git a/test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java b/test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java
new file mode 100644
index 000000000..f2780a564
--- /dev/null
+++ b/test/java/util/concurrent/forkjoin/FJExceptionTableLeak.java
@@ -0,0 +1,73 @@
+/*
+ * 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:
+ *
+ * Written by Doug Lea with assistance from members of JCP JSR-166
+ * Expert Group and released to the public domain, as explained at
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+/*
+ * @test
+ * @author Doug Lea
+ * @bug 8004138
+ * @summary Check if ForkJoinPool table leaks thrown exceptions.
+ * @run main/othervm -Xmx32m FJExceptionTableLeak
+ */
+import java.util.concurrent.*;
+
+public class FJExceptionTableLeak {
+
+    // Run with TASKS_PER_STEP * 40 < Xmx < STEPS * TASKS_PER_STEP * 40
+    // These work for Xmx32m:
+    static final int STEPS = 2000;
+    static final int TASKS_PER_STEP = 1000;
+
+    static class FailingTaskException extends RuntimeException {}
+    static class FailingTask extends RecursiveAction {
+        public void compute() {
+            throw new FailingTaskException();
+        }
+    }
+
+    public static void main(String[] args) throws InterruptedException {
+        ForkJoinPool pool = new ForkJoinPool(4);
+        FailingTask[] tasks = new FailingTask[TASKS_PER_STEP];
+        for (int k = 0; k < STEPS; ++k) {
+            for (int i = 0; i < tasks.length; ++i)
+                tasks[i] = new FailingTask();
+            for (int i = 0; i < tasks.length; ++i)
+                pool.execute(tasks[i]);
+            for (int i = 0; i < tasks.length; ++i) {
+                try {
+                    tasks[i].join();
+                    throw new AssertionError("should throw");
+                } catch (FailingTaskException success) {}
+            }
+        }
+    }
+}
-- 
cgit v1.2.3


From 4707fed2ab3ae9f4ee99c612520aba5d47b4833e Mon Sep 17 00:00:00 2001
From: weijun 
Date: Fri, 18 Oct 2013 08:57:52 +0800
Subject: 7025699: Policy Tool is not accessible by keyboard Reviewed-by:
 alexp, weijun Contributed-by: Leif Samuelsson 

---
 test/sun/security/tools/policytool/Alias.html             | 8 +++-----
 test/sun/security/tools/policytool/OpenPolicy.html        | 5 +++--
 test/sun/security/tools/policytool/UpdatePermissions.html | 3 ++-
 3 files changed, 8 insertions(+), 8 deletions(-)

(limited to 'test')

diff --git a/test/sun/security/tools/policytool/Alias.html b/test/sun/security/tools/policytool/Alias.html
index 743472629..ee67609e3 100644
--- a/test/sun/security/tools/policytool/Alias.html
+++ b/test/sun/security/tools/policytool/Alias.html
@@ -23,12 +23,10 @@ reading these instructions.

Warning: Principal name 'myalias' specified without a Principal class.
  • Click on "OK"
  • Open the "File" menu, and "Save As" -
  • Enter "p1" as the file name -
  • Click on "OK" -
  • Click on "OK" in the message window +
  • Save using the file name "p1" +
  • Click on "OK" in the status message window
  • Open the "File" menu and "Open Policy" -
  • Enter "p1" as the file name -
  • Click on "OK" +
  • Open the file named "p1"
  • If the file opens successfully, the test passed. Otherwise, the test failed. diff --git a/test/sun/security/tools/policytool/OpenPolicy.html b/test/sun/security/tools/policytool/OpenPolicy.html index 2d12c7d36..19a8a602b 100644 --- a/test/sun/security/tools/policytool/OpenPolicy.html +++ b/test/sun/security/tools/policytool/OpenPolicy.html @@ -9,8 +9,9 @@ reading these instructions.

    First, policytool will be invoked.

    -On Windows, if PolicyTool tries to open the default Policy File
    -and it has the File separator character pointing the wrong way, like:

    +Pull down 'File' menu and select 'View Warning Log', which shows that +the default Policy File is not found. On Windows, if the file name +has the File separator character pointing the wrong way, like:

    C:\windows/java.policy

    diff --git a/test/sun/security/tools/policytool/UpdatePermissions.html b/test/sun/security/tools/policytool/UpdatePermissions.html index 31e6fcf7f..c840c323b 100644 --- a/test/sun/security/tools/policytool/UpdatePermissions.html +++ b/test/sun/security/tools/policytool/UpdatePermissions.html @@ -12,6 +12,7 @@ First, policytool will be invoked.

    Then, follow these steps:
    0) Find (or create) a temporary directory that you have write access to. (Example: 'C:\foo\tmp' on Windows or '/tmp' on other systems)

    + 1) Click on the "Add Policy Entry" button in the main policytool window.

    @@ -31,7 +32,7 @@ select "listenToAllAWTEvents".

    select "Save As".

    8) In the SaveAs window, enter "/tmp/ptool.test" as the file name -and click "OK".
    +and save it. If the file already exists, just replace it.
    (Or use the temporary directory mentioned in Step 0 if it's not '/tmp'. For example, "C:\foo\tmp\ptool.test" on Windows)

    -- cgit v1.2.3